eslint-plugin-nextjs 0.0.1 → 0.1.0

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 (157) hide show
  1. package/dist/index.cjs +1494 -0
  2. package/dist/index.cjs.map +1 -0
  3. package/dist/index.d.cts +43 -0
  4. package/dist/index.d.ts +42 -1
  5. package/dist/index.js +1455 -1
  6. package/dist/index.js.map +1 -1
  7. package/dist/rules/google-font-display.cjs +119 -0
  8. package/dist/rules/google-font-display.cjs.map +1 -0
  9. package/dist/rules/google-font-display.d.cts +8 -0
  10. package/dist/rules/google-font-display.d.ts +8 -0
  11. package/dist/rules/google-font-display.js +92 -0
  12. package/dist/rules/google-font-display.js.map +1 -0
  13. package/dist/rules/google-font-preconnect.cjs +109 -0
  14. package/dist/rules/google-font-preconnect.cjs.map +1 -0
  15. package/dist/rules/google-font-preconnect.d.cts +5 -0
  16. package/dist/rules/google-font-preconnect.d.ts +5 -0
  17. package/dist/rules/google-font-preconnect.js +82 -0
  18. package/dist/rules/google-font-preconnect.js.map +1 -0
  19. package/dist/rules/inline-script-id.cjs +94 -0
  20. package/dist/rules/inline-script-id.cjs.map +1 -0
  21. package/dist/rules/inline-script-id.d.cts +5 -0
  22. package/dist/rules/inline-script-id.d.ts +5 -0
  23. package/dist/rules/inline-script-id.js +67 -0
  24. package/dist/rules/inline-script-id.js.map +1 -0
  25. package/dist/rules/next-script-for-ga.cjs +129 -0
  26. package/dist/rules/next-script-for-ga.cjs.map +1 -0
  27. package/dist/rules/next-script-for-ga.d.cts +5 -0
  28. package/dist/rules/next-script-for-ga.d.ts +5 -0
  29. package/dist/rules/next-script-for-ga.js +102 -0
  30. package/dist/rules/next-script-for-ga.js.map +1 -0
  31. package/dist/rules/no-assign-module-variable.cjs +64 -0
  32. package/dist/rules/no-assign-module-variable.cjs.map +1 -0
  33. package/dist/rules/no-assign-module-variable.d.cts +5 -0
  34. package/dist/rules/no-assign-module-variable.d.ts +5 -0
  35. package/dist/rules/no-assign-module-variable.js +37 -0
  36. package/dist/rules/no-assign-module-variable.js.map +1 -0
  37. package/dist/rules/no-async-client-component.cjs +99 -0
  38. package/dist/rules/no-async-client-component.cjs.map +1 -0
  39. package/dist/rules/no-async-client-component.d.cts +5 -0
  40. package/dist/rules/no-async-client-component.d.ts +5 -0
  41. package/dist/rules/no-async-client-component.js +72 -0
  42. package/dist/rules/no-async-client-component.js.map +1 -0
  43. package/dist/rules/no-before-interactive-script-outside-document.cjs +94 -0
  44. package/dist/rules/no-before-interactive-script-outside-document.cjs.map +1 -0
  45. package/dist/rules/no-before-interactive-script-outside-document.d.cts +5 -0
  46. package/dist/rules/no-before-interactive-script-outside-document.d.ts +5 -0
  47. package/dist/rules/no-before-interactive-script-outside-document.js +59 -0
  48. package/dist/rules/no-before-interactive-script-outside-document.js.map +1 -0
  49. package/dist/rules/no-css-tags.cjs +70 -0
  50. package/dist/rules/no-css-tags.cjs.map +1 -0
  51. package/dist/rules/no-css-tags.d.cts +5 -0
  52. package/dist/rules/no-css-tags.d.ts +5 -0
  53. package/dist/rules/no-css-tags.js +43 -0
  54. package/dist/rules/no-css-tags.js.map +1 -0
  55. package/dist/rules/no-document-import-in-page.cjs +74 -0
  56. package/dist/rules/no-document-import-in-page.cjs.map +1 -0
  57. package/dist/rules/no-document-import-in-page.d.cts +5 -0
  58. package/dist/rules/no-document-import-in-page.d.ts +5 -0
  59. package/dist/rules/no-document-import-in-page.js +39 -0
  60. package/dist/rules/no-document-import-in-page.js.map +1 -0
  61. package/dist/rules/no-duplicate-head.cjs +87 -0
  62. package/dist/rules/no-duplicate-head.cjs.map +1 -0
  63. package/dist/rules/no-duplicate-head.d.cts +5 -0
  64. package/dist/rules/no-duplicate-head.d.ts +5 -0
  65. package/dist/rules/no-duplicate-head.js +60 -0
  66. package/dist/rules/no-duplicate-head.js.map +1 -0
  67. package/dist/rules/no-head-element.cjs +76 -0
  68. package/dist/rules/no-head-element.cjs.map +1 -0
  69. package/dist/rules/no-head-element.d.cts +5 -0
  70. package/dist/rules/no-head-element.d.ts +5 -0
  71. package/dist/rules/no-head-element.js +41 -0
  72. package/dist/rules/no-head-element.js.map +1 -0
  73. package/dist/rules/no-head-import-in-document.cjs +76 -0
  74. package/dist/rules/no-head-import-in-document.cjs.map +1 -0
  75. package/dist/rules/no-head-import-in-document.d.cts +5 -0
  76. package/dist/rules/no-head-import-in-document.d.ts +5 -0
  77. package/dist/rules/no-head-import-in-document.js +41 -0
  78. package/dist/rules/no-head-import-in-document.js.map +1 -0
  79. package/dist/rules/no-html-link-for-pages.cjs +302 -0
  80. package/dist/rules/no-html-link-for-pages.cjs.map +1 -0
  81. package/dist/rules/no-html-link-for-pages.d.cts +5 -0
  82. package/dist/rules/no-html-link-for-pages.d.ts +5 -0
  83. package/dist/rules/no-html-link-for-pages.js +267 -0
  84. package/dist/rules/no-html-link-for-pages.js.map +1 -0
  85. package/dist/rules/no-img-element.cjs +83 -0
  86. package/dist/rules/no-img-element.cjs.map +1 -0
  87. package/dist/rules/no-img-element.d.cts +5 -0
  88. package/dist/rules/no-img-element.d.ts +5 -0
  89. package/dist/rules/no-img-element.js +48 -0
  90. package/dist/rules/no-img-element.js.map +1 -0
  91. package/dist/rules/no-page-custom-font.cjs +184 -0
  92. package/dist/rules/no-page-custom-font.cjs.map +1 -0
  93. package/dist/rules/no-page-custom-font.d.cts +5 -0
  94. package/dist/rules/no-page-custom-font.d.ts +5 -0
  95. package/dist/rules/no-page-custom-font.js +159 -0
  96. package/dist/rules/no-page-custom-font.js.map +1 -0
  97. package/dist/rules/no-script-component-in-head.cjs +74 -0
  98. package/dist/rules/no-script-component-in-head.cjs.map +1 -0
  99. package/dist/rules/no-script-component-in-head.d.cts +5 -0
  100. package/dist/rules/no-script-component-in-head.d.ts +5 -0
  101. package/dist/rules/no-script-component-in-head.js +47 -0
  102. package/dist/rules/no-script-component-in-head.js.map +1 -0
  103. package/dist/rules/no-styled-jsx-in-document.cjs +78 -0
  104. package/dist/rules/no-styled-jsx-in-document.cjs.map +1 -0
  105. package/dist/rules/no-styled-jsx-in-document.d.cts +5 -0
  106. package/dist/rules/no-styled-jsx-in-document.d.ts +5 -0
  107. package/dist/rules/no-styled-jsx-in-document.js +43 -0
  108. package/dist/rules/no-styled-jsx-in-document.js.map +1 -0
  109. package/dist/rules/no-sync-scripts.cjs +64 -0
  110. package/dist/rules/no-sync-scripts.cjs.map +1 -0
  111. package/dist/rules/no-sync-scripts.d.cts +5 -0
  112. package/dist/rules/no-sync-scripts.d.ts +5 -0
  113. package/dist/rules/no-sync-scripts.js +37 -0
  114. package/dist/rules/no-sync-scripts.js.map +1 -0
  115. package/dist/rules/no-title-in-document-head.cjs +78 -0
  116. package/dist/rules/no-title-in-document-head.cjs.map +1 -0
  117. package/dist/rules/no-title-in-document-head.d.cts +5 -0
  118. package/dist/rules/no-title-in-document-head.d.ts +5 -0
  119. package/dist/rules/no-title-in-document-head.js +51 -0
  120. package/dist/rules/no-title-in-document-head.js.map +1 -0
  121. package/dist/rules/no-typos.cjs +133 -0
  122. package/dist/rules/no-typos.cjs.map +1 -0
  123. package/dist/rules/no-typos.d.cts +5 -0
  124. package/dist/rules/no-typos.d.ts +5 -0
  125. package/dist/rules/no-typos.js +98 -0
  126. package/dist/rules/no-typos.js.map +1 -0
  127. package/dist/rules/no-unwanted-polyfillio.cjs +164 -0
  128. package/dist/rules/no-unwanted-polyfillio.cjs.map +1 -0
  129. package/dist/rules/no-unwanted-polyfillio.d.cts +5 -0
  130. package/dist/rules/no-unwanted-polyfillio.d.ts +5 -0
  131. package/dist/rules/no-unwanted-polyfillio.js +137 -0
  132. package/dist/rules/no-unwanted-polyfillio.js.map +1 -0
  133. package/dist/utils/define-rule.cjs +31 -0
  134. package/dist/utils/define-rule.cjs.map +1 -0
  135. package/dist/utils/define-rule.d.cts +5 -0
  136. package/dist/utils/define-rule.d.ts +5 -0
  137. package/dist/utils/define-rule.js +6 -0
  138. package/dist/utils/define-rule.js.map +1 -0
  139. package/dist/utils/get-root-dirs.cjs +60 -0
  140. package/dist/utils/get-root-dirs.cjs.map +1 -0
  141. package/dist/utils/get-root-dirs.d.cts +8 -0
  142. package/dist/utils/get-root-dirs.d.ts +8 -0
  143. package/dist/utils/get-root-dirs.js +25 -0
  144. package/dist/utils/get-root-dirs.js.map +1 -0
  145. package/dist/utils/node-attributes.cjs +67 -0
  146. package/dist/utils/node-attributes.cjs.map +1 -0
  147. package/dist/utils/node-attributes.d.cts +15 -0
  148. package/dist/utils/node-attributes.d.ts +15 -0
  149. package/dist/utils/node-attributes.js +46 -0
  150. package/dist/utils/node-attributes.js.map +1 -0
  151. package/dist/utils/url.cjs +167 -0
  152. package/dist/utils/url.cjs.map +1 -0
  153. package/dist/utils/url.d.cts +35 -0
  154. package/dist/utils/url.d.ts +35 -0
  155. package/dist/utils/url.js +128 -0
  156. package/dist/utils/url.js.map +1 -0
  157. package/package.json +15 -2
@@ -0,0 +1,5 @@
1
+ import * as eslint from 'eslint';
2
+
3
+ declare const noTypos: eslint.Rule.RuleModule;
4
+
5
+ export { noTypos };
@@ -0,0 +1,5 @@
1
+ import * as eslint from 'eslint';
2
+
3
+ declare const noTypos: eslint.Rule.RuleModule;
4
+
5
+ export { noTypos };
@@ -0,0 +1,98 @@
1
+ // src/rules/no-typos.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-typos.ts
8
+ var NEXT_EXPORT_FUNCTIONS = [
9
+ "getStaticProps",
10
+ "getStaticPaths",
11
+ "getServerSideProps"
12
+ ];
13
+ var THRESHOLD = 1;
14
+ var minDistance = (a, b) => {
15
+ const m = a.length;
16
+ const n = b.length;
17
+ if (m < n) {
18
+ return minDistance(b, a);
19
+ }
20
+ if (n === 0) {
21
+ return m;
22
+ }
23
+ let previousRow = Array.from({ length: n + 1 }, (_, i) => i);
24
+ for (let i = 0; i < m; i++) {
25
+ const s1 = a[i];
26
+ const currentRow = [i + 1];
27
+ for (let j = 0; j < n; j++) {
28
+ const s2 = b[j];
29
+ const insertions = previousRow[j + 1] + 1;
30
+ const deletions = currentRow[j] + 1;
31
+ const substitutions = previousRow[j] + Number(s1 !== s2);
32
+ currentRow.push(Math.min(insertions, deletions, substitutions));
33
+ }
34
+ previousRow = currentRow;
35
+ }
36
+ return previousRow[previousRow.length - 1];
37
+ };
38
+ var noTypos = defineRule({
39
+ create: (context) => {
40
+ const checkTypos = (node, name) => {
41
+ if (NEXT_EXPORT_FUNCTIONS.includes(name)) {
42
+ return;
43
+ }
44
+ const potentialTypos = NEXT_EXPORT_FUNCTIONS.map((o) => ({
45
+ distance: minDistance(o, name) ?? Infinity,
46
+ option: o
47
+ })).filter(({ distance }) => distance <= THRESHOLD && distance > 0).sort((a, b) => a.distance - b.distance);
48
+ if (potentialTypos.length) {
49
+ context.report({
50
+ message: `${name} may be a typo. Did you mean ${potentialTypos[0]?.option}?`,
51
+ node
52
+ });
53
+ }
54
+ };
55
+ return {
56
+ ExportNamedDeclaration: (node) => {
57
+ const page = context.filename.split("pages", 2)[1];
58
+ if (!page || path.parse(page).dir.startsWith("/api")) {
59
+ return;
60
+ }
61
+ const decl = node.declaration;
62
+ if (!decl) {
63
+ return;
64
+ }
65
+ switch (decl.type) {
66
+ case "FunctionDeclaration": {
67
+ checkTypos(node, decl.id.name);
68
+ break;
69
+ }
70
+ case "VariableDeclaration": {
71
+ decl.declarations.forEach((d) => {
72
+ if (d.id.type !== "Identifier") {
73
+ return;
74
+ }
75
+ checkTypos(node, d.id.name);
76
+ });
77
+ break;
78
+ }
79
+ default: {
80
+ break;
81
+ }
82
+ }
83
+ }
84
+ };
85
+ },
86
+ meta: {
87
+ docs: {
88
+ description: "Prevent common typos in Next.js data fetching functions.",
89
+ recommended: true
90
+ },
91
+ schema: [],
92
+ type: "problem"
93
+ }
94
+ });
95
+ export {
96
+ noTypos
97
+ };
98
+ //# sourceMappingURL=no-typos.js.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,YAAY,UAAU;;;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,SAA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names":[]}
@@ -0,0 +1,164 @@
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-unwanted-polyfillio.ts
21
+ var no_unwanted_polyfillio_exports = {};
22
+ __export(no_unwanted_polyfillio_exports, {
23
+ noUnwantedPolyfillio: () => noUnwantedPolyfillio
24
+ });
25
+ module.exports = __toCommonJS(no_unwanted_polyfillio_exports);
26
+
27
+ // src/utils/define-rule.ts
28
+ var defineRule = (rule) => rule;
29
+
30
+ // src/rules/no-unwanted-polyfillio.ts
31
+ var NEXT_POLYFILLED_FEATURES = [
32
+ "Array.prototype.@@iterator",
33
+ "Array.prototype.at",
34
+ "Array.prototype.copyWithin",
35
+ "Array.prototype.fill",
36
+ "Array.prototype.find",
37
+ "Array.prototype.findIndex",
38
+ "Array.prototype.flatMap",
39
+ "Array.prototype.flat",
40
+ "Array.from",
41
+ "Array.prototype.includes",
42
+ "Array.of",
43
+ "Function.prototype.name",
44
+ "fetch",
45
+ "Map",
46
+ "Number.EPSILON",
47
+ "Number.Epsilon",
48
+ "Number.isFinite",
49
+ "Number.isNaN",
50
+ "Number.isInteger",
51
+ "Number.isSafeInteger",
52
+ "Number.MAX_SAFE_INTEGER",
53
+ "Number.MIN_SAFE_INTEGER",
54
+ "Number.parseFloat",
55
+ "Number.parseInt",
56
+ "Object.assign",
57
+ "Object.entries",
58
+ "Object.fromEntries",
59
+ "Object.getOwnPropertyDescriptor",
60
+ "Object.getOwnPropertyDescriptors",
61
+ "Object.hasOwn",
62
+ "Object.is",
63
+ "Object.keys",
64
+ "Object.values",
65
+ "Reflect",
66
+ "Set",
67
+ "Symbol",
68
+ "Symbol.asyncIterator",
69
+ "String.prototype.codePointAt",
70
+ "String.prototype.endsWith",
71
+ "String.fromCodePoint",
72
+ "String.prototype.includes",
73
+ "String.prototype.@@iterator",
74
+ "String.prototype.padEnd",
75
+ "String.prototype.padStart",
76
+ "String.prototype.repeat",
77
+ "String.raw",
78
+ "String.prototype.startsWith",
79
+ "String.prototype.trimEnd",
80
+ "String.prototype.trimStart",
81
+ "URL",
82
+ "URL.prototype.toJSON",
83
+ "URLSearchParams",
84
+ "WeakMap",
85
+ "WeakSet",
86
+ "Promise",
87
+ "Promise.prototype.finally",
88
+ "es2015",
89
+ // Should be covered by babel-preset-env instead.
90
+ "es2016",
91
+ // contains polyfilled 'Array.prototype.includes', 'String.prototype.padEnd' and 'String.prototype.padStart'
92
+ "es2017",
93
+ // contains polyfilled 'Object.entries', 'Object.getOwnPropertyDescriptors', 'Object.values', 'String.prototype.padEnd' and 'String.prototype.padStart'
94
+ "es2018",
95
+ // contains polyfilled 'Promise.prototype.finally' and ''Symbol.asyncIterator'
96
+ "es2019",
97
+ // Contains polyfilled 'Object.fromEntries' and polyfilled 'Array.prototype.flat', 'Array.prototype.flatMap', 'String.prototype.trimEnd' and 'String.prototype.trimStart'
98
+ "es5",
99
+ // Should be covered by babel-preset-env instead.
100
+ "es6",
101
+ // Should be covered by babel-preset-env instead.
102
+ "es7"
103
+ // contains polyfilled 'Array.prototype.includes', 'String.prototype.padEnd' and 'String.prototype.padStart'
104
+ ];
105
+ var url = "https://nextjs.org/docs/messages/no-unwanted-polyfillio";
106
+ var noUnwantedPolyfillio = defineRule({
107
+ create: (context) => {
108
+ let scriptImport = null;
109
+ return {
110
+ ImportDeclaration: (node) => {
111
+ if (node.source && node.source.value === "next/script") {
112
+ scriptImport = node.specifiers[0].local.name;
113
+ }
114
+ },
115
+ JSXOpeningElement: (node) => {
116
+ if (node.name && node.name.name !== "script" && node.name.name !== scriptImport) {
117
+ return;
118
+ }
119
+ if (node.attributes.length === 0) {
120
+ return;
121
+ }
122
+ const srcNode = node.attributes.find(
123
+ (attr) => attr.type === "JSXAttribute" && attr.name.name === "src"
124
+ );
125
+ if (!srcNode || srcNode.value.type !== "Literal") {
126
+ return;
127
+ }
128
+ const src = srcNode.value.value;
129
+ if (src.startsWith("https://cdn.polyfill.io/v2/") || src.startsWith("https://polyfill.io/v3/") || // https://community.fastly.com/t/new-options-for-polyfill-io-users/2540
130
+ src.startsWith("https://polyfill-fastly.net/") || src.startsWith("https://polyfill-fastly.io/") || // https://blog.cloudflare.com/polyfill-io-now-available-on-cdnjs-reduce-your-supply-chain-risk
131
+ src.startsWith("https://cdnjs.cloudflare.com/polyfill/")) {
132
+ const featureQueryString = new URL(src).searchParams.get("features");
133
+ const featuresRequested = (featureQueryString ?? "").split(",");
134
+ const unwantedFeatures = featuresRequested.filter(
135
+ (feature) => NEXT_POLYFILLED_FEATURES.includes(feature)
136
+ );
137
+ if (unwantedFeatures.length > 0) {
138
+ context.report({
139
+ message: `No duplicate polyfills from Polyfill.io are allowed. ${unwantedFeatures.join(
140
+ ", "
141
+ )} ${unwantedFeatures.length > 1 ? "are" : "is"} already shipped with Next.js. See: ${url}`,
142
+ node
143
+ });
144
+ }
145
+ }
146
+ }
147
+ };
148
+ },
149
+ meta: {
150
+ docs: {
151
+ category: "HTML",
152
+ description: "Prevent duplicate polyfills from Polyfill.io.",
153
+ recommended: true,
154
+ url
155
+ },
156
+ schema: [],
157
+ type: "problem"
158
+ }
159
+ });
160
+ // Annotate the CommonJS export names for ESM import in node:
161
+ 0 && (module.exports = {
162
+ noUnwantedPolyfillio
163
+ });
164
+ //# sourceMappingURL=no-unwanted-polyfillio.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/rules/no-unwanted-polyfillio.ts","../../src/utils/define-rule.ts"],"sourcesContent":["import { defineRule } from \"../utils/define-rule.js\";\n\n// Keep in sync with next.js polyfills file : https://github.com/vercel/next.js/blob/master/packages/next-polyfill-nomodule/src/index.js\nconst NEXT_POLYFILLED_FEATURES = [\n \"Array.prototype.@@iterator\",\n \"Array.prototype.at\",\n \"Array.prototype.copyWithin\",\n \"Array.prototype.fill\",\n \"Array.prototype.find\",\n \"Array.prototype.findIndex\",\n \"Array.prototype.flatMap\",\n \"Array.prototype.flat\",\n \"Array.from\",\n \"Array.prototype.includes\",\n \"Array.of\",\n \"Function.prototype.name\",\n \"fetch\",\n \"Map\",\n \"Number.EPSILON\",\n \"Number.Epsilon\",\n \"Number.isFinite\",\n \"Number.isNaN\",\n \"Number.isInteger\",\n \"Number.isSafeInteger\",\n \"Number.MAX_SAFE_INTEGER\",\n \"Number.MIN_SAFE_INTEGER\",\n \"Number.parseFloat\",\n \"Number.parseInt\",\n \"Object.assign\",\n \"Object.entries\",\n \"Object.fromEntries\",\n \"Object.getOwnPropertyDescriptor\",\n \"Object.getOwnPropertyDescriptors\",\n \"Object.hasOwn\",\n \"Object.is\",\n \"Object.keys\",\n \"Object.values\",\n \"Reflect\",\n \"Set\",\n \"Symbol\",\n \"Symbol.asyncIterator\",\n \"String.prototype.codePointAt\",\n \"String.prototype.endsWith\",\n \"String.fromCodePoint\",\n \"String.prototype.includes\",\n \"String.prototype.@@iterator\",\n \"String.prototype.padEnd\",\n \"String.prototype.padStart\",\n \"String.prototype.repeat\",\n \"String.raw\",\n \"String.prototype.startsWith\",\n \"String.prototype.trimEnd\",\n \"String.prototype.trimStart\",\n \"URL\",\n \"URL.prototype.toJSON\",\n \"URLSearchParams\",\n \"WeakMap\",\n \"WeakSet\",\n \"Promise\",\n \"Promise.prototype.finally\",\n \"es2015\", // Should be covered by babel-preset-env instead.\n \"es2016\", // contains polyfilled 'Array.prototype.includes', 'String.prototype.padEnd' and 'String.prototype.padStart'\n \"es2017\", // contains polyfilled 'Object.entries', 'Object.getOwnPropertyDescriptors', 'Object.values', 'String.prototype.padEnd' and 'String.prototype.padStart'\n \"es2018\", // contains polyfilled 'Promise.prototype.finally' and ''Symbol.asyncIterator'\n \"es2019\", // Contains polyfilled 'Object.fromEntries' and polyfilled 'Array.prototype.flat', 'Array.prototype.flatMap', 'String.prototype.trimEnd' and 'String.prototype.trimStart'\n \"es5\", // Should be covered by babel-preset-env instead.\n \"es6\", // Should be covered by babel-preset-env instead.\n \"es7\", // contains polyfilled 'Array.prototype.includes', 'String.prototype.padEnd' and 'String.prototype.padStart'\n];\n\nconst url = \"https://nextjs.org/docs/messages/no-unwanted-polyfillio\";\n\n//------------------------------------------------------------------------------\n// Rule Definition\n//------------------------------------------------------------------------------\nexport const noUnwantedPolyfillio = defineRule({\n create: (context: any) => {\n let scriptImport: null | string = null;\n\n return {\n ImportDeclaration: (node: any) => {\n if (node.source && node.source.value === \"next/script\") {\n scriptImport = node.specifiers[0].local.name;\n }\n },\n JSXOpeningElement: (node: any) => {\n if (\n node.name &&\n node.name.name !== \"script\" &&\n node.name.name !== scriptImport\n ) {\n return;\n }\n if (node.attributes.length === 0) {\n return;\n }\n\n const srcNode = node.attributes.find(\n (attr: any) =>\n attr.type === \"JSXAttribute\" && attr.name.name === \"src\",\n );\n if (!srcNode || srcNode.value.type !== \"Literal\") {\n return;\n }\n const src = srcNode.value.value;\n if (\n src.startsWith(\"https://cdn.polyfill.io/v2/\") ||\n src.startsWith(\"https://polyfill.io/v3/\") ||\n // https://community.fastly.com/t/new-options-for-polyfill-io-users/2540\n src.startsWith(\"https://polyfill-fastly.net/\") ||\n src.startsWith(\"https://polyfill-fastly.io/\") ||\n // https://blog.cloudflare.com/polyfill-io-now-available-on-cdnjs-reduce-your-supply-chain-risk\n src.startsWith(\"https://cdnjs.cloudflare.com/polyfill/\")\n ) {\n const featureQueryString = new URL(src).searchParams.get(\"features\");\n const featuresRequested = (featureQueryString ?? \"\").split(\",\");\n const unwantedFeatures = featuresRequested.filter((feature) =>\n NEXT_POLYFILLED_FEATURES.includes(feature),\n );\n if (unwantedFeatures.length > 0) {\n context.report({\n message: `No duplicate polyfills from Polyfill.io are allowed. ${unwantedFeatures.join(\n \", \",\n )} ${\n unwantedFeatures.length > 1 ? \"are\" : \"is\"\n } already shipped with Next.js. See: ${url}`,\n node,\n });\n }\n }\n },\n };\n },\n\n meta: {\n docs: {\n category: \"HTML\",\n description: \"Prevent duplicate polyfills from Polyfill.io.\",\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;;;ADCtE,IAAM,2BAA2B;AAAA,EAC/B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA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AC,IACC,iBAAiB,SAAS,IAAI,QAAQ,IACxC,uCAAuC,GAAG;AAAA,cAC1C;AAAA,YACF,CAAC;AAAA,UACH;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAAA,EAEA,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,5 @@
1
+ import * as eslint from 'eslint';
2
+
3
+ declare const noUnwantedPolyfillio: eslint.Rule.RuleModule;
4
+
5
+ export { noUnwantedPolyfillio };
@@ -0,0 +1,5 @@
1
+ import * as eslint from 'eslint';
2
+
3
+ declare const noUnwantedPolyfillio: eslint.Rule.RuleModule;
4
+
5
+ export { noUnwantedPolyfillio };
@@ -0,0 +1,137 @@
1
+ // src/utils/define-rule.ts
2
+ var defineRule = (rule) => rule;
3
+
4
+ // src/rules/no-unwanted-polyfillio.ts
5
+ var NEXT_POLYFILLED_FEATURES = [
6
+ "Array.prototype.@@iterator",
7
+ "Array.prototype.at",
8
+ "Array.prototype.copyWithin",
9
+ "Array.prototype.fill",
10
+ "Array.prototype.find",
11
+ "Array.prototype.findIndex",
12
+ "Array.prototype.flatMap",
13
+ "Array.prototype.flat",
14
+ "Array.from",
15
+ "Array.prototype.includes",
16
+ "Array.of",
17
+ "Function.prototype.name",
18
+ "fetch",
19
+ "Map",
20
+ "Number.EPSILON",
21
+ "Number.Epsilon",
22
+ "Number.isFinite",
23
+ "Number.isNaN",
24
+ "Number.isInteger",
25
+ "Number.isSafeInteger",
26
+ "Number.MAX_SAFE_INTEGER",
27
+ "Number.MIN_SAFE_INTEGER",
28
+ "Number.parseFloat",
29
+ "Number.parseInt",
30
+ "Object.assign",
31
+ "Object.entries",
32
+ "Object.fromEntries",
33
+ "Object.getOwnPropertyDescriptor",
34
+ "Object.getOwnPropertyDescriptors",
35
+ "Object.hasOwn",
36
+ "Object.is",
37
+ "Object.keys",
38
+ "Object.values",
39
+ "Reflect",
40
+ "Set",
41
+ "Symbol",
42
+ "Symbol.asyncIterator",
43
+ "String.prototype.codePointAt",
44
+ "String.prototype.endsWith",
45
+ "String.fromCodePoint",
46
+ "String.prototype.includes",
47
+ "String.prototype.@@iterator",
48
+ "String.prototype.padEnd",
49
+ "String.prototype.padStart",
50
+ "String.prototype.repeat",
51
+ "String.raw",
52
+ "String.prototype.startsWith",
53
+ "String.prototype.trimEnd",
54
+ "String.prototype.trimStart",
55
+ "URL",
56
+ "URL.prototype.toJSON",
57
+ "URLSearchParams",
58
+ "WeakMap",
59
+ "WeakSet",
60
+ "Promise",
61
+ "Promise.prototype.finally",
62
+ "es2015",
63
+ // Should be covered by babel-preset-env instead.
64
+ "es2016",
65
+ // contains polyfilled 'Array.prototype.includes', 'String.prototype.padEnd' and 'String.prototype.padStart'
66
+ "es2017",
67
+ // contains polyfilled 'Object.entries', 'Object.getOwnPropertyDescriptors', 'Object.values', 'String.prototype.padEnd' and 'String.prototype.padStart'
68
+ "es2018",
69
+ // contains polyfilled 'Promise.prototype.finally' and ''Symbol.asyncIterator'
70
+ "es2019",
71
+ // Contains polyfilled 'Object.fromEntries' and polyfilled 'Array.prototype.flat', 'Array.prototype.flatMap', 'String.prototype.trimEnd' and 'String.prototype.trimStart'
72
+ "es5",
73
+ // Should be covered by babel-preset-env instead.
74
+ "es6",
75
+ // Should be covered by babel-preset-env instead.
76
+ "es7"
77
+ // contains polyfilled 'Array.prototype.includes', 'String.prototype.padEnd' and 'String.prototype.padStart'
78
+ ];
79
+ var url = "https://nextjs.org/docs/messages/no-unwanted-polyfillio";
80
+ var noUnwantedPolyfillio = defineRule({
81
+ create: (context) => {
82
+ let scriptImport = null;
83
+ return {
84
+ ImportDeclaration: (node) => {
85
+ if (node.source && node.source.value === "next/script") {
86
+ scriptImport = node.specifiers[0].local.name;
87
+ }
88
+ },
89
+ JSXOpeningElement: (node) => {
90
+ if (node.name && node.name.name !== "script" && node.name.name !== scriptImport) {
91
+ return;
92
+ }
93
+ if (node.attributes.length === 0) {
94
+ return;
95
+ }
96
+ const srcNode = node.attributes.find(
97
+ (attr) => attr.type === "JSXAttribute" && attr.name.name === "src"
98
+ );
99
+ if (!srcNode || srcNode.value.type !== "Literal") {
100
+ return;
101
+ }
102
+ const src = srcNode.value.value;
103
+ if (src.startsWith("https://cdn.polyfill.io/v2/") || src.startsWith("https://polyfill.io/v3/") || // https://community.fastly.com/t/new-options-for-polyfill-io-users/2540
104
+ src.startsWith("https://polyfill-fastly.net/") || src.startsWith("https://polyfill-fastly.io/") || // https://blog.cloudflare.com/polyfill-io-now-available-on-cdnjs-reduce-your-supply-chain-risk
105
+ src.startsWith("https://cdnjs.cloudflare.com/polyfill/")) {
106
+ const featureQueryString = new URL(src).searchParams.get("features");
107
+ const featuresRequested = (featureQueryString ?? "").split(",");
108
+ const unwantedFeatures = featuresRequested.filter(
109
+ (feature) => NEXT_POLYFILLED_FEATURES.includes(feature)
110
+ );
111
+ if (unwantedFeatures.length > 0) {
112
+ context.report({
113
+ message: `No duplicate polyfills from Polyfill.io are allowed. ${unwantedFeatures.join(
114
+ ", "
115
+ )} ${unwantedFeatures.length > 1 ? "are" : "is"} already shipped with Next.js. See: ${url}`,
116
+ node
117
+ });
118
+ }
119
+ }
120
+ }
121
+ };
122
+ },
123
+ meta: {
124
+ docs: {
125
+ category: "HTML",
126
+ description: "Prevent duplicate polyfills from Polyfill.io.",
127
+ recommended: true,
128
+ url
129
+ },
130
+ schema: [],
131
+ type: "problem"
132
+ }
133
+ });
134
+ export {
135
+ noUnwantedPolyfillio
136
+ };
137
+ //# sourceMappingURL=no-unwanted-polyfillio.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/utils/define-rule.ts","../../src/rules/no-unwanted-polyfillio.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\n// Keep in sync with next.js polyfills file : https://github.com/vercel/next.js/blob/master/packages/next-polyfill-nomodule/src/index.js\nconst NEXT_POLYFILLED_FEATURES = [\n \"Array.prototype.@@iterator\",\n \"Array.prototype.at\",\n \"Array.prototype.copyWithin\",\n \"Array.prototype.fill\",\n \"Array.prototype.find\",\n \"Array.prototype.findIndex\",\n \"Array.prototype.flatMap\",\n \"Array.prototype.flat\",\n \"Array.from\",\n \"Array.prototype.includes\",\n \"Array.of\",\n \"Function.prototype.name\",\n \"fetch\",\n \"Map\",\n \"Number.EPSILON\",\n \"Number.Epsilon\",\n \"Number.isFinite\",\n \"Number.isNaN\",\n \"Number.isInteger\",\n \"Number.isSafeInteger\",\n \"Number.MAX_SAFE_INTEGER\",\n \"Number.MIN_SAFE_INTEGER\",\n \"Number.parseFloat\",\n \"Number.parseInt\",\n \"Object.assign\",\n \"Object.entries\",\n \"Object.fromEntries\",\n \"Object.getOwnPropertyDescriptor\",\n \"Object.getOwnPropertyDescriptors\",\n \"Object.hasOwn\",\n \"Object.is\",\n \"Object.keys\",\n \"Object.values\",\n \"Reflect\",\n \"Set\",\n \"Symbol\",\n \"Symbol.asyncIterator\",\n \"String.prototype.codePointAt\",\n \"String.prototype.endsWith\",\n \"String.fromCodePoint\",\n \"String.prototype.includes\",\n \"String.prototype.@@iterator\",\n \"String.prototype.padEnd\",\n \"String.prototype.padStart\",\n \"String.prototype.repeat\",\n \"String.raw\",\n \"String.prototype.startsWith\",\n \"String.prototype.trimEnd\",\n \"String.prototype.trimStart\",\n \"URL\",\n \"URL.prototype.toJSON\",\n \"URLSearchParams\",\n \"WeakMap\",\n \"WeakSet\",\n \"Promise\",\n \"Promise.prototype.finally\",\n \"es2015\", // Should be covered by babel-preset-env instead.\n \"es2016\", // contains polyfilled 'Array.prototype.includes', 'String.prototype.padEnd' and 'String.prototype.padStart'\n \"es2017\", // contains polyfilled 'Object.entries', 'Object.getOwnPropertyDescriptors', 'Object.values', 'String.prototype.padEnd' and 'String.prototype.padStart'\n \"es2018\", // contains polyfilled 'Promise.prototype.finally' and ''Symbol.asyncIterator'\n \"es2019\", // Contains polyfilled 'Object.fromEntries' and polyfilled 'Array.prototype.flat', 'Array.prototype.flatMap', 'String.prototype.trimEnd' and 'String.prototype.trimStart'\n \"es5\", // Should be covered by babel-preset-env instead.\n \"es6\", // Should be covered by babel-preset-env instead.\n \"es7\", // contains polyfilled 'Array.prototype.includes', 'String.prototype.padEnd' and 'String.prototype.padStart'\n];\n\nconst url = \"https://nextjs.org/docs/messages/no-unwanted-polyfillio\";\n\n//------------------------------------------------------------------------------\n// Rule Definition\n//------------------------------------------------------------------------------\nexport const noUnwantedPolyfillio = defineRule({\n create: (context: any) => {\n let scriptImport: null | string = null;\n\n return {\n ImportDeclaration: (node: any) => {\n if (node.source && node.source.value === \"next/script\") {\n scriptImport = node.specifiers[0].local.name;\n }\n },\n JSXOpeningElement: (node: any) => {\n if (\n node.name &&\n node.name.name !== \"script\" &&\n node.name.name !== scriptImport\n ) {\n return;\n }\n if (node.attributes.length === 0) {\n return;\n }\n\n const srcNode = node.attributes.find(\n (attr: any) =>\n attr.type === \"JSXAttribute\" && attr.name.name === \"src\",\n );\n if (!srcNode || srcNode.value.type !== \"Literal\") {\n return;\n }\n const src = srcNode.value.value;\n if (\n src.startsWith(\"https://cdn.polyfill.io/v2/\") ||\n src.startsWith(\"https://polyfill.io/v3/\") ||\n // https://community.fastly.com/t/new-options-for-polyfill-io-users/2540\n src.startsWith(\"https://polyfill-fastly.net/\") ||\n src.startsWith(\"https://polyfill-fastly.io/\") ||\n // https://blog.cloudflare.com/polyfill-io-now-available-on-cdnjs-reduce-your-supply-chain-risk\n src.startsWith(\"https://cdnjs.cloudflare.com/polyfill/\")\n ) {\n const featureQueryString = new URL(src).searchParams.get(\"features\");\n const featuresRequested = (featureQueryString ?? \"\").split(\",\");\n const unwantedFeatures = featuresRequested.filter((feature) =>\n NEXT_POLYFILLED_FEATURES.includes(feature),\n );\n if (unwantedFeatures.length > 0) {\n context.report({\n message: `No duplicate polyfills from Polyfill.io are allowed. ${unwantedFeatures.join(\n \", \",\n )} ${\n unwantedFeatures.length > 1 ? \"are\" : \"is\"\n } already shipped with Next.js. See: ${url}`,\n node,\n });\n }\n }\n },\n };\n },\n\n meta: {\n docs: {\n category: \"HTML\",\n description: \"Prevent duplicate polyfills from Polyfill.io.\",\n recommended: true,\n url,\n },\n schema: [],\n type: \"problem\",\n },\n});\n"],"mappings":";AAEO,IAAM,aAAa,CAAC,SAA2C;;;ACCtE,IAAM,2BAA2B;AAAA,EAC/B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AACF;AAEA,IAAM,MAAM;AAKL,IAAM,uBAAuB,WAAW;AAAA,EAC7C,QAAQ,CAAC,YAAiB;AACxB,QAAI,eAA8B;AAElC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b;AAAA,IACF;AAAA,IACA,QAAQ,CAAC;AAAA,IACT,MAAM;AAAA,EACR;AACF,CAAC;","names":[]}
@@ -0,0 +1,31 @@
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/utils/define-rule.ts
21
+ var define_rule_exports = {};
22
+ __export(define_rule_exports, {
23
+ defineRule: () => defineRule
24
+ });
25
+ module.exports = __toCommonJS(define_rule_exports);
26
+ var defineRule = (rule) => rule;
27
+ // Annotate the CommonJS export names for ESM import in node:
28
+ 0 && (module.exports = {
29
+ defineRule
30
+ });
31
+ //# sourceMappingURL=define-rule.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/utils/define-rule.ts"],"sourcesContent":["import type { Rule } from \"eslint\";\n\nexport const defineRule = (rule: Rule.RuleModule): Rule.RuleModule => rule;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEO,IAAM,aAAa,CAAC,SAA2C;","names":[]}
@@ -0,0 +1,5 @@
1
+ import { Rule } from 'eslint';
2
+
3
+ declare const defineRule: (rule: Rule.RuleModule) => Rule.RuleModule;
4
+
5
+ export { defineRule };
@@ -0,0 +1,5 @@
1
+ import { Rule } from 'eslint';
2
+
3
+ declare const defineRule: (rule: Rule.RuleModule) => Rule.RuleModule;
4
+
5
+ export { defineRule };
@@ -0,0 +1,6 @@
1
+ // src/utils/define-rule.ts
2
+ var defineRule = (rule) => rule;
3
+ export {
4
+ defineRule
5
+ };
6
+ //# sourceMappingURL=define-rule.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/utils/define-rule.ts"],"sourcesContent":["import type { Rule } from \"eslint\";\n\nexport const defineRule = (rule: Rule.RuleModule): Rule.RuleModule => rule;\n"],"mappings":";AAEO,IAAM,aAAa,CAAC,SAA2C;","names":[]}
@@ -0,0 +1,60 @@
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/utils/get-root-dirs.ts
31
+ var get_root_dirs_exports = {};
32
+ __export(get_root_dirs_exports, {
33
+ getRootDirs: () => getRootDirs
34
+ });
35
+ module.exports = __toCommonJS(get_root_dirs_exports);
36
+ var import_fast_glob = __toESM(require("fast-glob"), 1);
37
+ var processRootDir = (rootDir) => {
38
+ return import_fast_glob.default.globSync(rootDir.replaceAll("\\", "/"), {
39
+ onlyDirectories: true
40
+ });
41
+ };
42
+ var getRootDirs = (context) => {
43
+ let rootDirs = [context.cwd];
44
+ const nextSettings = (
45
+ // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
46
+ context.settings.next || {}
47
+ );
48
+ const rootDir = nextSettings.rootDir;
49
+ if (typeof rootDir === "string") {
50
+ rootDirs = processRootDir(rootDir);
51
+ } else if (Array.isArray(rootDir)) {
52
+ rootDirs = rootDir.map((dir) => typeof dir === "string" ? processRootDir(dir) : []).flat();
53
+ }
54
+ return rootDirs;
55
+ };
56
+ // Annotate the CommonJS export names for ESM import in node:
57
+ 0 && (module.exports = {
58
+ getRootDirs
59
+ });
60
+ //# sourceMappingURL=get-root-dirs.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/utils/get-root-dirs.ts"],"sourcesContent":["import type { Rule } from \"eslint\";\n\nimport fastGlob from \"fast-glob\";\n\n/**\n * Process a Next.js root directory glob.\n */\nconst processRootDir = (rootDir: string): string[] => {\n return fastGlob.globSync(rootDir.replaceAll(\"\\\\\", \"/\"), {\n onlyDirectories: true,\n });\n};\n\n/**\n * Gets one or more Root, returns an array of root directories.\n */\nexport const getRootDirs = (context: Rule.RuleContext) => {\n let rootDirs = [context.cwd];\n\n const nextSettings: { rootDir?: string | string[] } =\n // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing\n context.settings.next || {};\n const rootDir = nextSettings.rootDir;\n\n if (typeof rootDir === \"string\") {\n rootDirs = processRootDir(rootDir);\n } else if (Array.isArray(rootDir)) {\n rootDirs = rootDir\n .map((dir) => (typeof dir === \"string\" ? processRootDir(dir) : []))\n .flat();\n }\n\n return rootDirs;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,uBAAqB;AAKrB,IAAM,iBAAiB,CAAC,YAA8B;AACpD,SAAO,iBAAAA,QAAS,SAAS,QAAQ,WAAW,MAAM,GAAG,GAAG;AAAA,IACtD,iBAAiB;AAAA,EACnB,CAAC;AACH;AAKO,IAAM,cAAc,CAAC,YAA8B;AACxD,MAAI,WAAW,CAAC,QAAQ,GAAG;AAE3B,QAAM;AAAA;AAAA,IAEJ,QAAQ,SAAS,QAAQ,CAAC;AAAA;AAC5B,QAAM,UAAU,aAAa;AAE7B,MAAI,OAAO,YAAY,UAAU;AAC/B,eAAW,eAAe,OAAO;AAAA,EACnC,WAAW,MAAM,QAAQ,OAAO,GAAG;AACjC,eAAW,QACR,IAAI,CAAC,QAAS,OAAO,QAAQ,WAAW,eAAe,GAAG,IAAI,CAAC,CAAE,EACjE,KAAK;AAAA,EACV;AAEA,SAAO;AACT;","names":["fastGlob"]}
@@ -0,0 +1,8 @@
1
+ import { Rule } from 'eslint';
2
+
3
+ /**
4
+ * Gets one or more Root, returns an array of root directories.
5
+ */
6
+ declare const getRootDirs: (context: Rule.RuleContext) => string[];
7
+
8
+ export { getRootDirs };
@@ -0,0 +1,8 @@
1
+ import { Rule } from 'eslint';
2
+
3
+ /**
4
+ * Gets one or more Root, returns an array of root directories.
5
+ */
6
+ declare const getRootDirs: (context: Rule.RuleContext) => string[];
7
+
8
+ export { getRootDirs };
@@ -0,0 +1,25 @@
1
+ // src/utils/get-root-dirs.ts
2
+ import fastGlob from "fast-glob";
3
+ var processRootDir = (rootDir) => {
4
+ return fastGlob.globSync(rootDir.replaceAll("\\", "/"), {
5
+ onlyDirectories: true
6
+ });
7
+ };
8
+ var getRootDirs = (context) => {
9
+ let rootDirs = [context.cwd];
10
+ const nextSettings = (
11
+ // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
12
+ context.settings.next || {}
13
+ );
14
+ const rootDir = nextSettings.rootDir;
15
+ if (typeof rootDir === "string") {
16
+ rootDirs = processRootDir(rootDir);
17
+ } else if (Array.isArray(rootDir)) {
18
+ rootDirs = rootDir.map((dir) => typeof dir === "string" ? processRootDir(dir) : []).flat();
19
+ }
20
+ return rootDirs;
21
+ };
22
+ export {
23
+ getRootDirs
24
+ };
25
+ //# sourceMappingURL=get-root-dirs.js.map