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,5 @@
1
+ import * as eslint from 'eslint';
2
+
3
+ declare const noScriptComponentInHead: eslint.Rule.RuleModule;
4
+
5
+ export { noScriptComponentInHead };
@@ -0,0 +1,5 @@
1
+ import * as eslint from 'eslint';
2
+
3
+ declare const noScriptComponentInHead: eslint.Rule.RuleModule;
4
+
5
+ export { noScriptComponentInHead };
@@ -0,0 +1,47 @@
1
+ // src/utils/define-rule.ts
2
+ var defineRule = (rule) => rule;
3
+
4
+ // src/rules/no-script-component-in-head.ts
5
+ var url = "https://nextjs.org/docs/messages/no-script-component-in-head";
6
+ var noScriptComponentInHead = defineRule({
7
+ create: (context) => {
8
+ let isNextHead = null;
9
+ return {
10
+ ImportDeclaration: (node) => {
11
+ if (node.source.value === "next/head") {
12
+ isNextHead = node.source.value;
13
+ }
14
+ },
15
+ JSXElement: (node) => {
16
+ if (!isNextHead) {
17
+ return;
18
+ }
19
+ if (node.openingElement?.name && node.openingElement.name.name !== "Head") {
20
+ return;
21
+ }
22
+ const scriptTag = node.children.find(
23
+ (child) => child.openingElement?.name && child.openingElement.name.name === "Script"
24
+ );
25
+ if (scriptTag) {
26
+ context.report({
27
+ message: `\`next/script\` should not be used in \`next/head\` component. Move \`<Script />\` outside of \`<Head>\` instead. See: ${url}`,
28
+ node
29
+ });
30
+ }
31
+ }
32
+ };
33
+ },
34
+ meta: {
35
+ docs: {
36
+ description: "Prevent usage of `next/script` in `next/head` component.",
37
+ recommended: true,
38
+ url
39
+ },
40
+ schema: [],
41
+ type: "problem"
42
+ }
43
+ });
44
+ export {
45
+ noScriptComponentInHead
46
+ };
47
+ //# sourceMappingURL=no-script-component-in-head.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/utils/define-rule.ts","../../src/rules/no-script-component-in-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-script-component-in-head\";\n\nexport const noScriptComponentInHead = defineRule({\n create: (context: any) => {\n let isNextHead: null | string = null;\n\n return {\n ImportDeclaration: (node: any) => {\n if (node.source.value === \"next/head\") {\n isNextHead = node.source.value;\n }\n },\n JSXElement: (node: any) => {\n if (!isNextHead) {\n return;\n }\n\n if (\n node.openingElement?.name &&\n node.openingElement.name.name !== \"Head\"\n ) {\n return;\n }\n\n const scriptTag = node.children.find(\n (child: any) =>\n child.openingElement?.name &&\n child.openingElement.name.name === \"Script\",\n );\n\n if (scriptTag) {\n context.report({\n message: `\\`next/script\\` should not be used in \\`next/head\\` component. Move \\`<Script />\\` outside of \\`<Head>\\` instead. See: ${url}`,\n node,\n });\n }\n },\n };\n },\n meta: {\n docs: {\n description: \"Prevent usage of `next/script` in `next/head` component.\",\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,0BAA0B,WAAW;AAAA,EAChD,QAAQ,CAAC,YAAiB;AACxB,QAAI,aAA4B;AAEhC,WAAO;AAAA,MACL,mBAAmB,CAAC,SAAc;AAChC,YAAI,KAAK,OAAO,UAAU,aAAa;AACrC,uBAAa,KAAK,OAAO;AAAA,QAC3B;AAAA,MACF;AAAA,MACA,YAAY,CAAC,SAAc;AACzB,YAAI,CAAC,YAAY;AACf;AAAA,QACF;AAEA,YACE,KAAK,gBAAgB,QACrB,KAAK,eAAe,KAAK,SAAS,QAClC;AACA;AAAA,QACF;AAEA,cAAM,YAAY,KAAK,SAAS;AAAA,UAC9B,CAAC,UACC,MAAM,gBAAgB,QACtB,MAAM,eAAe,KAAK,SAAS;AAAA,QACvC;AAEA,YAAI,WAAW;AACb,kBAAQ,OAAO;AAAA,YACb,SAAS,0HAA0H,GAAG;AAAA,YACtI;AAAA,UACF,CAAC;AAAA,QACH;AAAA,MACF;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,78 @@
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-styled-jsx-in-document.ts
31
+ var no_styled_jsx_in_document_exports = {};
32
+ __export(no_styled_jsx_in_document_exports, {
33
+ noStyledJsxInDocument: () => noStyledJsxInDocument
34
+ });
35
+ module.exports = __toCommonJS(no_styled_jsx_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-styled-jsx-in-document.ts
42
+ var url = "https://nextjs.org/docs/messages/no-styled-jsx-in-document";
43
+ var noStyledJsxInDocument = defineRule({
44
+ create: (context) => ({
45
+ JSXOpeningElement: (node) => {
46
+ const document = context.filename.split("pages", 2)[1];
47
+ if (!document) {
48
+ return;
49
+ }
50
+ const { dir, name } = path.parse(document);
51
+ if (!(name.startsWith("_document") || dir === "/_document" && name === "index")) {
52
+ return;
53
+ }
54
+ if (node.name.name === "style" && node.attributes.find(
55
+ (attr) => attr.type === "JSXAttribute" && attr.name.name === "jsx"
56
+ )) {
57
+ context.report({
58
+ message: `\`styled-jsx\` should not be used in \`pages/_document.js\`. See: ${url}`,
59
+ node
60
+ });
61
+ }
62
+ }
63
+ }),
64
+ meta: {
65
+ docs: {
66
+ description: "Prevent usage of `styled-jsx` in `pages/_document.js`.",
67
+ recommended: true,
68
+ url
69
+ },
70
+ schema: [],
71
+ type: "problem"
72
+ }
73
+ });
74
+ // Annotate the CommonJS export names for ESM import in node:
75
+ 0 && (module.exports = {
76
+ noStyledJsxInDocument
77
+ });
78
+ //# sourceMappingURL=no-styled-jsx-in-document.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/rules/no-styled-jsx-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-styled-jsx-in-document\";\n\nexport const noStyledJsxInDocument = defineRule({\n create: (context: any) => ({\n JSXOpeningElement: (node: any) => {\n const document = context.filename.split(\"pages\", 2)[1];\n if (!document) {\n return;\n }\n const { dir, name } = path.parse(document);\n\n if (\n !(\n name.startsWith(\"_document\") ||\n (dir === \"/_document\" && name === \"index\")\n )\n ) {\n return;\n }\n\n if (\n node.name.name === \"style\" &&\n node.attributes.find(\n (attr: any) =>\n attr.type === \"JSXAttribute\" && attr.name.name === \"jsx\",\n )\n ) {\n context.report({\n message: `\\`styled-jsx\\` should not be used in \\`pages/_document.js\\`. See: ${url}`,\n node,\n });\n }\n },\n }),\n meta: {\n docs: {\n description: \"Prevent usage of `styled-jsx` 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,wBAAwB,WAAW;AAAA,EAC9C,QAAQ,CAAC,aAAkB;AAAA,IACzB,mBAAmB,CAAC,SAAc;AAChC,YAAM,WAAW,QAAQ,SAAS,MAAM,SAAS,CAAC,EAAE,CAAC;AACrD,UAAI,CAAC,UAAU;AACb;AAAA,MACF;AACA,YAAM,EAAE,KAAK,KAAK,IAAS,WAAM,QAAQ;AAEzC,UACE,EACE,KAAK,WAAW,WAAW,KAC1B,QAAQ,gBAAgB,SAAS,UAEpC;AACA;AAAA,MACF;AAEA,UACE,KAAK,KAAK,SAAS,WACnB,KAAK,WAAW;AAAA,QACd,CAAC,SACC,KAAK,SAAS,kBAAkB,KAAK,KAAK,SAAS;AAAA,MACvD,GACA;AACA,gBAAQ,OAAO;AAAA,UACb,SAAS,qEAAqE,GAAG;AAAA,UACjF;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 noStyledJsxInDocument: eslint.Rule.RuleModule;
4
+
5
+ export { noStyledJsxInDocument };
@@ -0,0 +1,5 @@
1
+ import * as eslint from 'eslint';
2
+
3
+ declare const noStyledJsxInDocument: eslint.Rule.RuleModule;
4
+
5
+ export { noStyledJsxInDocument };
@@ -0,0 +1,43 @@
1
+ // src/rules/no-styled-jsx-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-styled-jsx-in-document.ts
8
+ var url = "https://nextjs.org/docs/messages/no-styled-jsx-in-document";
9
+ var noStyledJsxInDocument = defineRule({
10
+ create: (context) => ({
11
+ JSXOpeningElement: (node) => {
12
+ const document = context.filename.split("pages", 2)[1];
13
+ if (!document) {
14
+ return;
15
+ }
16
+ const { dir, name } = path.parse(document);
17
+ if (!(name.startsWith("_document") || dir === "/_document" && name === "index")) {
18
+ return;
19
+ }
20
+ if (node.name.name === "style" && node.attributes.find(
21
+ (attr) => attr.type === "JSXAttribute" && attr.name.name === "jsx"
22
+ )) {
23
+ context.report({
24
+ message: `\`styled-jsx\` should not be used in \`pages/_document.js\`. See: ${url}`,
25
+ node
26
+ });
27
+ }
28
+ }
29
+ }),
30
+ meta: {
31
+ docs: {
32
+ description: "Prevent usage of `styled-jsx` in `pages/_document.js`.",
33
+ recommended: true,
34
+ url
35
+ },
36
+ schema: [],
37
+ type: "problem"
38
+ }
39
+ });
40
+ export {
41
+ noStyledJsxInDocument
42
+ };
43
+ //# sourceMappingURL=no-styled-jsx-in-document.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/rules/no-styled-jsx-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-styled-jsx-in-document\";\n\nexport const noStyledJsxInDocument = defineRule({\n create: (context: any) => ({\n JSXOpeningElement: (node: any) => {\n const document = context.filename.split(\"pages\", 2)[1];\n if (!document) {\n return;\n }\n const { dir, name } = path.parse(document);\n\n if (\n !(\n name.startsWith(\"_document\") ||\n (dir === \"/_document\" && name === \"index\")\n )\n ) {\n return;\n }\n\n if (\n node.name.name === \"style\" &&\n node.attributes.find(\n (attr: any) =>\n attr.type === \"JSXAttribute\" && attr.name.name === \"jsx\",\n )\n ) {\n context.report({\n message: `\\`styled-jsx\\` should not be used in \\`pages/_document.js\\`. See: ${url}`,\n node,\n });\n }\n },\n }),\n meta: {\n docs: {\n description: \"Prevent usage of `styled-jsx` 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,wBAAwB,WAAW;AAAA,EAC9C,QAAQ,CAAC,aAAkB;AAAA,IACzB,mBAAmB,CAAC,SAAc;AAChC,YAAM,WAAW,QAAQ,SAAS,MAAM,SAAS,CAAC,EAAE,CAAC;AACrD,UAAI,CAAC,UAAU;AACb;AAAA,MACF;AACA,YAAM,EAAE,KAAK,KAAK,IAAS,WAAM,QAAQ;AAEzC,UACE,EACE,KAAK,WAAW,WAAW,KAC1B,QAAQ,gBAAgB,SAAS,UAEpC;AACA;AAAA,MACF;AAEA,UACE,KAAK,KAAK,SAAS,WACnB,KAAK,WAAW;AAAA,QACd,CAAC,SACC,KAAK,SAAS,kBAAkB,KAAK,KAAK,SAAS;AAAA,MACvD,GACA;AACA,gBAAQ,OAAO;AAAA,UACb,SAAS,qEAAqE,GAAG;AAAA,UACjF;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,64 @@
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-sync-scripts.ts
21
+ var no_sync_scripts_exports = {};
22
+ __export(no_sync_scripts_exports, {
23
+ noSyncScripts: () => noSyncScripts
24
+ });
25
+ module.exports = __toCommonJS(no_sync_scripts_exports);
26
+
27
+ // src/utils/define-rule.ts
28
+ var defineRule = (rule) => rule;
29
+
30
+ // src/rules/no-sync-scripts.ts
31
+ var url = "https://nextjs.org/docs/messages/no-sync-scripts";
32
+ var noSyncScripts = defineRule({
33
+ create: (context) => ({
34
+ JSXOpeningElement: (node) => {
35
+ if (node.name.name !== "script") {
36
+ return;
37
+ }
38
+ if (node.attributes.length === 0) {
39
+ return;
40
+ }
41
+ const attributeNames = node.attributes.filter((attr) => attr.type === "JSXAttribute").map((attr) => attr.name.name);
42
+ if (attributeNames.includes("src") && !attributeNames.includes("async") && !attributeNames.includes("defer")) {
43
+ context.report({
44
+ message: `Synchronous scripts should not be used. See: ${url}`,
45
+ node
46
+ });
47
+ }
48
+ }
49
+ }),
50
+ meta: {
51
+ docs: {
52
+ description: "Prevent synchronous scripts.",
53
+ recommended: true,
54
+ url
55
+ },
56
+ schema: [],
57
+ type: "problem"
58
+ }
59
+ });
60
+ // Annotate the CommonJS export names for ESM import in node:
61
+ 0 && (module.exports = {
62
+ noSyncScripts
63
+ });
64
+ //# sourceMappingURL=no-sync-scripts.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/rules/no-sync-scripts.ts","../../src/utils/define-rule.ts"],"sourcesContent":["import { defineRule } from \"../utils/define-rule.js\";\n\nconst url = \"https://nextjs.org/docs/messages/no-sync-scripts\";\n\nexport const noSyncScripts = defineRule({\n create: (context: any) => ({\n JSXOpeningElement: (node: any) => {\n if (node.name.name !== \"script\") {\n return;\n }\n if (node.attributes.length === 0) {\n return;\n }\n const attributeNames = node.attributes\n .filter((attr: any) => attr.type === \"JSXAttribute\")\n .map((attr: any) => attr.name.name);\n if (\n attributeNames.includes(\"src\") &&\n !attributeNames.includes(\"async\") &&\n !attributeNames.includes(\"defer\")\n ) {\n context.report({\n message: `Synchronous scripts should not be used. See: ${url}`,\n node,\n });\n }\n },\n }),\n meta: {\n docs: {\n description: \"Prevent synchronous scripts.\",\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;;;ADAtE,IAAM,MAAM;AAEL,IAAM,gBAAgB,WAAW;AAAA,EACtC,QAAQ,CAAC,aAAkB;AAAA,IACzB,mBAAmB,CAAC,SAAc;AAChC,UAAI,KAAK,KAAK,SAAS,UAAU;AAC/B;AAAA,MACF;AACA,UAAI,KAAK,WAAW,WAAW,GAAG;AAChC;AAAA,MACF;AACA,YAAM,iBAAiB,KAAK,WACzB,OAAO,CAAC,SAAc,KAAK,SAAS,cAAc,EAClD,IAAI,CAAC,SAAc,KAAK,KAAK,IAAI;AACpC,UACE,eAAe,SAAS,KAAK,KAC7B,CAAC,eAAe,SAAS,OAAO,KAChC,CAAC,eAAe,SAAS,OAAO,GAChC;AACA,gBAAQ,OAAO;AAAA,UACb,SAAS,gDAAgD,GAAG;AAAA,UAC5D;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 noSyncScripts: eslint.Rule.RuleModule;
4
+
5
+ export { noSyncScripts };
@@ -0,0 +1,5 @@
1
+ import * as eslint from 'eslint';
2
+
3
+ declare const noSyncScripts: eslint.Rule.RuleModule;
4
+
5
+ export { noSyncScripts };
@@ -0,0 +1,37 @@
1
+ // src/utils/define-rule.ts
2
+ var defineRule = (rule) => rule;
3
+
4
+ // src/rules/no-sync-scripts.ts
5
+ var url = "https://nextjs.org/docs/messages/no-sync-scripts";
6
+ var noSyncScripts = defineRule({
7
+ create: (context) => ({
8
+ JSXOpeningElement: (node) => {
9
+ if (node.name.name !== "script") {
10
+ return;
11
+ }
12
+ if (node.attributes.length === 0) {
13
+ return;
14
+ }
15
+ const attributeNames = node.attributes.filter((attr) => attr.type === "JSXAttribute").map((attr) => attr.name.name);
16
+ if (attributeNames.includes("src") && !attributeNames.includes("async") && !attributeNames.includes("defer")) {
17
+ context.report({
18
+ message: `Synchronous scripts should not be used. See: ${url}`,
19
+ node
20
+ });
21
+ }
22
+ }
23
+ }),
24
+ meta: {
25
+ docs: {
26
+ description: "Prevent synchronous scripts.",
27
+ recommended: true,
28
+ url
29
+ },
30
+ schema: [],
31
+ type: "problem"
32
+ }
33
+ });
34
+ export {
35
+ noSyncScripts
36
+ };
37
+ //# sourceMappingURL=no-sync-scripts.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/utils/define-rule.ts","../../src/rules/no-sync-scripts.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\";\n\nconst url = \"https://nextjs.org/docs/messages/no-sync-scripts\";\n\nexport const noSyncScripts = defineRule({\n create: (context: any) => ({\n JSXOpeningElement: (node: any) => {\n if (node.name.name !== \"script\") {\n return;\n }\n if (node.attributes.length === 0) {\n return;\n }\n const attributeNames = node.attributes\n .filter((attr: any) => attr.type === \"JSXAttribute\")\n .map((attr: any) => attr.name.name);\n if (\n attributeNames.includes(\"src\") &&\n !attributeNames.includes(\"async\") &&\n !attributeNames.includes(\"defer\")\n ) {\n context.report({\n message: `Synchronous scripts should not be used. See: ${url}`,\n node,\n });\n }\n },\n }),\n meta: {\n docs: {\n description: \"Prevent synchronous scripts.\",\n recommended: true,\n url,\n },\n schema: [],\n type: \"problem\",\n },\n});\n"],"mappings":";AAEO,IAAM,aAAa,CAAC,SAA2C;;;ACAtE,IAAM,MAAM;AAEL,IAAM,gBAAgB,WAAW;AAAA,EACtC,QAAQ,CAAC,aAAkB;AAAA,IACzB,mBAAmB,CAAC,SAAc;AAChC,UAAI,KAAK,KAAK,SAAS,UAAU;AAC/B;AAAA,MACF;AACA,UAAI,KAAK,WAAW,WAAW,GAAG;AAChC;AAAA,MACF;AACA,YAAM,iBAAiB,KAAK,WACzB,OAAO,CAAC,SAAc,KAAK,SAAS,cAAc,EAClD,IAAI,CAAC,SAAc,KAAK,KAAK,IAAI;AACpC,UACE,eAAe,SAAS,KAAK,KAC7B,CAAC,eAAe,SAAS,OAAO,KAChC,CAAC,eAAe,SAAS,OAAO,GAChC;AACA,gBAAQ,OAAO;AAAA,UACb,SAAS,gDAAgD,GAAG;AAAA,UAC5D;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,78 @@
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-title-in-document-head.ts
21
+ var no_title_in_document_head_exports = {};
22
+ __export(no_title_in_document_head_exports, {
23
+ noTitleInDocumentHead: () => noTitleInDocumentHead
24
+ });
25
+ module.exports = __toCommonJS(no_title_in_document_head_exports);
26
+
27
+ // src/utils/define-rule.ts
28
+ var defineRule = (rule) => rule;
29
+
30
+ // src/rules/no-title-in-document-head.ts
31
+ var url = "https://nextjs.org/docs/messages/no-title-in-document-head";
32
+ var noTitleInDocumentHead = defineRule({
33
+ create: (context) => {
34
+ let headFromNextDocument = false;
35
+ return {
36
+ ImportDeclaration: (node) => {
37
+ if (node.source.value === "next/document") {
38
+ if (node.specifiers.some(
39
+ ({ local }) => local.name === "Head"
40
+ )) {
41
+ headFromNextDocument = true;
42
+ }
43
+ }
44
+ },
45
+ JSXElement: (node) => {
46
+ if (!headFromNextDocument) {
47
+ return;
48
+ }
49
+ if (node.openingElement?.name && node.openingElement.name.name !== "Head") {
50
+ return;
51
+ }
52
+ const titleTag = node.children.find(
53
+ (child) => child.openingElement?.name && child.openingElement.name.type === "JSXIdentifier" && child.openingElement.name.name === "title"
54
+ );
55
+ if (titleTag) {
56
+ context.report({
57
+ message: `Do not use \`<title>\` element with \`<Head />\` component from \`next/document\`. Titles should defined at the page-level using \`<Head />\` from \`next/head\` instead. See: ${url}`,
58
+ node: titleTag
59
+ });
60
+ }
61
+ }
62
+ };
63
+ },
64
+ meta: {
65
+ docs: {
66
+ description: "Prevent usage of `<title>` with `Head` component from `next/document`.",
67
+ recommended: true,
68
+ url
69
+ },
70
+ schema: [],
71
+ type: "problem"
72
+ }
73
+ });
74
+ // Annotate the CommonJS export names for ESM import in node:
75
+ 0 && (module.exports = {
76
+ noTitleInDocumentHead
77
+ });
78
+ //# sourceMappingURL=no-title-in-document-head.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/rules/no-title-in-document-head.ts","../../src/utils/define-rule.ts"],"sourcesContent":["import { defineRule } from \"../utils/define-rule.js\";\nconst url = \"https://nextjs.org/docs/messages/no-title-in-document-head\";\n\nexport const noTitleInDocumentHead = defineRule({\n create: (context: any) => {\n let headFromNextDocument = false;\n return {\n ImportDeclaration: (node: any) => {\n if (node.source.value === \"next/document\") {\n if (\n node.specifiers.some(\n ({ local }: { local: any }) => local.name === \"Head\",\n )\n ) {\n headFromNextDocument = true;\n }\n }\n },\n JSXElement: (node: any) => {\n if (!headFromNextDocument) {\n return;\n }\n\n if (\n node.openingElement?.name &&\n node.openingElement.name.name !== \"Head\"\n ) {\n return;\n }\n\n const titleTag = node.children.find(\n (child: any) =>\n child.openingElement?.name &&\n child.openingElement.name.type === \"JSXIdentifier\" &&\n child.openingElement.name.name === \"title\",\n );\n\n if (titleTag) {\n context.report({\n message: `Do not use \\`<title>\\` element with \\`<Head />\\` component from \\`next/document\\`. Titles should defined at the page-level using \\`<Head />\\` from \\`next/head\\` instead. See: ${url}`,\n node: titleTag,\n });\n }\n },\n };\n },\n meta: {\n docs: {\n description:\n \"Prevent usage of `<title>` with `Head` component from `next/document`.\",\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,wBAAwB,WAAW;AAAA,EAC9C,QAAQ,CAAC,YAAiB;AACxB,QAAI,uBAAuB;AAC3B,WAAO;AAAA,MACL,mBAAmB,CAAC,SAAc;AAChC,YAAI,KAAK,OAAO,UAAU,iBAAiB;AACzC,cACE,KAAK,WAAW;AAAA,YACd,CAAC,EAAE,MAAM,MAAsB,MAAM,SAAS;AAAA,UAChD,GACA;AACA,mCAAuB;AAAA,UACzB;AAAA,QACF;AAAA,MACF;AAAA,MACA,YAAY,CAAC,SAAc;AACzB,YAAI,CAAC,sBAAsB;AACzB;AAAA,QACF;AAEA,YACE,KAAK,gBAAgB,QACrB,KAAK,eAAe,KAAK,SAAS,QAClC;AACA;AAAA,QACF;AAEA,cAAM,WAAW,KAAK,SAAS;AAAA,UAC7B,CAAC,UACC,MAAM,gBAAgB,QACtB,MAAM,eAAe,KAAK,SAAS,mBACnC,MAAM,eAAe,KAAK,SAAS;AAAA,QACvC;AAEA,YAAI,UAAU;AACZ,kBAAQ,OAAO;AAAA,YACb,SAAS,kLAAkL,GAAG;AAAA,YAC9L,MAAM;AAAA,UACR,CAAC;AAAA,QACH;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 noTitleInDocumentHead: eslint.Rule.RuleModule;
4
+
5
+ export { noTitleInDocumentHead };
@@ -0,0 +1,5 @@
1
+ import * as eslint from 'eslint';
2
+
3
+ declare const noTitleInDocumentHead: eslint.Rule.RuleModule;
4
+
5
+ export { noTitleInDocumentHead };
@@ -0,0 +1,51 @@
1
+ // src/utils/define-rule.ts
2
+ var defineRule = (rule) => rule;
3
+
4
+ // src/rules/no-title-in-document-head.ts
5
+ var url = "https://nextjs.org/docs/messages/no-title-in-document-head";
6
+ var noTitleInDocumentHead = defineRule({
7
+ create: (context) => {
8
+ let headFromNextDocument = false;
9
+ return {
10
+ ImportDeclaration: (node) => {
11
+ if (node.source.value === "next/document") {
12
+ if (node.specifiers.some(
13
+ ({ local }) => local.name === "Head"
14
+ )) {
15
+ headFromNextDocument = true;
16
+ }
17
+ }
18
+ },
19
+ JSXElement: (node) => {
20
+ if (!headFromNextDocument) {
21
+ return;
22
+ }
23
+ if (node.openingElement?.name && node.openingElement.name.name !== "Head") {
24
+ return;
25
+ }
26
+ const titleTag = node.children.find(
27
+ (child) => child.openingElement?.name && child.openingElement.name.type === "JSXIdentifier" && child.openingElement.name.name === "title"
28
+ );
29
+ if (titleTag) {
30
+ context.report({
31
+ message: `Do not use \`<title>\` element with \`<Head />\` component from \`next/document\`. Titles should defined at the page-level using \`<Head />\` from \`next/head\` instead. See: ${url}`,
32
+ node: titleTag
33
+ });
34
+ }
35
+ }
36
+ };
37
+ },
38
+ meta: {
39
+ docs: {
40
+ description: "Prevent usage of `<title>` with `Head` component from `next/document`.",
41
+ recommended: true,
42
+ url
43
+ },
44
+ schema: [],
45
+ type: "problem"
46
+ }
47
+ });
48
+ export {
49
+ noTitleInDocumentHead
50
+ };
51
+ //# sourceMappingURL=no-title-in-document-head.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/utils/define-rule.ts","../../src/rules/no-title-in-document-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-title-in-document-head\";\n\nexport const noTitleInDocumentHead = defineRule({\n create: (context: any) => {\n let headFromNextDocument = false;\n return {\n ImportDeclaration: (node: any) => {\n if (node.source.value === \"next/document\") {\n if (\n node.specifiers.some(\n ({ local }: { local: any }) => local.name === \"Head\",\n )\n ) {\n headFromNextDocument = true;\n }\n }\n },\n JSXElement: (node: any) => {\n if (!headFromNextDocument) {\n return;\n }\n\n if (\n node.openingElement?.name &&\n node.openingElement.name.name !== \"Head\"\n ) {\n return;\n }\n\n const titleTag = node.children.find(\n (child: any) =>\n child.openingElement?.name &&\n child.openingElement.name.type === \"JSXIdentifier\" &&\n child.openingElement.name.name === \"title\",\n );\n\n if (titleTag) {\n context.report({\n message: `Do not use \\`<title>\\` element with \\`<Head />\\` component from \\`next/document\\`. Titles should defined at the page-level using \\`<Head />\\` from \\`next/head\\` instead. See: ${url}`,\n node: titleTag,\n });\n }\n },\n };\n },\n meta: {\n docs: {\n description:\n \"Prevent usage of `<title>` with `Head` component from `next/document`.\",\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,wBAAwB,WAAW;AAAA,EAC9C,QAAQ,CAAC,YAAiB;AACxB,QAAI,uBAAuB;AAC3B,WAAO;AAAA,MACL,mBAAmB,CAAC,SAAc;AAChC,YAAI,KAAK,OAAO,UAAU,iBAAiB;AACzC,cACE,KAAK,WAAW;AAAA,YACd,CAAC,EAAE,MAAM,MAAsB,MAAM,SAAS;AAAA,UAChD,GACA;AACA,mCAAuB;AAAA,UACzB;AAAA,QACF;AAAA,MACF;AAAA,MACA,YAAY,CAAC,SAAc;AACzB,YAAI,CAAC,sBAAsB;AACzB;AAAA,QACF;AAEA,YACE,KAAK,gBAAgB,QACrB,KAAK,eAAe,KAAK,SAAS,QAClC;AACA;AAAA,QACF;AAEA,cAAM,WAAW,KAAK,SAAS;AAAA,UAC7B,CAAC,UACC,MAAM,gBAAgB,QACtB,MAAM,eAAe,KAAK,SAAS,mBACnC,MAAM,eAAe,KAAK,SAAS;AAAA,QACvC;AAEA,YAAI,UAAU;AACZ,kBAAQ,OAAO;AAAA,YACb,SAAS,kLAAkL,GAAG;AAAA,YAC9L,MAAM;AAAA,UACR,CAAC;AAAA,QACH;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,133 @@
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-typos.ts
31
+ var no_typos_exports = {};
32
+ __export(no_typos_exports, {
33
+ noTypos: () => noTypos
34
+ });
35
+ module.exports = __toCommonJS(no_typos_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-typos.ts
42
+ var NEXT_EXPORT_FUNCTIONS = [
43
+ "getStaticProps",
44
+ "getStaticPaths",
45
+ "getServerSideProps"
46
+ ];
47
+ var THRESHOLD = 1;
48
+ var minDistance = (a, b) => {
49
+ const m = a.length;
50
+ const n = b.length;
51
+ if (m < n) {
52
+ return minDistance(b, a);
53
+ }
54
+ if (n === 0) {
55
+ return m;
56
+ }
57
+ let previousRow = Array.from({ length: n + 1 }, (_, i) => i);
58
+ for (let i = 0; i < m; i++) {
59
+ const s1 = a[i];
60
+ const currentRow = [i + 1];
61
+ for (let j = 0; j < n; j++) {
62
+ const s2 = b[j];
63
+ const insertions = previousRow[j + 1] + 1;
64
+ const deletions = currentRow[j] + 1;
65
+ const substitutions = previousRow[j] + Number(s1 !== s2);
66
+ currentRow.push(Math.min(insertions, deletions, substitutions));
67
+ }
68
+ previousRow = currentRow;
69
+ }
70
+ return previousRow[previousRow.length - 1];
71
+ };
72
+ var noTypos = defineRule({
73
+ create: (context) => {
74
+ const checkTypos = (node, name) => {
75
+ if (NEXT_EXPORT_FUNCTIONS.includes(name)) {
76
+ return;
77
+ }
78
+ const potentialTypos = NEXT_EXPORT_FUNCTIONS.map((o) => ({
79
+ distance: minDistance(o, name) ?? Infinity,
80
+ option: o
81
+ })).filter(({ distance }) => distance <= THRESHOLD && distance > 0).sort((a, b) => a.distance - b.distance);
82
+ if (potentialTypos.length) {
83
+ context.report({
84
+ message: `${name} may be a typo. Did you mean ${potentialTypos[0]?.option}?`,
85
+ node
86
+ });
87
+ }
88
+ };
89
+ return {
90
+ ExportNamedDeclaration: (node) => {
91
+ const page = context.filename.split("pages", 2)[1];
92
+ if (!page || path.parse(page).dir.startsWith("/api")) {
93
+ return;
94
+ }
95
+ const decl = node.declaration;
96
+ if (!decl) {
97
+ return;
98
+ }
99
+ switch (decl.type) {
100
+ case "FunctionDeclaration": {
101
+ checkTypos(node, decl.id.name);
102
+ break;
103
+ }
104
+ case "VariableDeclaration": {
105
+ decl.declarations.forEach((d) => {
106
+ if (d.id.type !== "Identifier") {
107
+ return;
108
+ }
109
+ checkTypos(node, d.id.name);
110
+ });
111
+ break;
112
+ }
113
+ default: {
114
+ break;
115
+ }
116
+ }
117
+ }
118
+ };
119
+ },
120
+ meta: {
121
+ docs: {
122
+ description: "Prevent common typos in Next.js data fetching functions.",
123
+ recommended: true
124
+ },
125
+ schema: [],
126
+ type: "problem"
127
+ }
128
+ });
129
+ // Annotate the CommonJS export names for ESM import in node:
130
+ 0 && (module.exports = {
131
+ noTypos
132
+ });
133
+ //# sourceMappingURL=no-typos.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/rules/no-typos.ts","../../src/utils/define-rule.ts"],"sourcesContent":["import * as path from \"node:path\";\n\nimport { defineRule } from \"../utils/define-rule.js\";\n\nconst NEXT_EXPORT_FUNCTIONS = [\n \"getStaticProps\",\n \"getStaticPaths\",\n \"getServerSideProps\",\n];\n\n// 0 is the exact match\nconst THRESHOLD = 1;\n\n// the minimum number of operations required to convert string a to string b.\nconst minDistance = (a: string, b: string): number | undefined => {\n const m = a.length;\n const n = b.length;\n\n if (m < n) {\n return minDistance(b, a);\n }\n\n if (n === 0) {\n return m;\n }\n\n let previousRow = Array.from({ length: n + 1 }, (_, i) => i);\n\n for (let i = 0; i < m; i++) {\n const s1 = a[i];\n const currentRow = [i + 1];\n for (let j = 0; j < n; j++) {\n const s2 = b[j];\n const insertions = (previousRow[j + 1] as any) + 1;\n const deletions = (currentRow[j] as any) + 1;\n const substitutions = (previousRow[j] as any) + Number(s1 !== s2);\n currentRow.push(Math.min(insertions, deletions, substitutions));\n }\n previousRow = currentRow;\n }\n return previousRow[previousRow.length - 1];\n};\n\nexport const noTypos = defineRule({\n create: (context: any) => {\n const checkTypos = (node: any, name: string) => {\n if (NEXT_EXPORT_FUNCTIONS.includes(name)) {\n return;\n }\n\n const potentialTypos = NEXT_EXPORT_FUNCTIONS.map((o) => ({\n distance: minDistance(o, name) ?? Infinity,\n option: o,\n }))\n .filter(({ distance }) => distance <= THRESHOLD && distance > 0)\n .sort((a, b) => a.distance - b.distance);\n\n if (potentialTypos.length) {\n context.report({\n message: `${name} may be a typo. Did you mean ${potentialTypos[0]?.option}?`,\n node,\n });\n }\n };\n return {\n ExportNamedDeclaration: (node: any) => {\n const page = context.filename.split(\"pages\", 2)[1];\n if (!page || path.parse(page).dir.startsWith(\"/api\")) {\n return;\n }\n\n const decl = node.declaration;\n\n if (!decl) {\n return;\n }\n\n switch (decl.type) {\n case \"FunctionDeclaration\": {\n checkTypos(node, decl.id.name);\n break;\n }\n case \"VariableDeclaration\": {\n decl.declarations.forEach((d: any) => {\n if (d.id.type !== \"Identifier\") {\n return;\n }\n checkTypos(node, d.id.name);\n });\n break;\n }\n default: {\n break;\n }\n }\n },\n };\n },\n\n meta: {\n docs: {\n description: \"Prevent common typos in Next.js data fetching functions.\",\n recommended: true,\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,wBAAwB;AAAA,EAC5B;AAAA,EACA;AAAA,EACA;AACF;AAGA,IAAM,YAAY;AAGlB,IAAM,cAAc,CAAC,GAAW,MAAkC;AAChE,QAAM,IAAI,EAAE;AACZ,QAAM,IAAI,EAAE;AAEZ,MAAI,IAAI,GAAG;AACT,WAAO,YAAY,GAAG,CAAC;AAAA,EACzB;AAEA,MAAI,MAAM,GAAG;AACX,WAAO;AAAA,EACT;AAEA,MAAI,cAAc,MAAM,KAAK,EAAE,QAAQ,IAAI,EAAE,GAAG,CAAC,GAAG,MAAM,CAAC;AAE3D,WAAS,IAAI,GAAG,IAAI,GAAG,KAAK;AAC1B,UAAM,KAAK,EAAE,CAAC;AACd,UAAM,aAAa,CAAC,IAAI,CAAC;AACzB,aAAS,IAAI,GAAG,IAAI,GAAG,KAAK;AAC1B,YAAM,KAAK,EAAE,CAAC;AACd,YAAM,aAAc,YAAY,IAAI,CAAC,IAAY;AACjD,YAAM,YAAa,WAAW,CAAC,IAAY;AAC3C,YAAM,gBAAiB,YAAY,CAAC,IAAY,OAAO,OAAO,EAAE;AAChE,iBAAW,KAAK,KAAK,IAAI,YAAY,WAAW,aAAa,CAAC;AAAA,IAChE;AACA,kBAAc;AAAA,EAChB;AACA,SAAO,YAAY,YAAY,SAAS,CAAC;AAC3C;AAEO,IAAM,UAAU,WAAW;AAAA,EAChC,QAAQ,CAAC,YAAiB;AACxB,UAAM,aAAa,CAAC,MAAW,SAAiB;AAC9C,UAAI,sBAAsB,SAAS,IAAI,GAAG;AACxC;AAAA,MACF;AAEA,YAAM,iBAAiB,sBAAsB,IAAI,CAAC,OAAO;AAAA,QACvD,UAAU,YAAY,GAAG,IAAI,KAAK;AAAA,QAClC,QAAQ;AAAA,MACV,EAAE,EACC,OAAO,CAAC,EAAE,SAAS,MAAM,YAAY,aAAa,WAAW,CAAC,EAC9D,KAAK,CAAC,GAAG,MAAM,EAAE,WAAW,EAAE,QAAQ;AAEzC,UAAI,eAAe,QAAQ;AACzB,gBAAQ,OAAO;AAAA,UACb,SAAS,GAAG,IAAI,gCAAgC,eAAe,CAAC,GAAG,MAAM;AAAA,UACzE;AAAA,QACF,CAAC;AAAA,MACH;AAAA,IACF;AACA,WAAO;AAAA,MACL,wBAAwB,CAAC,SAAc;AACrC,cAAM,OAAO,QAAQ,SAAS,MAAM,SAAS,CAAC,EAAE,CAAC;AACjD,YAAI,CAAC,QAAa,WAAM,IAAI,EAAE,IAAI,WAAW,MAAM,GAAG;AACpD;AAAA,QACF;AAEA,cAAM,OAAO,KAAK;AAElB,YAAI,CAAC,MAAM;AACT;AAAA,QACF;AAEA,gBAAQ,KAAK,MAAM;AAAA,UACjB,KAAK,uBAAuB;AAC1B,uBAAW,MAAM,KAAK,GAAG,IAAI;AAC7B;AAAA,UACF;AAAA,UACA,KAAK,uBAAuB;AAC1B,iBAAK,aAAa,QAAQ,CAAC,MAAW;AACpC,kBAAI,EAAE,GAAG,SAAS,cAAc;AAC9B;AAAA,cACF;AACA,yBAAW,MAAM,EAAE,GAAG,IAAI;AAAA,YAC5B,CAAC;AACD;AAAA,UACF;AAAA,UACA,SAAS;AACP;AAAA,UACF;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAAA,EAEA,MAAM;AAAA,IACJ,MAAM;AAAA,MACJ,aAAa;AAAA,MACb,aAAa;AAAA,IACf;AAAA,IACA,QAAQ,CAAC;AAAA,IACT,MAAM;AAAA,EACR;AACF,CAAC;","names":[]}