eslint-plugin-nextjs 0.1.1 → 1.0.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 (158) hide show
  1. package/README.md +13 -13
  2. package/dist/index.d.ts +4 -39
  3. package/dist/index.js +403 -274
  4. package/dist/index.js.map +1 -1
  5. package/package.json +15 -10
  6. package/dist/index.cjs +0 -1494
  7. package/dist/index.cjs.map +0 -1
  8. package/dist/index.d.cts +0 -43
  9. package/dist/rules/google-font-display.cjs +0 -119
  10. package/dist/rules/google-font-display.cjs.map +0 -1
  11. package/dist/rules/google-font-display.d.cts +0 -8
  12. package/dist/rules/google-font-display.d.ts +0 -8
  13. package/dist/rules/google-font-display.js +0 -92
  14. package/dist/rules/google-font-display.js.map +0 -1
  15. package/dist/rules/google-font-preconnect.cjs +0 -109
  16. package/dist/rules/google-font-preconnect.cjs.map +0 -1
  17. package/dist/rules/google-font-preconnect.d.cts +0 -5
  18. package/dist/rules/google-font-preconnect.d.ts +0 -5
  19. package/dist/rules/google-font-preconnect.js +0 -82
  20. package/dist/rules/google-font-preconnect.js.map +0 -1
  21. package/dist/rules/inline-script-id.cjs +0 -94
  22. package/dist/rules/inline-script-id.cjs.map +0 -1
  23. package/dist/rules/inline-script-id.d.cts +0 -5
  24. package/dist/rules/inline-script-id.d.ts +0 -5
  25. package/dist/rules/inline-script-id.js +0 -67
  26. package/dist/rules/inline-script-id.js.map +0 -1
  27. package/dist/rules/next-script-for-ga.cjs +0 -129
  28. package/dist/rules/next-script-for-ga.cjs.map +0 -1
  29. package/dist/rules/next-script-for-ga.d.cts +0 -5
  30. package/dist/rules/next-script-for-ga.d.ts +0 -5
  31. package/dist/rules/next-script-for-ga.js +0 -102
  32. package/dist/rules/next-script-for-ga.js.map +0 -1
  33. package/dist/rules/no-assign-module-variable.cjs +0 -64
  34. package/dist/rules/no-assign-module-variable.cjs.map +0 -1
  35. package/dist/rules/no-assign-module-variable.d.cts +0 -5
  36. package/dist/rules/no-assign-module-variable.d.ts +0 -5
  37. package/dist/rules/no-assign-module-variable.js +0 -37
  38. package/dist/rules/no-assign-module-variable.js.map +0 -1
  39. package/dist/rules/no-async-client-component.cjs +0 -99
  40. package/dist/rules/no-async-client-component.cjs.map +0 -1
  41. package/dist/rules/no-async-client-component.d.cts +0 -5
  42. package/dist/rules/no-async-client-component.d.ts +0 -5
  43. package/dist/rules/no-async-client-component.js +0 -72
  44. package/dist/rules/no-async-client-component.js.map +0 -1
  45. package/dist/rules/no-before-interactive-script-outside-document.cjs +0 -94
  46. package/dist/rules/no-before-interactive-script-outside-document.cjs.map +0 -1
  47. package/dist/rules/no-before-interactive-script-outside-document.d.cts +0 -5
  48. package/dist/rules/no-before-interactive-script-outside-document.d.ts +0 -5
  49. package/dist/rules/no-before-interactive-script-outside-document.js +0 -59
  50. package/dist/rules/no-before-interactive-script-outside-document.js.map +0 -1
  51. package/dist/rules/no-css-tags.cjs +0 -70
  52. package/dist/rules/no-css-tags.cjs.map +0 -1
  53. package/dist/rules/no-css-tags.d.cts +0 -5
  54. package/dist/rules/no-css-tags.d.ts +0 -5
  55. package/dist/rules/no-css-tags.js +0 -43
  56. package/dist/rules/no-css-tags.js.map +0 -1
  57. package/dist/rules/no-document-import-in-page.cjs +0 -74
  58. package/dist/rules/no-document-import-in-page.cjs.map +0 -1
  59. package/dist/rules/no-document-import-in-page.d.cts +0 -5
  60. package/dist/rules/no-document-import-in-page.d.ts +0 -5
  61. package/dist/rules/no-document-import-in-page.js +0 -39
  62. package/dist/rules/no-document-import-in-page.js.map +0 -1
  63. package/dist/rules/no-duplicate-head.cjs +0 -87
  64. package/dist/rules/no-duplicate-head.cjs.map +0 -1
  65. package/dist/rules/no-duplicate-head.d.cts +0 -5
  66. package/dist/rules/no-duplicate-head.d.ts +0 -5
  67. package/dist/rules/no-duplicate-head.js +0 -60
  68. package/dist/rules/no-duplicate-head.js.map +0 -1
  69. package/dist/rules/no-head-element.cjs +0 -76
  70. package/dist/rules/no-head-element.cjs.map +0 -1
  71. package/dist/rules/no-head-element.d.cts +0 -5
  72. package/dist/rules/no-head-element.d.ts +0 -5
  73. package/dist/rules/no-head-element.js +0 -41
  74. package/dist/rules/no-head-element.js.map +0 -1
  75. package/dist/rules/no-head-import-in-document.cjs +0 -76
  76. package/dist/rules/no-head-import-in-document.cjs.map +0 -1
  77. package/dist/rules/no-head-import-in-document.d.cts +0 -5
  78. package/dist/rules/no-head-import-in-document.d.ts +0 -5
  79. package/dist/rules/no-head-import-in-document.js +0 -41
  80. package/dist/rules/no-head-import-in-document.js.map +0 -1
  81. package/dist/rules/no-html-link-for-pages.cjs +0 -302
  82. package/dist/rules/no-html-link-for-pages.cjs.map +0 -1
  83. package/dist/rules/no-html-link-for-pages.d.cts +0 -5
  84. package/dist/rules/no-html-link-for-pages.d.ts +0 -5
  85. package/dist/rules/no-html-link-for-pages.js +0 -267
  86. package/dist/rules/no-html-link-for-pages.js.map +0 -1
  87. package/dist/rules/no-img-element.cjs +0 -83
  88. package/dist/rules/no-img-element.cjs.map +0 -1
  89. package/dist/rules/no-img-element.d.cts +0 -5
  90. package/dist/rules/no-img-element.d.ts +0 -5
  91. package/dist/rules/no-img-element.js +0 -48
  92. package/dist/rules/no-img-element.js.map +0 -1
  93. package/dist/rules/no-page-custom-font.cjs +0 -184
  94. package/dist/rules/no-page-custom-font.cjs.map +0 -1
  95. package/dist/rules/no-page-custom-font.d.cts +0 -5
  96. package/dist/rules/no-page-custom-font.d.ts +0 -5
  97. package/dist/rules/no-page-custom-font.js +0 -159
  98. package/dist/rules/no-page-custom-font.js.map +0 -1
  99. package/dist/rules/no-script-component-in-head.cjs +0 -74
  100. package/dist/rules/no-script-component-in-head.cjs.map +0 -1
  101. package/dist/rules/no-script-component-in-head.d.cts +0 -5
  102. package/dist/rules/no-script-component-in-head.d.ts +0 -5
  103. package/dist/rules/no-script-component-in-head.js +0 -47
  104. package/dist/rules/no-script-component-in-head.js.map +0 -1
  105. package/dist/rules/no-styled-jsx-in-document.cjs +0 -78
  106. package/dist/rules/no-styled-jsx-in-document.cjs.map +0 -1
  107. package/dist/rules/no-styled-jsx-in-document.d.cts +0 -5
  108. package/dist/rules/no-styled-jsx-in-document.d.ts +0 -5
  109. package/dist/rules/no-styled-jsx-in-document.js +0 -43
  110. package/dist/rules/no-styled-jsx-in-document.js.map +0 -1
  111. package/dist/rules/no-sync-scripts.cjs +0 -64
  112. package/dist/rules/no-sync-scripts.cjs.map +0 -1
  113. package/dist/rules/no-sync-scripts.d.cts +0 -5
  114. package/dist/rules/no-sync-scripts.d.ts +0 -5
  115. package/dist/rules/no-sync-scripts.js +0 -37
  116. package/dist/rules/no-sync-scripts.js.map +0 -1
  117. package/dist/rules/no-title-in-document-head.cjs +0 -78
  118. package/dist/rules/no-title-in-document-head.cjs.map +0 -1
  119. package/dist/rules/no-title-in-document-head.d.cts +0 -5
  120. package/dist/rules/no-title-in-document-head.d.ts +0 -5
  121. package/dist/rules/no-title-in-document-head.js +0 -51
  122. package/dist/rules/no-title-in-document-head.js.map +0 -1
  123. package/dist/rules/no-typos.cjs +0 -133
  124. package/dist/rules/no-typos.cjs.map +0 -1
  125. package/dist/rules/no-typos.d.cts +0 -5
  126. package/dist/rules/no-typos.d.ts +0 -5
  127. package/dist/rules/no-typos.js +0 -98
  128. package/dist/rules/no-typos.js.map +0 -1
  129. package/dist/rules/no-unwanted-polyfillio.cjs +0 -164
  130. package/dist/rules/no-unwanted-polyfillio.cjs.map +0 -1
  131. package/dist/rules/no-unwanted-polyfillio.d.cts +0 -5
  132. package/dist/rules/no-unwanted-polyfillio.d.ts +0 -5
  133. package/dist/rules/no-unwanted-polyfillio.js +0 -137
  134. package/dist/rules/no-unwanted-polyfillio.js.map +0 -1
  135. package/dist/utils/define-rule.cjs +0 -31
  136. package/dist/utils/define-rule.cjs.map +0 -1
  137. package/dist/utils/define-rule.d.cts +0 -5
  138. package/dist/utils/define-rule.d.ts +0 -5
  139. package/dist/utils/define-rule.js +0 -6
  140. package/dist/utils/define-rule.js.map +0 -1
  141. package/dist/utils/get-root-dirs.cjs +0 -60
  142. package/dist/utils/get-root-dirs.cjs.map +0 -1
  143. package/dist/utils/get-root-dirs.d.cts +0 -8
  144. package/dist/utils/get-root-dirs.d.ts +0 -8
  145. package/dist/utils/get-root-dirs.js +0 -25
  146. package/dist/utils/get-root-dirs.js.map +0 -1
  147. package/dist/utils/node-attributes.cjs +0 -67
  148. package/dist/utils/node-attributes.cjs.map +0 -1
  149. package/dist/utils/node-attributes.d.cts +0 -15
  150. package/dist/utils/node-attributes.d.ts +0 -15
  151. package/dist/utils/node-attributes.js +0 -46
  152. package/dist/utils/node-attributes.js.map +0 -1
  153. package/dist/utils/url.cjs +0 -167
  154. package/dist/utils/url.cjs.map +0 -1
  155. package/dist/utils/url.d.cts +0 -35
  156. package/dist/utils/url.d.ts +0 -35
  157. package/dist/utils/url.js +0 -128
  158. package/dist/utils/url.js.map +0 -1
@@ -1,37 +0,0 @@
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
@@ -1 +0,0 @@
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":[]}
@@ -1,78 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // src/rules/no-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
@@ -1 +0,0 @@
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":[]}
@@ -1,5 +0,0 @@
1
- import * as eslint from 'eslint';
2
-
3
- declare const noTitleInDocumentHead: eslint.Rule.RuleModule;
4
-
5
- export { noTitleInDocumentHead };
@@ -1,5 +0,0 @@
1
- import * as eslint from 'eslint';
2
-
3
- declare const noTitleInDocumentHead: eslint.Rule.RuleModule;
4
-
5
- export { noTitleInDocumentHead };
@@ -1,51 +0,0 @@
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
@@ -1 +0,0 @@
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":[]}
@@ -1,133 +0,0 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
- var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
19
- };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
-
30
- // src/rules/no-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
@@ -1 +0,0 @@
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,CA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AAK,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":[]}
@@ -1,5 +0,0 @@
1
- import * as eslint from 'eslint';
2
-
3
- declare const noTypos: eslint.Rule.RuleModule;
4
-
5
- export { noTypos };
@@ -1,5 +0,0 @@
1
- import * as eslint from 'eslint';
2
-
3
- declare const noTypos: eslint.Rule.RuleModule;
4
-
5
- export { noTypos };
@@ -1,98 +0,0 @@
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
@@ -1 +0,0 @@
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: R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W,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":[]}
@@ -1,164 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // src/rules/no-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
@@ -1 +0,0 @@
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,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,WAAO;AAAA,MACL,mBAAmB,CAAC,SAAc;AAChC,YAAI,KAAK,UAAU,KAAK,OAAO,UAAU,eAAe;AACtD,yBAAe,KAAK,WAAW,CAAC,EAAE,MAAM;AAAA,QAC1C;AAAA,MACF;AAAA,MACA,mBAAmB,CAAC,SAAc;AAChC,YAC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