silverwolf-x's picture
download
raw
980 Bytes
import { defineRule } from '../utils/define-rule'
const url = 'https://nextjs.org/docs/messages/no-sync-scripts'
export default defineRule({
meta: {
docs: {
description: 'Prevent synchronous scripts.',
recommended: true,
url,
},
type: 'problem',
schema: [],
},
create(context) {
return {
JSXOpeningElement(node) {
if (node.name.name !== 'script') {
return
}
if (node.attributes.length === 0) {
return
}
const attributeNames = node.attributes
.filter((attr) => attr.type === 'JSXAttribute')
.map((attr) => attr.name.name)
if (
attributeNames.includes('src') &&
!attributeNames.includes('async') &&
!attributeNames.includes('defer')
) {
context.report({
node,
message: `Synchronous scripts should not be used. See: ${url}`,
})
}
},
}
},
})

Xet Storage Details

Size:
980 Bytes
·
Xet hash:
449d64081b4b67fd324bed2d9885ae0c99b61a842e07d9f8116c4c885a4be3d6

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.