eslint-plugin-nextjs 0.1.2 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +13 -13
- package/dist/index.d.ts +3 -6
- package/dist/index.js +399 -264
- package/dist/index.js.map +1 -1
- package/package.json +18 -12
- package/dist/index.cjs +0 -1485
- package/dist/index.cjs.map +0 -1
- package/dist/index.d.cts +0 -11
- package/dist/rules/google-font-display.cjs +0 -119
- package/dist/rules/google-font-display.cjs.map +0 -1
- package/dist/rules/google-font-display.d.cts +0 -8
- package/dist/rules/google-font-display.d.ts +0 -8
- package/dist/rules/google-font-display.js +0 -92
- package/dist/rules/google-font-display.js.map +0 -1
- package/dist/rules/google-font-preconnect.cjs +0 -109
- package/dist/rules/google-font-preconnect.cjs.map +0 -1
- package/dist/rules/google-font-preconnect.d.cts +0 -5
- package/dist/rules/google-font-preconnect.d.ts +0 -5
- package/dist/rules/google-font-preconnect.js +0 -82
- package/dist/rules/google-font-preconnect.js.map +0 -1
- package/dist/rules/inline-script-id.cjs +0 -94
- package/dist/rules/inline-script-id.cjs.map +0 -1
- package/dist/rules/inline-script-id.d.cts +0 -5
- package/dist/rules/inline-script-id.d.ts +0 -5
- package/dist/rules/inline-script-id.js +0 -67
- package/dist/rules/inline-script-id.js.map +0 -1
- package/dist/rules/next-script-for-ga.cjs +0 -129
- package/dist/rules/next-script-for-ga.cjs.map +0 -1
- package/dist/rules/next-script-for-ga.d.cts +0 -5
- package/dist/rules/next-script-for-ga.d.ts +0 -5
- package/dist/rules/next-script-for-ga.js +0 -102
- package/dist/rules/next-script-for-ga.js.map +0 -1
- package/dist/rules/no-assign-module-variable.cjs +0 -64
- package/dist/rules/no-assign-module-variable.cjs.map +0 -1
- package/dist/rules/no-assign-module-variable.d.cts +0 -5
- package/dist/rules/no-assign-module-variable.d.ts +0 -5
- package/dist/rules/no-assign-module-variable.js +0 -37
- package/dist/rules/no-assign-module-variable.js.map +0 -1
- package/dist/rules/no-async-client-component.cjs +0 -99
- package/dist/rules/no-async-client-component.cjs.map +0 -1
- package/dist/rules/no-async-client-component.d.cts +0 -5
- package/dist/rules/no-async-client-component.d.ts +0 -5
- package/dist/rules/no-async-client-component.js +0 -72
- package/dist/rules/no-async-client-component.js.map +0 -1
- package/dist/rules/no-before-interactive-script-outside-document.cjs +0 -94
- package/dist/rules/no-before-interactive-script-outside-document.cjs.map +0 -1
- package/dist/rules/no-before-interactive-script-outside-document.d.cts +0 -5
- package/dist/rules/no-before-interactive-script-outside-document.d.ts +0 -5
- package/dist/rules/no-before-interactive-script-outside-document.js +0 -59
- package/dist/rules/no-before-interactive-script-outside-document.js.map +0 -1
- package/dist/rules/no-css-tags.cjs +0 -70
- package/dist/rules/no-css-tags.cjs.map +0 -1
- package/dist/rules/no-css-tags.d.cts +0 -5
- package/dist/rules/no-css-tags.d.ts +0 -5
- package/dist/rules/no-css-tags.js +0 -43
- package/dist/rules/no-css-tags.js.map +0 -1
- package/dist/rules/no-document-import-in-page.cjs +0 -74
- package/dist/rules/no-document-import-in-page.cjs.map +0 -1
- package/dist/rules/no-document-import-in-page.d.cts +0 -5
- package/dist/rules/no-document-import-in-page.d.ts +0 -5
- package/dist/rules/no-document-import-in-page.js +0 -39
- package/dist/rules/no-document-import-in-page.js.map +0 -1
- package/dist/rules/no-duplicate-head.cjs +0 -87
- package/dist/rules/no-duplicate-head.cjs.map +0 -1
- package/dist/rules/no-duplicate-head.d.cts +0 -5
- package/dist/rules/no-duplicate-head.d.ts +0 -5
- package/dist/rules/no-duplicate-head.js +0 -60
- package/dist/rules/no-duplicate-head.js.map +0 -1
- package/dist/rules/no-head-element.cjs +0 -76
- package/dist/rules/no-head-element.cjs.map +0 -1
- package/dist/rules/no-head-element.d.cts +0 -5
- package/dist/rules/no-head-element.d.ts +0 -5
- package/dist/rules/no-head-element.js +0 -41
- package/dist/rules/no-head-element.js.map +0 -1
- package/dist/rules/no-head-import-in-document.cjs +0 -76
- package/dist/rules/no-head-import-in-document.cjs.map +0 -1
- package/dist/rules/no-head-import-in-document.d.cts +0 -5
- package/dist/rules/no-head-import-in-document.d.ts +0 -5
- package/dist/rules/no-head-import-in-document.js +0 -41
- package/dist/rules/no-head-import-in-document.js.map +0 -1
- package/dist/rules/no-html-link-for-pages.cjs +0 -302
- package/dist/rules/no-html-link-for-pages.cjs.map +0 -1
- package/dist/rules/no-html-link-for-pages.d.cts +0 -5
- package/dist/rules/no-html-link-for-pages.d.ts +0 -5
- package/dist/rules/no-html-link-for-pages.js +0 -267
- package/dist/rules/no-html-link-for-pages.js.map +0 -1
- package/dist/rules/no-img-element.cjs +0 -83
- package/dist/rules/no-img-element.cjs.map +0 -1
- package/dist/rules/no-img-element.d.cts +0 -5
- package/dist/rules/no-img-element.d.ts +0 -5
- package/dist/rules/no-img-element.js +0 -48
- package/dist/rules/no-img-element.js.map +0 -1
- package/dist/rules/no-page-custom-font.cjs +0 -184
- package/dist/rules/no-page-custom-font.cjs.map +0 -1
- package/dist/rules/no-page-custom-font.d.cts +0 -5
- package/dist/rules/no-page-custom-font.d.ts +0 -5
- package/dist/rules/no-page-custom-font.js +0 -159
- package/dist/rules/no-page-custom-font.js.map +0 -1
- package/dist/rules/no-script-component-in-head.cjs +0 -74
- package/dist/rules/no-script-component-in-head.cjs.map +0 -1
- package/dist/rules/no-script-component-in-head.d.cts +0 -5
- package/dist/rules/no-script-component-in-head.d.ts +0 -5
- package/dist/rules/no-script-component-in-head.js +0 -47
- package/dist/rules/no-script-component-in-head.js.map +0 -1
- package/dist/rules/no-styled-jsx-in-document.cjs +0 -78
- package/dist/rules/no-styled-jsx-in-document.cjs.map +0 -1
- package/dist/rules/no-styled-jsx-in-document.d.cts +0 -5
- package/dist/rules/no-styled-jsx-in-document.d.ts +0 -5
- package/dist/rules/no-styled-jsx-in-document.js +0 -43
- package/dist/rules/no-styled-jsx-in-document.js.map +0 -1
- package/dist/rules/no-sync-scripts.cjs +0 -64
- package/dist/rules/no-sync-scripts.cjs.map +0 -1
- package/dist/rules/no-sync-scripts.d.cts +0 -5
- package/dist/rules/no-sync-scripts.d.ts +0 -5
- package/dist/rules/no-sync-scripts.js +0 -37
- package/dist/rules/no-sync-scripts.js.map +0 -1
- package/dist/rules/no-title-in-document-head.cjs +0 -78
- package/dist/rules/no-title-in-document-head.cjs.map +0 -1
- package/dist/rules/no-title-in-document-head.d.cts +0 -5
- package/dist/rules/no-title-in-document-head.d.ts +0 -5
- package/dist/rules/no-title-in-document-head.js +0 -51
- package/dist/rules/no-title-in-document-head.js.map +0 -1
- package/dist/rules/no-typos.cjs +0 -133
- package/dist/rules/no-typos.cjs.map +0 -1
- package/dist/rules/no-typos.d.cts +0 -5
- package/dist/rules/no-typos.d.ts +0 -5
- package/dist/rules/no-typos.js +0 -98
- package/dist/rules/no-typos.js.map +0 -1
- package/dist/rules/no-unwanted-polyfillio.cjs +0 -164
- package/dist/rules/no-unwanted-polyfillio.cjs.map +0 -1
- package/dist/rules/no-unwanted-polyfillio.d.cts +0 -5
- package/dist/rules/no-unwanted-polyfillio.d.ts +0 -5
- package/dist/rules/no-unwanted-polyfillio.js +0 -137
- package/dist/rules/no-unwanted-polyfillio.js.map +0 -1
- package/dist/utils/define-rule.cjs +0 -31
- package/dist/utils/define-rule.cjs.map +0 -1
- package/dist/utils/define-rule.d.cts +0 -5
- package/dist/utils/define-rule.d.ts +0 -5
- package/dist/utils/define-rule.js +0 -6
- package/dist/utils/define-rule.js.map +0 -1
- package/dist/utils/get-root-dirs.cjs +0 -60
- package/dist/utils/get-root-dirs.cjs.map +0 -1
- package/dist/utils/get-root-dirs.d.cts +0 -8
- package/dist/utils/get-root-dirs.d.ts +0 -8
- package/dist/utils/get-root-dirs.js +0 -25
- package/dist/utils/get-root-dirs.js.map +0 -1
- package/dist/utils/node-attributes.cjs +0 -67
- package/dist/utils/node-attributes.cjs.map +0 -1
- package/dist/utils/node-attributes.d.cts +0 -15
- package/dist/utils/node-attributes.d.ts +0 -15
- package/dist/utils/node-attributes.js +0 -46
- package/dist/utils/node-attributes.js.map +0 -1
- package/dist/utils/url.cjs +0 -167
- package/dist/utils/url.cjs.map +0 -1
- package/dist/utils/url.d.cts +0 -35
- package/dist/utils/url.d.ts +0 -35
- package/dist/utils/url.js +0 -128
- package/dist/utils/url.js.map +0 -1
@@ -1,74 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
var __create = Object.create;
|
3
|
-
var __defProp = Object.defineProperty;
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
8
|
-
var __export = (target, all) => {
|
9
|
-
for (var name in all)
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
11
|
-
};
|
12
|
-
var __copyProps = (to, from, except, desc) => {
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
14
|
-
for (let key of __getOwnPropNames(from))
|
15
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
17
|
-
}
|
18
|
-
return to;
|
19
|
-
};
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
26
|
-
mod
|
27
|
-
));
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
29
|
-
|
30
|
-
// src/rules/no-document-import-in-page.ts
|
31
|
-
var no_document_import_in_page_exports = {};
|
32
|
-
__export(no_document_import_in_page_exports, {
|
33
|
-
noDocumentImportInPage: () => noDocumentImportInPage
|
34
|
-
});
|
35
|
-
module.exports = __toCommonJS(no_document_import_in_page_exports);
|
36
|
-
var path = __toESM(require("path"), 1);
|
37
|
-
|
38
|
-
// src/utils/define-rule.ts
|
39
|
-
var defineRule = (rule) => rule;
|
40
|
-
|
41
|
-
// src/rules/no-document-import-in-page.ts
|
42
|
-
var url = "https://nextjs.org/docs/messages/no-document-import-in-page";
|
43
|
-
var noDocumentImportInPage = defineRule({
|
44
|
-
create: (context) => ({
|
45
|
-
ImportDeclaration: (node) => {
|
46
|
-
if (node.source.value !== "next/document") {
|
47
|
-
return;
|
48
|
-
}
|
49
|
-
const paths = context.filename.split("pages");
|
50
|
-
const page = paths[paths.length - 1];
|
51
|
-
if (!page || page.startsWith(`${path.sep}_document`) || page.startsWith(`${path.posix.sep}_document`)) {
|
52
|
-
return;
|
53
|
-
}
|
54
|
-
context.report({
|
55
|
-
message: `\`<Document />\` from \`next/document\` should not be imported outside of \`pages/_document.js\`. See: ${url}`,
|
56
|
-
node
|
57
|
-
});
|
58
|
-
}
|
59
|
-
}),
|
60
|
-
meta: {
|
61
|
-
docs: {
|
62
|
-
description: "Prevent importing `next/document` outside of `pages/_document.js`.",
|
63
|
-
recommended: true,
|
64
|
-
url
|
65
|
-
},
|
66
|
-
schema: [],
|
67
|
-
type: "problem"
|
68
|
-
}
|
69
|
-
});
|
70
|
-
// Annotate the CommonJS export names for ESM import in node:
|
71
|
-
0 && (module.exports = {
|
72
|
-
noDocumentImportInPage
|
73
|
-
});
|
74
|
-
//# sourceMappingURL=no-document-import-in-page.cjs.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"sources":["../../src/rules/no-document-import-in-page.ts","../../src/utils/define-rule.ts"],"sourcesContent":["import * as path from \"node:path\";\n\nimport { defineRule } from \"../utils/define-rule.js\";\n\nconst url = \"https://nextjs.org/docs/messages/no-document-import-in-page\";\n\nexport const noDocumentImportInPage = defineRule({\n create: (context) => ({\n ImportDeclaration: (node) => {\n if (node.source.value !== \"next/document\") {\n return;\n }\n\n const paths = context.filename.split(\"pages\");\n const page = paths[paths.length - 1];\n\n if (\n !page ||\n page.startsWith(`${path.sep}_document`) ||\n page.startsWith(`${path.posix.sep}_document`)\n ) {\n return;\n }\n\n context.report({\n message: `\\`<Document />\\` from \\`next/document\\` should not be imported outside of \\`pages/_document.js\\`. See: ${url}`,\n node,\n });\n },\n }),\n meta: {\n docs: {\n description:\n \"Prevent importing `next/document` outside of `pages/_document.js`.\",\n recommended: true,\n url,\n },\n schema: [],\n type: \"problem\",\n },\n});\n","import type { Rule } from \"eslint\";\n\nexport const defineRule = (rule: Rule.RuleModule): Rule.RuleModule => rule;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,WAAsB;;;ACEf,IAAM,aAAa,CAAC,SAA2C;;;ADEtE,IAAM,MAAM;AAEL,IAAM,yBAAyB,WAAW;AAAA,EAC/C,QAAQ,CAAC,aAAa;AAAA,IACpB,mBAAmB,CAAC,SAAS;AAC3B,UAAI,KAAK,OAAO,UAAU,iBAAiB;AACzC;AAAA,MACF;AAEA,YAAM,QAAQ,QAAQ,SAAS,MAAM,OAAO;AAC5C,YAAM,OAAO,MAAM,MAAM,SAAS,CAAC;AAEnC,UACE,CAAC,QACD,KAAK,WAAW,GAAQ,QAAG,WAAW,KACtC,KAAK,WAAW,GAAQ,WAAM,GAAG,WAAW,GAC5C;AACA;AAAA,MACF;AAEA,cAAQ,OAAO;AAAA,QACb,SAAS,0GAA0G,GAAG;AAAA,QACtH;AAAA,MACF,CAAC;AAAA,IACH;AAAA,EACF;AAAA,EACA,MAAM;AAAA,IACJ,MAAM;AAAA,MACJ,aACE;AAAA,MACF,aAAa;AAAA,MACb;AAAA,IACF;AAAA,IACA,QAAQ,CAAC;AAAA,IACT,MAAM;AAAA,EACR;AACF,CAAC;","names":[]}
|
@@ -1,39 +0,0 @@
|
|
1
|
-
// src/rules/no-document-import-in-page.ts
|
2
|
-
import * as path from "node:path";
|
3
|
-
|
4
|
-
// src/utils/define-rule.ts
|
5
|
-
var defineRule = (rule) => rule;
|
6
|
-
|
7
|
-
// src/rules/no-document-import-in-page.ts
|
8
|
-
var url = "https://nextjs.org/docs/messages/no-document-import-in-page";
|
9
|
-
var noDocumentImportInPage = defineRule({
|
10
|
-
create: (context) => ({
|
11
|
-
ImportDeclaration: (node) => {
|
12
|
-
if (node.source.value !== "next/document") {
|
13
|
-
return;
|
14
|
-
}
|
15
|
-
const paths = context.filename.split("pages");
|
16
|
-
const page = paths[paths.length - 1];
|
17
|
-
if (!page || page.startsWith(`${path.sep}_document`) || page.startsWith(`${path.posix.sep}_document`)) {
|
18
|
-
return;
|
19
|
-
}
|
20
|
-
context.report({
|
21
|
-
message: `\`<Document />\` from \`next/document\` should not be imported outside of \`pages/_document.js\`. See: ${url}`,
|
22
|
-
node
|
23
|
-
});
|
24
|
-
}
|
25
|
-
}),
|
26
|
-
meta: {
|
27
|
-
docs: {
|
28
|
-
description: "Prevent importing `next/document` outside of `pages/_document.js`.",
|
29
|
-
recommended: true,
|
30
|
-
url
|
31
|
-
},
|
32
|
-
schema: [],
|
33
|
-
type: "problem"
|
34
|
-
}
|
35
|
-
});
|
36
|
-
export {
|
37
|
-
noDocumentImportInPage
|
38
|
-
};
|
39
|
-
//# sourceMappingURL=no-document-import-in-page.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"sources":["../../src/rules/no-document-import-in-page.ts","../../src/utils/define-rule.ts"],"sourcesContent":["import * as path from \"node:path\";\n\nimport { defineRule } from \"../utils/define-rule.js\";\n\nconst url = \"https://nextjs.org/docs/messages/no-document-import-in-page\";\n\nexport const noDocumentImportInPage = defineRule({\n create: (context) => ({\n ImportDeclaration: (node) => {\n if (node.source.value !== \"next/document\") {\n return;\n }\n\n const paths = context.filename.split(\"pages\");\n const page = paths[paths.length - 1];\n\n if (\n !page ||\n page.startsWith(`${path.sep}_document`) ||\n page.startsWith(`${path.posix.sep}_document`)\n ) {\n return;\n }\n\n context.report({\n message: `\\`<Document />\\` from \\`next/document\\` should not be imported outside of \\`pages/_document.js\\`. See: ${url}`,\n node,\n });\n },\n }),\n meta: {\n docs: {\n description:\n \"Prevent importing `next/document` outside of `pages/_document.js`.\",\n recommended: true,\n url,\n },\n schema: [],\n type: \"problem\",\n },\n});\n","import type { Rule } from \"eslint\";\n\nexport const defineRule = (rule: Rule.RuleModule): Rule.RuleModule => rule;\n"],"mappings":";AAAA,YAAY,UAAU;;;ACEf,IAAM,aAAa,CAAC,SAA2C;;;ADEtE,IAAM,MAAM;AAEL,IAAM,yBAAyB,WAAW;AAAA,EAC/C,QAAQ,CAAC,aAAa;AAAA,IACpB,mBAAmB,CAAC,SAAS;AAC3B,UAAI,KAAK,OAAO,UAAU,iBAAiB;AACzC;AAAA,MACF;AAEA,YAAM,QAAQ,QAAQ,SAAS,MAAM,OAAO;AAC5C,YAAM,OAAO,MAAM,MAAM,SAAS,CAAC;AAEnC,UACE,CAAC,QACD,KAAK,WAAW,GAAQ,QAAG,WAAW,KACtC,KAAK,WAAW,GAAQ,WAAM,GAAG,WAAW,GAC5C;AACA;AAAA,MACF;AAEA,cAAQ,OAAO;AAAA,QACb,SAAS,0GAA0G,GAAG;AAAA,QACtH;AAAA,MACF,CAAC;AAAA,IACH;AAAA,EACF;AAAA,EACA,MAAM;AAAA,IACJ,MAAM;AAAA,MACJ,aACE;AAAA,MACF,aAAa;AAAA,MACb;AAAA,IACF;AAAA,IACA,QAAQ,CAAC;AAAA,IACT,MAAM;AAAA,EACR;AACF,CAAC;","names":[]}
|
@@ -1,87 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
var __defProp = Object.defineProperty;
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
6
|
-
var __export = (target, all) => {
|
7
|
-
for (var name in all)
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
9
|
-
};
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
12
|
-
for (let key of __getOwnPropNames(from))
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
15
|
-
}
|
16
|
-
return to;
|
17
|
-
};
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
19
|
-
|
20
|
-
// src/rules/no-duplicate-head.ts
|
21
|
-
var no_duplicate_head_exports = {};
|
22
|
-
__export(no_duplicate_head_exports, {
|
23
|
-
noDuplicateHead: () => noDuplicateHead
|
24
|
-
});
|
25
|
-
module.exports = __toCommonJS(no_duplicate_head_exports);
|
26
|
-
|
27
|
-
// src/utils/define-rule.ts
|
28
|
-
var defineRule = (rule) => rule;
|
29
|
-
|
30
|
-
// src/rules/no-duplicate-head.ts
|
31
|
-
var url = "https://nextjs.org/docs/messages/no-duplicate-head";
|
32
|
-
var noDuplicateHead = defineRule({
|
33
|
-
create: (context) => {
|
34
|
-
const { sourceCode } = context;
|
35
|
-
let documentImportName = null;
|
36
|
-
return {
|
37
|
-
ImportDeclaration: (node) => {
|
38
|
-
if (node.source.value === "next/document") {
|
39
|
-
const documentImport = node.specifiers.find(
|
40
|
-
({ type }) => type === "ImportDefaultSpecifier"
|
41
|
-
);
|
42
|
-
if (documentImport?.local) {
|
43
|
-
documentImportName = documentImport.local.name;
|
44
|
-
}
|
45
|
-
}
|
46
|
-
},
|
47
|
-
ReturnStatement: (node) => {
|
48
|
-
const ancestors = sourceCode.getAncestors(node);
|
49
|
-
const documentClass = ancestors.find(
|
50
|
-
(ancestorNode) => ancestorNode.type === "ClassDeclaration" && ancestorNode.superClass && "name" in ancestorNode.superClass && ancestorNode.superClass.name === documentImportName
|
51
|
-
);
|
52
|
-
if (!documentClass) {
|
53
|
-
return;
|
54
|
-
}
|
55
|
-
if (node.argument && "children" in node.argument && // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
56
|
-
node.argument.children) {
|
57
|
-
const headComponents = node.argument.children.filter(
|
58
|
-
(childrenNode) => childrenNode.openingElement?.name && childrenNode.openingElement.name.name === "Head"
|
59
|
-
);
|
60
|
-
if (headComponents.length > 1) {
|
61
|
-
for (let i = 1; i < headComponents.length; i++) {
|
62
|
-
context.report({
|
63
|
-
message: `Do not include multiple instances of \`<Head/>\`. See: ${url}`,
|
64
|
-
// @ts-expect-error initial override, TODO: fix
|
65
|
-
node: headComponents[i]
|
66
|
-
});
|
67
|
-
}
|
68
|
-
}
|
69
|
-
}
|
70
|
-
}
|
71
|
-
};
|
72
|
-
},
|
73
|
-
meta: {
|
74
|
-
docs: {
|
75
|
-
description: "Prevent duplicate usage of `<Head>` in `pages/_document.js`.",
|
76
|
-
recommended: true,
|
77
|
-
url
|
78
|
-
},
|
79
|
-
schema: [],
|
80
|
-
type: "problem"
|
81
|
-
}
|
82
|
-
});
|
83
|
-
// Annotate the CommonJS export names for ESM import in node:
|
84
|
-
0 && (module.exports = {
|
85
|
-
noDuplicateHead
|
86
|
-
});
|
87
|
-
//# sourceMappingURL=no-duplicate-head.cjs.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"sources":["../../src/rules/no-duplicate-head.ts","../../src/utils/define-rule.ts"],"sourcesContent":["import { defineRule } from \"../utils/define-rule.js\";\nconst url = \"https://nextjs.org/docs/messages/no-duplicate-head\";\n\nexport const noDuplicateHead = defineRule({\n create: (context) => {\n const { sourceCode } = context;\n let documentImportName: null | string = null;\n return {\n ImportDeclaration: (node) => {\n if (node.source.value === \"next/document\") {\n const documentImport = node.specifiers.find(\n ({ type }) => type === \"ImportDefaultSpecifier\",\n );\n if (documentImport?.local) {\n documentImportName = documentImport.local.name;\n }\n }\n },\n ReturnStatement: (node) => {\n const ancestors = sourceCode.getAncestors(node);\n const documentClass = ancestors.find(\n (ancestorNode) =>\n ancestorNode.type === \"ClassDeclaration\" &&\n ancestorNode.superClass &&\n \"name\" in ancestorNode.superClass &&\n ancestorNode.superClass.name === documentImportName,\n );\n\n if (!documentClass) {\n return;\n }\n\n if (\n node.argument &&\n \"children\" in node.argument &&\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n node.argument.children\n ) {\n const headComponents = node.argument.children.filter(\n (childrenNode: any) =>\n childrenNode.openingElement?.name &&\n childrenNode.openingElement.name.name === \"Head\",\n );\n\n if (headComponents.length > 1) {\n for (let i = 1; i < headComponents.length; i++) {\n context.report({\n message: `Do not include multiple instances of \\`<Head/>\\`. See: ${url}`,\n // @ts-expect-error initial override, TODO: fix\n node: headComponents[i],\n });\n }\n }\n }\n },\n };\n },\n meta: {\n docs: {\n description:\n \"Prevent duplicate usage of `<Head>` in `pages/_document.js`.\",\n recommended: true,\n url,\n },\n schema: [],\n type: \"problem\",\n },\n});\n","import type { Rule } from \"eslint\";\n\nexport const defineRule = (rule: Rule.RuleModule): Rule.RuleModule => rule;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACEO,IAAM,aAAa,CAAC,SAA2C;;;ADDtE,IAAM,MAAM;AAEL,IAAM,kBAAkB,WAAW;AAAA,EACxC,QAAQ,CAAC,YAAY;AACnB,UAAM,EAAE,WAAW,IAAI;AACvB,QAAI,qBAAoC;AACxC,WAAO;AAAA,MACL,mBAAmB,CAAC,SAAS;AAC3B,YAAI,KAAK,OAAO,UAAU,iBAAiB;AACzC,gBAAM,iBAAiB,KAAK,WAAW;AAAA,YACrC,CAAC,EAAE,KAAK,MAAM,SAAS;AAAA,UACzB;AACA,cAAI,gBAAgB,OAAO;AACzB,iCAAqB,eAAe,MAAM;AAAA,UAC5C;AAAA,QACF;AAAA,MACF;AAAA,MACA,iBAAiB,CAAC,SAAS;AACzB,cAAM,YAAY,WAAW,aAAa,IAAI;AAC9C,cAAM,gBAAgB,UAAU;AAAA,UAC9B,CAAC,iBACC,aAAa,SAAS,sBACtB,aAAa,cACb,UAAU,aAAa,cACvB,aAAa,WAAW,SAAS;AAAA,QACrC;AAEA,YAAI,CAAC,eAAe;AAClB;AAAA,QACF;AAEA,YACE,KAAK,YACL,cAAc,KAAK;AAAA,QAEnB,KAAK,SAAS,UACd;AACA,gBAAM,iBAAiB,KAAK,SAAS,SAAS;AAAA,YAC5C,CAAC,iBACC,aAAa,gBAAgB,QAC7B,aAAa,eAAe,KAAK,SAAS;AAAA,UAC9C;AAEA,cAAI,eAAe,SAAS,GAAG;AAC7B,qBAAS,IAAI,GAAG,IAAI,eAAe,QAAQ,KAAK;AAC9C,sBAAQ,OAAO;AAAA,gBACb,SAAS,0DAA0D,GAAG;AAAA;AAAA,gBAEtE,MAAM,eAAe,CAAC;AAAA,cACxB,CAAC;AAAA,YACH;AAAA,UACF;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAAA,EACA,MAAM;AAAA,IACJ,MAAM;AAAA,MACJ,aACE;AAAA,MACF,aAAa;AAAA,MACb;AAAA,IACF;AAAA,IACA,QAAQ,CAAC;AAAA,IACT,MAAM;AAAA,EACR;AACF,CAAC;","names":[]}
|
@@ -1,60 +0,0 @@
|
|
1
|
-
// src/utils/define-rule.ts
|
2
|
-
var defineRule = (rule) => rule;
|
3
|
-
|
4
|
-
// src/rules/no-duplicate-head.ts
|
5
|
-
var url = "https://nextjs.org/docs/messages/no-duplicate-head";
|
6
|
-
var noDuplicateHead = defineRule({
|
7
|
-
create: (context) => {
|
8
|
-
const { sourceCode } = context;
|
9
|
-
let documentImportName = null;
|
10
|
-
return {
|
11
|
-
ImportDeclaration: (node) => {
|
12
|
-
if (node.source.value === "next/document") {
|
13
|
-
const documentImport = node.specifiers.find(
|
14
|
-
({ type }) => type === "ImportDefaultSpecifier"
|
15
|
-
);
|
16
|
-
if (documentImport?.local) {
|
17
|
-
documentImportName = documentImport.local.name;
|
18
|
-
}
|
19
|
-
}
|
20
|
-
},
|
21
|
-
ReturnStatement: (node) => {
|
22
|
-
const ancestors = sourceCode.getAncestors(node);
|
23
|
-
const documentClass = ancestors.find(
|
24
|
-
(ancestorNode) => ancestorNode.type === "ClassDeclaration" && ancestorNode.superClass && "name" in ancestorNode.superClass && ancestorNode.superClass.name === documentImportName
|
25
|
-
);
|
26
|
-
if (!documentClass) {
|
27
|
-
return;
|
28
|
-
}
|
29
|
-
if (node.argument && "children" in node.argument && // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
30
|
-
node.argument.children) {
|
31
|
-
const headComponents = node.argument.children.filter(
|
32
|
-
(childrenNode) => childrenNode.openingElement?.name && childrenNode.openingElement.name.name === "Head"
|
33
|
-
);
|
34
|
-
if (headComponents.length > 1) {
|
35
|
-
for (let i = 1; i < headComponents.length; i++) {
|
36
|
-
context.report({
|
37
|
-
message: `Do not include multiple instances of \`<Head/>\`. See: ${url}`,
|
38
|
-
// @ts-expect-error initial override, TODO: fix
|
39
|
-
node: headComponents[i]
|
40
|
-
});
|
41
|
-
}
|
42
|
-
}
|
43
|
-
}
|
44
|
-
}
|
45
|
-
};
|
46
|
-
},
|
47
|
-
meta: {
|
48
|
-
docs: {
|
49
|
-
description: "Prevent duplicate usage of `<Head>` in `pages/_document.js`.",
|
50
|
-
recommended: true,
|
51
|
-
url
|
52
|
-
},
|
53
|
-
schema: [],
|
54
|
-
type: "problem"
|
55
|
-
}
|
56
|
-
});
|
57
|
-
export {
|
58
|
-
noDuplicateHead
|
59
|
-
};
|
60
|
-
//# sourceMappingURL=no-duplicate-head.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"sources":["../../src/utils/define-rule.ts","../../src/rules/no-duplicate-head.ts"],"sourcesContent":["import type { Rule } from \"eslint\";\n\nexport const defineRule = (rule: Rule.RuleModule): Rule.RuleModule => rule;\n","import { defineRule } from \"../utils/define-rule.js\";\nconst url = \"https://nextjs.org/docs/messages/no-duplicate-head\";\n\nexport const noDuplicateHead = defineRule({\n create: (context) => {\n const { sourceCode } = context;\n let documentImportName: null | string = null;\n return {\n ImportDeclaration: (node) => {\n if (node.source.value === \"next/document\") {\n const documentImport = node.specifiers.find(\n ({ type }) => type === \"ImportDefaultSpecifier\",\n );\n if (documentImport?.local) {\n documentImportName = documentImport.local.name;\n }\n }\n },\n ReturnStatement: (node) => {\n const ancestors = sourceCode.getAncestors(node);\n const documentClass = ancestors.find(\n (ancestorNode) =>\n ancestorNode.type === \"ClassDeclaration\" &&\n ancestorNode.superClass &&\n \"name\" in ancestorNode.superClass &&\n ancestorNode.superClass.name === documentImportName,\n );\n\n if (!documentClass) {\n return;\n }\n\n if (\n node.argument &&\n \"children\" in node.argument &&\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n node.argument.children\n ) {\n const headComponents = node.argument.children.filter(\n (childrenNode: any) =>\n childrenNode.openingElement?.name &&\n childrenNode.openingElement.name.name === \"Head\",\n );\n\n if (headComponents.length > 1) {\n for (let i = 1; i < headComponents.length; i++) {\n context.report({\n message: `Do not include multiple instances of \\`<Head/>\\`. See: ${url}`,\n // @ts-expect-error initial override, TODO: fix\n node: headComponents[i],\n });\n }\n }\n }\n },\n };\n },\n meta: {\n docs: {\n description:\n \"Prevent duplicate usage of `<Head>` in `pages/_document.js`.\",\n recommended: true,\n url,\n },\n schema: [],\n type: \"problem\",\n },\n});\n"],"mappings":";AAEO,IAAM,aAAa,CAAC,SAA2C;;;ACDtE,IAAM,MAAM;AAEL,IAAM,kBAAkB,WAAW;AAAA,EACxC,QAAQ,CAAC,YAAY;AACnB,UAAM,EAAE,WAAW,IAAI;AACvB,QAAI,qBAAoC;AACxC,WAAO;AAAA,MACL,mBAAmB,CAAC,SAAS;AAC3B,YAAI,KAAK,OAAO,UAAU,iBAAiB;AACzC,gBAAM,iBAAiB,KAAK,WAAW;AAAA,YACrC,CAAC,EAAE,KAAK,MAAM,SAAS;AAAA,UACzB;AACA,cAAI,gBAAgB,OAAO;AACzB,iCAAqB,eAAe,MAAM;AAAA,UAC5C;AAAA,QACF;AAAA,MACF;AAAA,MACA,iBAAiB,CAAC,SAAS;AACzB,cAAM,YAAY,WAAW,aAAa,IAAI;AAC9C,cAAM,gBAAgB,UAAU;AAAA,UAC9B,CAAC,iBACC,aAAa,SAAS,sBACtB,aAAa,cACb,UAAU,aAAa,cACvB,aAAa,WAAW,SAAS;AAAA,QACrC;AAEA,YAAI,CAAC,eAAe;AAClB;AAAA,QACF;AAEA,YACE,KAAK,YACL,cAAc,KAAK;AAAA,QAEnB,KAAK,SAAS,UACd;AACA,gBAAM,iBAAiB,KAAK,SAAS,SAAS;AAAA,YAC5C,CAAC,iBACC,aAAa,gBAAgB,QAC7B,aAAa,eAAe,KAAK,SAAS;AAAA,UAC9C;AAEA,cAAI,eAAe,SAAS,GAAG;AAC7B,qBAAS,IAAI,GAAG,IAAI,eAAe,QAAQ,KAAK;AAC9C,sBAAQ,OAAO;AAAA,gBACb,SAAS,0DAA0D,GAAG;AAAA;AAAA,gBAEtE,MAAM,eAAe,CAAC;AAAA,cACxB,CAAC;AAAA,YACH;AAAA,UACF;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAAA,EACA,MAAM;AAAA,IACJ,MAAM;AAAA,MACJ,aACE;AAAA,MACF,aAAa;AAAA,MACb;AAAA,IACF;AAAA,IACA,QAAQ,CAAC;AAAA,IACT,MAAM;AAAA,EACR;AACF,CAAC;","names":[]}
|
@@ -1,76 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
var __create = Object.create;
|
3
|
-
var __defProp = Object.defineProperty;
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
8
|
-
var __export = (target, all) => {
|
9
|
-
for (var name in all)
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
11
|
-
};
|
12
|
-
var __copyProps = (to, from, except, desc) => {
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
14
|
-
for (let key of __getOwnPropNames(from))
|
15
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
17
|
-
}
|
18
|
-
return to;
|
19
|
-
};
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
26
|
-
mod
|
27
|
-
));
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
29
|
-
|
30
|
-
// src/rules/no-head-element.ts
|
31
|
-
var no_head_element_exports = {};
|
32
|
-
__export(no_head_element_exports, {
|
33
|
-
noHeadElement: () => noHeadElement
|
34
|
-
});
|
35
|
-
module.exports = __toCommonJS(no_head_element_exports);
|
36
|
-
var import_node_path = __toESM(require("path"), 1);
|
37
|
-
|
38
|
-
// src/utils/define-rule.ts
|
39
|
-
var defineRule = (rule) => rule;
|
40
|
-
|
41
|
-
// src/rules/no-head-element.ts
|
42
|
-
var url = "https://nextjs.org/docs/messages/no-head-element";
|
43
|
-
var noHeadElement = defineRule({
|
44
|
-
create: (context) => ({
|
45
|
-
JSXOpeningElement: (node) => {
|
46
|
-
const paths = context.filename;
|
47
|
-
const isInAppDir = () => (
|
48
|
-
// TODO: fix
|
49
|
-
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
|
50
|
-
paths.includes(`app${import_node_path.default.sep}`) || paths.includes(`app${import_node_path.default.posix.sep}`)
|
51
|
-
);
|
52
|
-
if (node.name.name !== "head" || isInAppDir()) {
|
53
|
-
return;
|
54
|
-
}
|
55
|
-
context.report({
|
56
|
-
message: `Do not use \`<head>\` element. Use \`<Head />\` from \`next/head\` instead. See: ${url}`,
|
57
|
-
node
|
58
|
-
});
|
59
|
-
}
|
60
|
-
}),
|
61
|
-
meta: {
|
62
|
-
docs: {
|
63
|
-
category: "HTML",
|
64
|
-
description: "Prevent usage of `<head>` element.",
|
65
|
-
recommended: true,
|
66
|
-
url
|
67
|
-
},
|
68
|
-
schema: [],
|
69
|
-
type: "problem"
|
70
|
-
}
|
71
|
-
});
|
72
|
-
// Annotate the CommonJS export names for ESM import in node:
|
73
|
-
0 && (module.exports = {
|
74
|
-
noHeadElement
|
75
|
-
});
|
76
|
-
//# sourceMappingURL=no-head-element.cjs.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"sources":["../../src/rules/no-head-element.ts","../../src/utils/define-rule.ts"],"sourcesContent":["import path from \"node:path\";\n\nimport { defineRule } from \"../utils/define-rule.js\";\n\nconst url = \"https://nextjs.org/docs/messages/no-head-element\";\n\nexport const noHeadElement = defineRule({\n create: (context: any) => ({\n JSXOpeningElement: (node: any) => {\n const paths = context.filename;\n\n const isInAppDir = () =>\n // TODO: fix\n // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing\n paths.includes(`app${path.sep}`) ||\n paths.includes(`app${path.posix.sep}`);\n // Only lint the <head> element in pages directory\n if (node.name.name !== \"head\" || isInAppDir()) {\n return;\n }\n\n context.report({\n message: `Do not use \\`<head>\\` element. Use \\`<Head />\\` from \\`next/head\\` instead. See: ${url}`,\n node,\n });\n },\n }),\n meta: {\n docs: {\n category: \"HTML\",\n description: \"Prevent usage of `<head>` element.\",\n recommended: true,\n url,\n },\n schema: [],\n type: \"problem\",\n },\n});\n","import type { Rule } from \"eslint\";\n\nexport const defineRule = (rule: Rule.RuleModule): Rule.RuleModule => rule;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,uBAAiB;;;ACEV,IAAM,aAAa,CAAC,SAA2C;;;ADEtE,IAAM,MAAM;AAEL,IAAM,gBAAgB,WAAW;AAAA,EACtC,QAAQ,CAAC,aAAkB;AAAA,IACzB,mBAAmB,CAAC,SAAc;AAChC,YAAM,QAAQ,QAAQ;AAEtB,YAAM,aAAa;AAAA;AAAA;AAAA,QAGjB,MAAM,SAAS,MAAM,iBAAAA,QAAK,GAAG,EAAE,KAC/B,MAAM,SAAS,MAAM,iBAAAA,QAAK,MAAM,GAAG,EAAE;AAAA;AAEvC,UAAI,KAAK,KAAK,SAAS,UAAU,WAAW,GAAG;AAC7C;AAAA,MACF;AAEA,cAAQ,OAAO;AAAA,QACb,SAAS,oFAAoF,GAAG;AAAA,QAChG;AAAA,MACF,CAAC;AAAA,IACH;AAAA,EACF;AAAA,EACA,MAAM;AAAA,IACJ,MAAM;AAAA,MACJ,UAAU;AAAA,MACV,aAAa;AAAA,MACb,aAAa;AAAA,MACb;AAAA,IACF;AAAA,IACA,QAAQ,CAAC;AAAA,IACT,MAAM;AAAA,EACR;AACF,CAAC;","names":["path"]}
|
@@ -1,41 +0,0 @@
|
|
1
|
-
// src/rules/no-head-element.ts
|
2
|
-
import path from "node:path";
|
3
|
-
|
4
|
-
// src/utils/define-rule.ts
|
5
|
-
var defineRule = (rule) => rule;
|
6
|
-
|
7
|
-
// src/rules/no-head-element.ts
|
8
|
-
var url = "https://nextjs.org/docs/messages/no-head-element";
|
9
|
-
var noHeadElement = defineRule({
|
10
|
-
create: (context) => ({
|
11
|
-
JSXOpeningElement: (node) => {
|
12
|
-
const paths = context.filename;
|
13
|
-
const isInAppDir = () => (
|
14
|
-
// TODO: fix
|
15
|
-
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
|
16
|
-
paths.includes(`app${path.sep}`) || paths.includes(`app${path.posix.sep}`)
|
17
|
-
);
|
18
|
-
if (node.name.name !== "head" || isInAppDir()) {
|
19
|
-
return;
|
20
|
-
}
|
21
|
-
context.report({
|
22
|
-
message: `Do not use \`<head>\` element. Use \`<Head />\` from \`next/head\` instead. See: ${url}`,
|
23
|
-
node
|
24
|
-
});
|
25
|
-
}
|
26
|
-
}),
|
27
|
-
meta: {
|
28
|
-
docs: {
|
29
|
-
category: "HTML",
|
30
|
-
description: "Prevent usage of `<head>` element.",
|
31
|
-
recommended: true,
|
32
|
-
url
|
33
|
-
},
|
34
|
-
schema: [],
|
35
|
-
type: "problem"
|
36
|
-
}
|
37
|
-
});
|
38
|
-
export {
|
39
|
-
noHeadElement
|
40
|
-
};
|
41
|
-
//# sourceMappingURL=no-head-element.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"sources":["../../src/rules/no-head-element.ts","../../src/utils/define-rule.ts"],"sourcesContent":["import path from \"node:path\";\n\nimport { defineRule } from \"../utils/define-rule.js\";\n\nconst url = \"https://nextjs.org/docs/messages/no-head-element\";\n\nexport const noHeadElement = defineRule({\n create: (context: any) => ({\n JSXOpeningElement: (node: any) => {\n const paths = context.filename;\n\n const isInAppDir = () =>\n // TODO: fix\n // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing\n paths.includes(`app${path.sep}`) ||\n paths.includes(`app${path.posix.sep}`);\n // Only lint the <head> element in pages directory\n if (node.name.name !== \"head\" || isInAppDir()) {\n return;\n }\n\n context.report({\n message: `Do not use \\`<head>\\` element. Use \\`<Head />\\` from \\`next/head\\` instead. See: ${url}`,\n node,\n });\n },\n }),\n meta: {\n docs: {\n category: \"HTML\",\n description: \"Prevent usage of `<head>` element.\",\n recommended: true,\n url,\n },\n schema: [],\n type: \"problem\",\n },\n});\n","import type { Rule } from \"eslint\";\n\nexport const defineRule = (rule: Rule.RuleModule): Rule.RuleModule => rule;\n"],"mappings":";AAAA,OAAO,UAAU;;;ACEV,IAAM,aAAa,CAAC,SAA2C;;;ADEtE,IAAM,MAAM;AAEL,IAAM,gBAAgB,WAAW;AAAA,EACtC,QAAQ,CAAC,aAAkB;AAAA,IACzB,mBAAmB,CAAC,SAAc;AAChC,YAAM,QAAQ,QAAQ;AAEtB,YAAM,aAAa;AAAA;AAAA;AAAA,QAGjB,MAAM,SAAS,MAAM,KAAK,GAAG,EAAE,KAC/B,MAAM,SAAS,MAAM,KAAK,MAAM,GAAG,EAAE;AAAA;AAEvC,UAAI,KAAK,KAAK,SAAS,UAAU,WAAW,GAAG;AAC7C;AAAA,MACF;AAEA,cAAQ,OAAO;AAAA,QACb,SAAS,oFAAoF,GAAG;AAAA,QAChG;AAAA,MACF,CAAC;AAAA,IACH;AAAA,EACF;AAAA,EACA,MAAM;AAAA,IACJ,MAAM;AAAA,MACJ,UAAU;AAAA,MACV,aAAa;AAAA,MACb,aAAa;AAAA,MACb;AAAA,IACF;AAAA,IACA,QAAQ,CAAC;AAAA,IACT,MAAM;AAAA,EACR;AACF,CAAC;","names":[]}
|
@@ -1,76 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
var __create = Object.create;
|
3
|
-
var __defProp = Object.defineProperty;
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
8
|
-
var __export = (target, all) => {
|
9
|
-
for (var name in all)
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
11
|
-
};
|
12
|
-
var __copyProps = (to, from, except, desc) => {
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
14
|
-
for (let key of __getOwnPropNames(from))
|
15
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
17
|
-
}
|
18
|
-
return to;
|
19
|
-
};
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
26
|
-
mod
|
27
|
-
));
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
29
|
-
|
30
|
-
// src/rules/no-head-import-in-document.ts
|
31
|
-
var no_head_import_in_document_exports = {};
|
32
|
-
__export(no_head_import_in_document_exports, {
|
33
|
-
noHeadImportInDocument: () => noHeadImportInDocument
|
34
|
-
});
|
35
|
-
module.exports = __toCommonJS(no_head_import_in_document_exports);
|
36
|
-
var path = __toESM(require("path"), 1);
|
37
|
-
|
38
|
-
// src/utils/define-rule.ts
|
39
|
-
var defineRule = (rule) => rule;
|
40
|
-
|
41
|
-
// src/rules/no-head-import-in-document.ts
|
42
|
-
var url = "https://nextjs.org/docs/messages/no-head-import-in-document";
|
43
|
-
var noHeadImportInDocument = defineRule({
|
44
|
-
create: (context) => ({
|
45
|
-
ImportDeclaration: (node) => {
|
46
|
-
if (node.source.value !== "next/head") {
|
47
|
-
return;
|
48
|
-
}
|
49
|
-
const document = context.filename.split("pages", 2)[1];
|
50
|
-
if (!document) {
|
51
|
-
return;
|
52
|
-
}
|
53
|
-
const { dir, name } = path.parse(document);
|
54
|
-
if (name.startsWith("_document") || dir === "/_document" && name === "index") {
|
55
|
-
context.report({
|
56
|
-
message: `\`next/head\` should not be imported in \`pages${document}\`. Use \`<Head />\` from \`next/document\` instead. See: ${url}`,
|
57
|
-
node
|
58
|
-
});
|
59
|
-
}
|
60
|
-
}
|
61
|
-
}),
|
62
|
-
meta: {
|
63
|
-
docs: {
|
64
|
-
description: "Prevent usage of `next/head` in `pages/_document.js`.",
|
65
|
-
recommended: true,
|
66
|
-
url
|
67
|
-
},
|
68
|
-
schema: [],
|
69
|
-
type: "problem"
|
70
|
-
}
|
71
|
-
});
|
72
|
-
// Annotate the CommonJS export names for ESM import in node:
|
73
|
-
0 && (module.exports = {
|
74
|
-
noHeadImportInDocument
|
75
|
-
});
|
76
|
-
//# sourceMappingURL=no-head-import-in-document.cjs.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"sources":["../../src/rules/no-head-import-in-document.ts","../../src/utils/define-rule.ts"],"sourcesContent":["import * as path from \"node:path\";\n\nimport { defineRule } from \"../utils/define-rule.js\";\n\nconst url = \"https://nextjs.org/docs/messages/no-head-import-in-document\";\n\nexport const noHeadImportInDocument = defineRule({\n create: (context: any) => ({\n ImportDeclaration: (node: any) => {\n if (node.source.value !== \"next/head\") {\n return;\n }\n\n const document = context.filename.split(\"pages\", 2)[1];\n if (!document) {\n return;\n }\n\n const { dir, name } = path.parse(document);\n\n if (\n name.startsWith(\"_document\") ||\n (dir === \"/_document\" && name === \"index\")\n ) {\n context.report({\n message: `\\`next/head\\` should not be imported in \\`pages${document}\\`. Use \\`<Head />\\` from \\`next/document\\` instead. See: ${url}`,\n node,\n });\n }\n },\n }),\n meta: {\n docs: {\n description: \"Prevent usage of `next/head` in `pages/_document.js`.\",\n recommended: true,\n url,\n },\n schema: [],\n type: \"problem\",\n },\n});\n","import type { Rule } from \"eslint\";\n\nexport const defineRule = (rule: Rule.RuleModule): Rule.RuleModule => rule;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,WAAsB;;;ACEf,IAAM,aAAa,CAAC,SAA2C;;;ADEtE,IAAM,MAAM;AAEL,IAAM,yBAAyB,WAAW;AAAA,EAC/C,QAAQ,CAAC,aAAkB;AAAA,IACzB,mBAAmB,CAAC,SAAc;AAChC,UAAI,KAAK,OAAO,UAAU,aAAa;AACrC;AAAA,MACF;AAEA,YAAM,WAAW,QAAQ,SAAS,MAAM,SAAS,CAAC,EAAE,CAAC;AACrD,UAAI,CAAC,UAAU;AACb;AAAA,MACF;AAEA,YAAM,EAAE,KAAK,KAAK,IAAS,WAAM,QAAQ;AAEzC,UACE,KAAK,WAAW,WAAW,KAC1B,QAAQ,gBAAgB,SAAS,SAClC;AACA,gBAAQ,OAAO;AAAA,UACb,SAAS,kDAAkD,QAAQ,6DAA6D,GAAG;AAAA,UACnI;AAAA,QACF,CAAC;AAAA,MACH;AAAA,IACF;AAAA,EACF;AAAA,EACA,MAAM;AAAA,IACJ,MAAM;AAAA,MACJ,aAAa;AAAA,MACb,aAAa;AAAA,MACb;AAAA,IACF;AAAA,IACA,QAAQ,CAAC;AAAA,IACT,MAAM;AAAA,EACR;AACF,CAAC;","names":[]}
|
@@ -1,41 +0,0 @@
|
|
1
|
-
// src/rules/no-head-import-in-document.ts
|
2
|
-
import * as path from "node:path";
|
3
|
-
|
4
|
-
// src/utils/define-rule.ts
|
5
|
-
var defineRule = (rule) => rule;
|
6
|
-
|
7
|
-
// src/rules/no-head-import-in-document.ts
|
8
|
-
var url = "https://nextjs.org/docs/messages/no-head-import-in-document";
|
9
|
-
var noHeadImportInDocument = defineRule({
|
10
|
-
create: (context) => ({
|
11
|
-
ImportDeclaration: (node) => {
|
12
|
-
if (node.source.value !== "next/head") {
|
13
|
-
return;
|
14
|
-
}
|
15
|
-
const document = context.filename.split("pages", 2)[1];
|
16
|
-
if (!document) {
|
17
|
-
return;
|
18
|
-
}
|
19
|
-
const { dir, name } = path.parse(document);
|
20
|
-
if (name.startsWith("_document") || dir === "/_document" && name === "index") {
|
21
|
-
context.report({
|
22
|
-
message: `\`next/head\` should not be imported in \`pages${document}\`. Use \`<Head />\` from \`next/document\` instead. See: ${url}`,
|
23
|
-
node
|
24
|
-
});
|
25
|
-
}
|
26
|
-
}
|
27
|
-
}),
|
28
|
-
meta: {
|
29
|
-
docs: {
|
30
|
-
description: "Prevent usage of `next/head` in `pages/_document.js`.",
|
31
|
-
recommended: true,
|
32
|
-
url
|
33
|
-
},
|
34
|
-
schema: [],
|
35
|
-
type: "problem"
|
36
|
-
}
|
37
|
-
});
|
38
|
-
export {
|
39
|
-
noHeadImportInDocument
|
40
|
-
};
|
41
|
-
//# sourceMappingURL=no-head-import-in-document.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"sources":["../../src/rules/no-head-import-in-document.ts","../../src/utils/define-rule.ts"],"sourcesContent":["import * as path from \"node:path\";\n\nimport { defineRule } from \"../utils/define-rule.js\";\n\nconst url = \"https://nextjs.org/docs/messages/no-head-import-in-document\";\n\nexport const noHeadImportInDocument = defineRule({\n create: (context: any) => ({\n ImportDeclaration: (node: any) => {\n if (node.source.value !== \"next/head\") {\n return;\n }\n\n const document = context.filename.split(\"pages\", 2)[1];\n if (!document) {\n return;\n }\n\n const { dir, name } = path.parse(document);\n\n if (\n name.startsWith(\"_document\") ||\n (dir === \"/_document\" && name === \"index\")\n ) {\n context.report({\n message: `\\`next/head\\` should not be imported in \\`pages${document}\\`. Use \\`<Head />\\` from \\`next/document\\` instead. See: ${url}`,\n node,\n });\n }\n },\n }),\n meta: {\n docs: {\n description: \"Prevent usage of `next/head` in `pages/_document.js`.\",\n recommended: true,\n url,\n },\n schema: [],\n type: \"problem\",\n },\n});\n","import type { Rule } from \"eslint\";\n\nexport const defineRule = (rule: Rule.RuleModule): Rule.RuleModule => rule;\n"],"mappings":";AAAA,YAAY,UAAU;;;ACEf,IAAM,aAAa,CAAC,SAA2C;;;ADEtE,IAAM,MAAM;AAEL,IAAM,yBAAyB,WAAW;AAAA,EAC/C,QAAQ,CAAC,aAAkB;AAAA,IACzB,mBAAmB,CAAC,SAAc;AAChC,UAAI,KAAK,OAAO,UAAU,aAAa;AACrC;AAAA,MACF;AAEA,YAAM,WAAW,QAAQ,SAAS,MAAM,SAAS,CAAC,EAAE,CAAC;AACrD,UAAI,CAAC,UAAU;AACb;AAAA,MACF;AAEA,YAAM,EAAE,KAAK,KAAK,IAAS,WAAM,QAAQ;AAEzC,UACE,KAAK,WAAW,WAAW,KAC1B,QAAQ,gBAAgB,SAAS,SAClC;AACA,gBAAQ,OAAO;AAAA,UACb,SAAS,kDAAkD,QAAQ,6DAA6D,GAAG;AAAA,UACnI;AAAA,QACF,CAAC;AAAA,MACH;AAAA,IACF;AAAA,EACF;AAAA,EACA,MAAM;AAAA,IACJ,MAAM;AAAA,MACJ,aAAa;AAAA,MACb,aAAa;AAAA,MACb;AAAA,IACF;AAAA,IACA,QAAQ,CAAC;AAAA,IACT,MAAM;AAAA,EACR;AACF,CAAC;","names":[]}
|