main repo

This commit is contained in:
Basilosaurusrex
2025-11-24 18:09:40 +01:00
parent b636ee5e70
commit f027651f9b
34146 changed files with 4436636 additions and 0 deletions

View File

@@ -0,0 +1,44 @@
"use strict";
var _definerule = require("../utils/define-rule");
var url = "https://nextjs.org/docs/messages/no-script-component-in-head";
module.exports = (0, _definerule.defineRule)({
meta: {
docs: {
description: "Prevent usage of `next/script` in `next/head` component.",
recommended: true,
url: url
},
type: "problem",
schema: []
},
create: function create(context) {
var isNextHead = null;
return {
ImportDeclaration: function ImportDeclaration(node) {
if (node.source.value === "next/head") {
isNextHead = node.source.value;
}
if (node.source.value !== "next/script") {
return;
}
},
JSXElement: function JSXElement(node) {
if (!isNextHead) {
return;
}
if (node.openingElement && node.openingElement.name && node.openingElement.name.name !== "Head") {
return;
}
var scriptTag = node.children.find(function(child) {
return child.openingElement && child.openingElement.name && child.openingElement.name.name === "Script";
});
if (scriptTag) {
context.report({
node: node,
message: "`next/script` should not be used in `next/head` component. Move `<Script />` outside of `<Head>` instead. See: ".concat(url)
});
}
}
};
}
});