eslint-plugin-nextjs 0.0.1 → 0.1.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.
Files changed (158) hide show
  1. package/README.md +58 -5
  2. package/dist/index.cjs +1494 -0
  3. package/dist/index.cjs.map +1 -0
  4. package/dist/index.d.cts +43 -0
  5. package/dist/index.d.ts +42 -1
  6. package/dist/index.js +1455 -1
  7. package/dist/index.js.map +1 -1
  8. package/dist/rules/google-font-display.cjs +119 -0
  9. package/dist/rules/google-font-display.cjs.map +1 -0
  10. package/dist/rules/google-font-display.d.cts +8 -0
  11. package/dist/rules/google-font-display.d.ts +8 -0
  12. package/dist/rules/google-font-display.js +92 -0
  13. package/dist/rules/google-font-display.js.map +1 -0
  14. package/dist/rules/google-font-preconnect.cjs +109 -0
  15. package/dist/rules/google-font-preconnect.cjs.map +1 -0
  16. package/dist/rules/google-font-preconnect.d.cts +5 -0
  17. package/dist/rules/google-font-preconnect.d.ts +5 -0
  18. package/dist/rules/google-font-preconnect.js +82 -0
  19. package/dist/rules/google-font-preconnect.js.map +1 -0
  20. package/dist/rules/inline-script-id.cjs +94 -0
  21. package/dist/rules/inline-script-id.cjs.map +1 -0
  22. package/dist/rules/inline-script-id.d.cts +5 -0
  23. package/dist/rules/inline-script-id.d.ts +5 -0
  24. package/dist/rules/inline-script-id.js +67 -0
  25. package/dist/rules/inline-script-id.js.map +1 -0
  26. package/dist/rules/next-script-for-ga.cjs +129 -0
  27. package/dist/rules/next-script-for-ga.cjs.map +1 -0
  28. package/dist/rules/next-script-for-ga.d.cts +5 -0
  29. package/dist/rules/next-script-for-ga.d.ts +5 -0
  30. package/dist/rules/next-script-for-ga.js +102 -0
  31. package/dist/rules/next-script-for-ga.js.map +1 -0
  32. package/dist/rules/no-assign-module-variable.cjs +64 -0
  33. package/dist/rules/no-assign-module-variable.cjs.map +1 -0
  34. package/dist/rules/no-assign-module-variable.d.cts +5 -0
  35. package/dist/rules/no-assign-module-variable.d.ts +5 -0
  36. package/dist/rules/no-assign-module-variable.js +37 -0
  37. package/dist/rules/no-assign-module-variable.js.map +1 -0
  38. package/dist/rules/no-async-client-component.cjs +99 -0
  39. package/dist/rules/no-async-client-component.cjs.map +1 -0
  40. package/dist/rules/no-async-client-component.d.cts +5 -0
  41. package/dist/rules/no-async-client-component.d.ts +5 -0
  42. package/dist/rules/no-async-client-component.js +72 -0
  43. package/dist/rules/no-async-client-component.js.map +1 -0
  44. package/dist/rules/no-before-interactive-script-outside-document.cjs +94 -0
  45. package/dist/rules/no-before-interactive-script-outside-document.cjs.map +1 -0
  46. package/dist/rules/no-before-interactive-script-outside-document.d.cts +5 -0
  47. package/dist/rules/no-before-interactive-script-outside-document.d.ts +5 -0
  48. package/dist/rules/no-before-interactive-script-outside-document.js +59 -0
  49. package/dist/rules/no-before-interactive-script-outside-document.js.map +1 -0
  50. package/dist/rules/no-css-tags.cjs +70 -0
  51. package/dist/rules/no-css-tags.cjs.map +1 -0
  52. package/dist/rules/no-css-tags.d.cts +5 -0
  53. package/dist/rules/no-css-tags.d.ts +5 -0
  54. package/dist/rules/no-css-tags.js +43 -0
  55. package/dist/rules/no-css-tags.js.map +1 -0
  56. package/dist/rules/no-document-import-in-page.cjs +74 -0
  57. package/dist/rules/no-document-import-in-page.cjs.map +1 -0
  58. package/dist/rules/no-document-import-in-page.d.cts +5 -0
  59. package/dist/rules/no-document-import-in-page.d.ts +5 -0
  60. package/dist/rules/no-document-import-in-page.js +39 -0
  61. package/dist/rules/no-document-import-in-page.js.map +1 -0
  62. package/dist/rules/no-duplicate-head.cjs +87 -0
  63. package/dist/rules/no-duplicate-head.cjs.map +1 -0
  64. package/dist/rules/no-duplicate-head.d.cts +5 -0
  65. package/dist/rules/no-duplicate-head.d.ts +5 -0
  66. package/dist/rules/no-duplicate-head.js +60 -0
  67. package/dist/rules/no-duplicate-head.js.map +1 -0
  68. package/dist/rules/no-head-element.cjs +76 -0
  69. package/dist/rules/no-head-element.cjs.map +1 -0
  70. package/dist/rules/no-head-element.d.cts +5 -0
  71. package/dist/rules/no-head-element.d.ts +5 -0
  72. package/dist/rules/no-head-element.js +41 -0
  73. package/dist/rules/no-head-element.js.map +1 -0
  74. package/dist/rules/no-head-import-in-document.cjs +76 -0
  75. package/dist/rules/no-head-import-in-document.cjs.map +1 -0
  76. package/dist/rules/no-head-import-in-document.d.cts +5 -0
  77. package/dist/rules/no-head-import-in-document.d.ts +5 -0
  78. package/dist/rules/no-head-import-in-document.js +41 -0
  79. package/dist/rules/no-head-import-in-document.js.map +1 -0
  80. package/dist/rules/no-html-link-for-pages.cjs +302 -0
  81. package/dist/rules/no-html-link-for-pages.cjs.map +1 -0
  82. package/dist/rules/no-html-link-for-pages.d.cts +5 -0
  83. package/dist/rules/no-html-link-for-pages.d.ts +5 -0
  84. package/dist/rules/no-html-link-for-pages.js +267 -0
  85. package/dist/rules/no-html-link-for-pages.js.map +1 -0
  86. package/dist/rules/no-img-element.cjs +83 -0
  87. package/dist/rules/no-img-element.cjs.map +1 -0
  88. package/dist/rules/no-img-element.d.cts +5 -0
  89. package/dist/rules/no-img-element.d.ts +5 -0
  90. package/dist/rules/no-img-element.js +48 -0
  91. package/dist/rules/no-img-element.js.map +1 -0
  92. package/dist/rules/no-page-custom-font.cjs +184 -0
  93. package/dist/rules/no-page-custom-font.cjs.map +1 -0
  94. package/dist/rules/no-page-custom-font.d.cts +5 -0
  95. package/dist/rules/no-page-custom-font.d.ts +5 -0
  96. package/dist/rules/no-page-custom-font.js +159 -0
  97. package/dist/rules/no-page-custom-font.js.map +1 -0
  98. package/dist/rules/no-script-component-in-head.cjs +74 -0
  99. package/dist/rules/no-script-component-in-head.cjs.map +1 -0
  100. package/dist/rules/no-script-component-in-head.d.cts +5 -0
  101. package/dist/rules/no-script-component-in-head.d.ts +5 -0
  102. package/dist/rules/no-script-component-in-head.js +47 -0
  103. package/dist/rules/no-script-component-in-head.js.map +1 -0
  104. package/dist/rules/no-styled-jsx-in-document.cjs +78 -0
  105. package/dist/rules/no-styled-jsx-in-document.cjs.map +1 -0
  106. package/dist/rules/no-styled-jsx-in-document.d.cts +5 -0
  107. package/dist/rules/no-styled-jsx-in-document.d.ts +5 -0
  108. package/dist/rules/no-styled-jsx-in-document.js +43 -0
  109. package/dist/rules/no-styled-jsx-in-document.js.map +1 -0
  110. package/dist/rules/no-sync-scripts.cjs +64 -0
  111. package/dist/rules/no-sync-scripts.cjs.map +1 -0
  112. package/dist/rules/no-sync-scripts.d.cts +5 -0
  113. package/dist/rules/no-sync-scripts.d.ts +5 -0
  114. package/dist/rules/no-sync-scripts.js +37 -0
  115. package/dist/rules/no-sync-scripts.js.map +1 -0
  116. package/dist/rules/no-title-in-document-head.cjs +78 -0
  117. package/dist/rules/no-title-in-document-head.cjs.map +1 -0
  118. package/dist/rules/no-title-in-document-head.d.cts +5 -0
  119. package/dist/rules/no-title-in-document-head.d.ts +5 -0
  120. package/dist/rules/no-title-in-document-head.js +51 -0
  121. package/dist/rules/no-title-in-document-head.js.map +1 -0
  122. package/dist/rules/no-typos.cjs +133 -0
  123. package/dist/rules/no-typos.cjs.map +1 -0
  124. package/dist/rules/no-typos.d.cts +5 -0
  125. package/dist/rules/no-typos.d.ts +5 -0
  126. package/dist/rules/no-typos.js +98 -0
  127. package/dist/rules/no-typos.js.map +1 -0
  128. package/dist/rules/no-unwanted-polyfillio.cjs +164 -0
  129. package/dist/rules/no-unwanted-polyfillio.cjs.map +1 -0
  130. package/dist/rules/no-unwanted-polyfillio.d.cts +5 -0
  131. package/dist/rules/no-unwanted-polyfillio.d.ts +5 -0
  132. package/dist/rules/no-unwanted-polyfillio.js +137 -0
  133. package/dist/rules/no-unwanted-polyfillio.js.map +1 -0
  134. package/dist/utils/define-rule.cjs +31 -0
  135. package/dist/utils/define-rule.cjs.map +1 -0
  136. package/dist/utils/define-rule.d.cts +5 -0
  137. package/dist/utils/define-rule.d.ts +5 -0
  138. package/dist/utils/define-rule.js +6 -0
  139. package/dist/utils/define-rule.js.map +1 -0
  140. package/dist/utils/get-root-dirs.cjs +60 -0
  141. package/dist/utils/get-root-dirs.cjs.map +1 -0
  142. package/dist/utils/get-root-dirs.d.cts +8 -0
  143. package/dist/utils/get-root-dirs.d.ts +8 -0
  144. package/dist/utils/get-root-dirs.js +25 -0
  145. package/dist/utils/get-root-dirs.js.map +1 -0
  146. package/dist/utils/node-attributes.cjs +67 -0
  147. package/dist/utils/node-attributes.cjs.map +1 -0
  148. package/dist/utils/node-attributes.d.cts +15 -0
  149. package/dist/utils/node-attributes.d.ts +15 -0
  150. package/dist/utils/node-attributes.js +46 -0
  151. package/dist/utils/node-attributes.js.map +1 -0
  152. package/dist/utils/url.cjs +167 -0
  153. package/dist/utils/url.cjs.map +1 -0
  154. package/dist/utils/url.d.cts +35 -0
  155. package/dist/utils/url.d.ts +35 -0
  156. package/dist/utils/url.js +128 -0
  157. package/dist/utils/url.js.map +1 -0
  158. package/package.json +15 -2
@@ -0,0 +1,74 @@
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
@@ -0,0 +1 @@
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":[]}
@@ -0,0 +1,5 @@
1
+ import * as eslint from 'eslint';
2
+
3
+ declare const noDocumentImportInPage: eslint.Rule.RuleModule;
4
+
5
+ export { noDocumentImportInPage };
@@ -0,0 +1,5 @@
1
+ import * as eslint from 'eslint';
2
+
3
+ declare const noDocumentImportInPage: eslint.Rule.RuleModule;
4
+
5
+ export { noDocumentImportInPage };
@@ -0,0 +1,39 @@
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
@@ -0,0 +1 @@
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":[]}
@@ -0,0 +1,87 @@
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
@@ -0,0 +1 @@
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":[]}
@@ -0,0 +1,5 @@
1
+ import * as eslint from 'eslint';
2
+
3
+ declare const noDuplicateHead: eslint.Rule.RuleModule;
4
+
5
+ export { noDuplicateHead };
@@ -0,0 +1,5 @@
1
+ import * as eslint from 'eslint';
2
+
3
+ declare const noDuplicateHead: eslint.Rule.RuleModule;
4
+
5
+ export { noDuplicateHead };
@@ -0,0 +1,60 @@
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
@@ -0,0 +1 @@
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":[]}
@@ -0,0 +1,76 @@
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
@@ -0,0 +1 @@
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"]}
@@ -0,0 +1,5 @@
1
+ import * as eslint from 'eslint';
2
+
3
+ declare const noHeadElement: eslint.Rule.RuleModule;
4
+
5
+ export { noHeadElement };
@@ -0,0 +1,5 @@
1
+ import * as eslint from 'eslint';
2
+
3
+ declare const noHeadElement: eslint.Rule.RuleModule;
4
+
5
+ export { noHeadElement };
@@ -0,0 +1,41 @@
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
@@ -0,0 +1 @@
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":[]}
@@ -0,0 +1,76 @@
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
@@ -0,0 +1 @@
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":[]}
@@ -0,0 +1,5 @@
1
+ import * as eslint from 'eslint';
2
+
3
+ declare const noHeadImportInDocument: eslint.Rule.RuleModule;
4
+
5
+ export { noHeadImportInDocument };
@@ -0,0 +1,5 @@
1
+ import * as eslint from 'eslint';
2
+
3
+ declare const noHeadImportInDocument: eslint.Rule.RuleModule;
4
+
5
+ export { noHeadImportInDocument };
@@ -0,0 +1,41 @@
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
@@ -0,0 +1 @@
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":[]}