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,102 +0,0 @@
1
- // src/utils/define-rule.ts
2
- var defineRule = (rule) => rule;
3
-
4
- // src/utils/node-attributes.ts
5
- var NodeAttributes = class {
6
- attributes;
7
- constructor(ASTnode) {
8
- this.attributes = {};
9
- ASTnode.attributes.forEach((attribute) => {
10
- if (!attribute.type || attribute.type !== "JSXAttribute") {
11
- return;
12
- }
13
- if (attribute.value) {
14
- const value = typeof attribute.value.value === "string" ? attribute.value.value : typeof attribute.value.expression?.value !== "undefined" ? attribute.value.expression.value : attribute.value.expression?.properties;
15
- this.attributes[attribute.name.name] = {
16
- hasValue: true,
17
- value
18
- };
19
- } else {
20
- this.attributes[attribute.name.name] = {
21
- hasValue: false
22
- };
23
- }
24
- });
25
- }
26
- has(attrName) {
27
- return Boolean(this.attributes[attrName]);
28
- }
29
- hasAny() {
30
- return Boolean(Object.keys(this.attributes).length);
31
- }
32
- hasValue(attrName) {
33
- return Boolean(this.attributes[attrName]?.hasValue);
34
- }
35
- value(attrName) {
36
- const attr = this.attributes[attrName];
37
- if (!attr) {
38
- return true;
39
- }
40
- if ("hasValue" in attr && attr.hasValue) {
41
- return attr.value;
42
- }
43
- return void 0;
44
- }
45
- };
46
-
47
- // src/rules/next-script-for-ga.ts
48
- var SUPPORTED_SRCS = [
49
- "www.google-analytics.com/analytics.js",
50
- "www.googletagmanager.com/gtag/js"
51
- ];
52
- var SUPPORTED_HTML_CONTENT_URLS = [
53
- "www.google-analytics.com/analytics.js",
54
- "www.googletagmanager.com/gtm.js"
55
- ];
56
- var description = "Prefer `next/script` component when using the inline script for Google Analytics.";
57
- var url = "https://nextjs.org/docs/messages/next-script-for-ga";
58
- var ERROR_MSG = `${description} See: ${url}`;
59
- var containsStr = (str, strList) => {
60
- return strList.some((s) => str.includes(s));
61
- };
62
- var nextScriptForGa = defineRule({
63
- create: (context) => ({
64
- JSXOpeningElement: (node) => {
65
- if (node.name.name !== "script") {
66
- return;
67
- }
68
- if (node.attributes.length === 0) {
69
- return;
70
- }
71
- const attributes = new NodeAttributes(node);
72
- if (typeof attributes.value("src") === "string" && containsStr(attributes.value("src"), SUPPORTED_SRCS)) {
73
- return context.report({
74
- message: ERROR_MSG,
75
- node
76
- });
77
- }
78
- if (attributes.value("dangerouslySetInnerHTML") && attributes.value("dangerouslySetInnerHTML").length > 0) {
79
- const htmlContent = attributes.value("dangerouslySetInnerHTML")[0].value.quasis?.[0].value.raw;
80
- if (htmlContent && containsStr(htmlContent, SUPPORTED_HTML_CONTENT_URLS)) {
81
- context.report({
82
- message: ERROR_MSG,
83
- node
84
- });
85
- }
86
- }
87
- }
88
- }),
89
- meta: {
90
- docs: {
91
- description,
92
- recommended: true,
93
- url
94
- },
95
- schema: [],
96
- type: "problem"
97
- }
98
- });
99
- export {
100
- nextScriptForGa
101
- };
102
- //# sourceMappingURL=next-script-for-ga.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/utils/define-rule.ts","../../src/utils/node-attributes.ts","../../src/rules/next-script-for-ga.ts"],"sourcesContent":["import type { Rule } from \"eslint\";\n\nexport const defineRule = (rule: Rule.RuleModule): Rule.RuleModule => rule;\n","// Return attributes and values of a node in a convenient way:\n/* example: \n <ExampleElement attr1=\"15\" attr2>\n { attr1: {\n hasValue: true,\n value: 15\n },\n attr2: {\n hasValue: false\n }\nInclusion of hasValue is in case an eslint rule cares about boolean values\nexplicitly assigned to attribute vs the attribute being used as a flag\n*/\nexport default class NodeAttributes {\n attributes: Record<\n string,\n | {\n hasValue: true;\n value: any;\n }\n | {\n hasValue?: false;\n }\n >;\n\n constructor(ASTnode: any) {\n this.attributes = {};\n ASTnode.attributes.forEach((attribute: any) => {\n if (!attribute.type || attribute.type !== \"JSXAttribute\") {\n return;\n }\n\n if (attribute.value) {\n // hasValue\n const value =\n typeof attribute.value.value === \"string\" ? attribute.value.value\n : typeof attribute.value.expression?.value !== \"undefined\" ?\n attribute.value.expression.value\n : attribute.value.expression?.properties;\n\n this.attributes[attribute.name.name] = {\n hasValue: true,\n value,\n };\n } else {\n this.attributes[attribute.name.name] = {\n hasValue: false,\n };\n }\n });\n }\n\n has(attrName: string): boolean {\n return Boolean(this.attributes[attrName]);\n }\n\n hasAny(): boolean {\n return Boolean(Object.keys(this.attributes).length);\n }\n\n hasValue(attrName: string): boolean {\n return Boolean(this.attributes[attrName]?.hasValue);\n }\n\n value(attrName: string): any {\n const attr = this.attributes[attrName];\n\n if (!attr) {\n return true;\n }\n\n if (\"hasValue\" in attr && attr.hasValue) {\n return attr.value;\n }\n\n return undefined;\n }\n}\n","import { defineRule } from \"../utils/define-rule.js\";\nimport NodeAttributes from \"../utils/node-attributes.js\";\n\nconst SUPPORTED_SRCS = [\n \"www.google-analytics.com/analytics.js\",\n \"www.googletagmanager.com/gtag/js\",\n];\nconst SUPPORTED_HTML_CONTENT_URLS = [\n \"www.google-analytics.com/analytics.js\",\n \"www.googletagmanager.com/gtm.js\",\n];\nconst description =\n \"Prefer `next/script` component when using the inline script for Google Analytics.\";\nconst url = \"https://nextjs.org/docs/messages/next-script-for-ga\";\nconst ERROR_MSG = `${description} See: ${url}`;\n\n// Check if one of the items in the list is a substring of the passed string\nconst containsStr = (str: string, strList: string[]) => {\n return strList.some((s) => str.includes(s));\n};\n\nexport const nextScriptForGa = 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 attributes = new NodeAttributes(node);\n\n // Check if the Alternative async tag is being used to add GA.\n // https://developers.google.com/analytics/devguides/collection/analyticsjs#alternative_async_tag\n // https://developers.google.com/analytics/devguides/collection/gtagjs\n if (\n typeof attributes.value(\"src\") === \"string\" &&\n containsStr(attributes.value(\"src\"), SUPPORTED_SRCS)\n ) {\n return context.report({\n message: ERROR_MSG,\n node,\n });\n }\n\n // Check if inline script is being used to add GA.\n // https://developers.google.com/analytics/devguides/collection/analyticsjs#the_google_analytics_tag\n // https://developers.google.com/tag-manager/quickstart\n if (\n attributes.value(\"dangerouslySetInnerHTML\") &&\n attributes.value(\"dangerouslySetInnerHTML\").length > 0\n ) {\n const htmlContent = attributes.value(\"dangerouslySetInnerHTML\")[0].value\n .quasis?.[0].value.raw;\n if (\n htmlContent &&\n containsStr(htmlContent, SUPPORTED_HTML_CONTENT_URLS)\n ) {\n context.report({\n message: ERROR_MSG,\n node,\n });\n }\n }\n },\n }),\n meta: {\n docs: {\n description,\n recommended: true,\n url,\n },\n schema: [],\n type: \"problem\",\n },\n});\n"],"mappings":";AAEO,IAAM,aAAa,CAAC,SAA2C;;;ACWtE,IAAqB,iBAArB,MAAoC;AAAA,EAClC;AAAA,EAWA,YAAY,SAAc;AACxB,SAAK,aAAa,CAAC;AACnB,YAAQ,WAAW,QAAQ,CAAC,cAAmB;AAC7C,UAAI,CAAC,UAAU,QAAQ,UAAU,SAAS,gBAAgB;AACxD;AAAA,MACF;AAEA,UAAI,UAAU,OAAO;AAEnB,cAAM,QACJ,OAAO,UAAU,MAAM,UAAU,WAAW,UAAU,MAAM,QAC1D,OAAO,UAAU,MAAM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IAAI,eAAe,IAAI;AAK1C,UACE,OAAO,WAAW,MAAM,KAAK,MAAM,YACnC,YAAY,WAAW,MAAM,KAAK,GAAG,cAAc,GACnD;AACA,eAAO,QAAQ,OAAO;AAAA,UACpB,SAAS;AAAA,UACT;AAAA,QACF,CAAC;AAAA,MACH;AAKA,UACE,WAAW,MAAM,yBAAyB,KAC1C,WAAW,MAAM,yBAAyB,EAAE,SAAS,GACrD;AACA,cAAM,cAAc,WAAW,MAAM,yBAAyB,EAAE,CAAC,EAAE,MAChE,SAAS,CAAC,EAAE,MAAM;AACrB,YACE,eACA,YAAY,aAAa,2BAA2B,GACpD;AACA,kBAAQ,OAAO;AAAA,YACb,SAAS;AAAA,YACT;AAAA,UACF,CAAC;AAAA,QACH;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAAA,EACA,MAAM;AAAA,IACJ,MAAM;AAAA,MACJ;AAAA,MACA,aAAa;AAAA,MACb;AAAA,IACF;AAAA,IACA,QAAQ,CAAC;AAAA,IACT,MAAM;AAAA,EACR;AACF,CAAC;","names":[]}
@@ -1,64 +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-assign-module-variable.ts
21
- var no_assign_module_variable_exports = {};
22
- __export(no_assign_module_variable_exports, {
23
- noAssignModuleVariable: () => noAssignModuleVariable
24
- });
25
- module.exports = __toCommonJS(no_assign_module_variable_exports);
26
-
27
- // src/utils/define-rule.ts
28
- var defineRule = (rule) => rule;
29
-
30
- // src/rules/no-assign-module-variable.ts
31
- var url = "https://nextjs.org/docs/messages/no-assign-module-variable";
32
- var noAssignModuleVariable = defineRule({
33
- create: (context) => ({
34
- VariableDeclaration: (node) => {
35
- const moduleVariableFound = node.declarations.some((declaration) => {
36
- if ("name" in declaration.id) {
37
- return declaration.id.name === "module";
38
- }
39
- return false;
40
- });
41
- if (!moduleVariableFound) {
42
- return;
43
- }
44
- context.report({
45
- message: `Do not assign to the variable \`module\`. See: ${url}`,
46
- node
47
- });
48
- }
49
- }),
50
- meta: {
51
- docs: {
52
- description: "Prevent assignment to the `module` variable.",
53
- recommended: true,
54
- url
55
- },
56
- schema: [],
57
- type: "problem"
58
- }
59
- });
60
- // Annotate the CommonJS export names for ESM import in node:
61
- 0 && (module.exports = {
62
- noAssignModuleVariable
63
- });
64
- //# sourceMappingURL=no-assign-module-variable.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/rules/no-assign-module-variable.ts","../../src/utils/define-rule.ts"],"sourcesContent":["import { defineRule } from \"../utils/define-rule.js\";\nconst url = \"https://nextjs.org/docs/messages/no-assign-module-variable\";\n\nexport const noAssignModuleVariable = defineRule({\n create: (context: any) => ({\n VariableDeclaration: (node: any) => {\n // Checks node.declarations array for variable with id.name of `module`\n const moduleVariableFound = node.declarations.some((declaration: any) => {\n if (\"name\" in declaration.id) {\n return declaration.id.name === \"module\";\n }\n return false;\n });\n\n // Return early if no `module` variable is found\n if (!moduleVariableFound) {\n return;\n }\n\n context.report({\n message: `Do not assign to the variable \\`module\\`. See: ${url}`,\n node,\n });\n },\n }),\n\n meta: {\n docs: {\n description: \"Prevent assignment to the `module` variable.\",\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,yBAAyB,WAAW;AAAA,EAC/C,QAAQ,CAAC,aAAkB;AAAA,IACzB,qBAAqB,CAAC,SAAc;AAElC,YAAM,sBAAsB,KAAK,aAAa,KAAK,CAAC,gBAAqB;AACvE,YAAI,UAAU,YAAY,IAAI;AAC5B,iBAAO,YAAY,GAAG,SAAS;AAAA,QACjC;AACA,eAAO;AAAA,MACT,CAAC;AAGD,UAAI,CAAC,qBAAqB;AACxB;AAAA,MACF;AAEA,cAAQ,OAAO;AAAA,QACb,SAAS,kDAAkD,GAAG;AAAA,QAC9D;AAAA,MACF,CAAC;AAAA,IACH;AAAA,EACF;AAAA,EAEA,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,5 +0,0 @@
1
- import * as eslint from 'eslint';
2
-
3
- declare const noAssignModuleVariable: eslint.Rule.RuleModule;
4
-
5
- export { noAssignModuleVariable };
@@ -1,5 +0,0 @@
1
- import * as eslint from 'eslint';
2
-
3
- declare const noAssignModuleVariable: eslint.Rule.RuleModule;
4
-
5
- export { noAssignModuleVariable };
@@ -1,37 +0,0 @@
1
- // src/utils/define-rule.ts
2
- var defineRule = (rule) => rule;
3
-
4
- // src/rules/no-assign-module-variable.ts
5
- var url = "https://nextjs.org/docs/messages/no-assign-module-variable";
6
- var noAssignModuleVariable = defineRule({
7
- create: (context) => ({
8
- VariableDeclaration: (node) => {
9
- const moduleVariableFound = node.declarations.some((declaration) => {
10
- if ("name" in declaration.id) {
11
- return declaration.id.name === "module";
12
- }
13
- return false;
14
- });
15
- if (!moduleVariableFound) {
16
- return;
17
- }
18
- context.report({
19
- message: `Do not assign to the variable \`module\`. See: ${url}`,
20
- node
21
- });
22
- }
23
- }),
24
- meta: {
25
- docs: {
26
- description: "Prevent assignment to the `module` variable.",
27
- recommended: true,
28
- url
29
- },
30
- schema: [],
31
- type: "problem"
32
- }
33
- });
34
- export {
35
- noAssignModuleVariable
36
- };
37
- //# sourceMappingURL=no-assign-module-variable.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/utils/define-rule.ts","../../src/rules/no-assign-module-variable.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-assign-module-variable\";\n\nexport const noAssignModuleVariable = defineRule({\n create: (context: any) => ({\n VariableDeclaration: (node: any) => {\n // Checks node.declarations array for variable with id.name of `module`\n const moduleVariableFound = node.declarations.some((declaration: any) => {\n if (\"name\" in declaration.id) {\n return declaration.id.name === \"module\";\n }\n return false;\n });\n\n // Return early if no `module` variable is found\n if (!moduleVariableFound) {\n return;\n }\n\n context.report({\n message: `Do not assign to the variable \\`module\\`. See: ${url}`,\n node,\n });\n },\n }),\n\n meta: {\n docs: {\n description: \"Prevent assignment to the `module` variable.\",\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,yBAAyB,WAAW;AAAA,EAC/C,QAAQ,CAAC,aAAkB;AAAA,IACzB,qBAAqB,CAAC,SAAc;AAElC,YAAM,sBAAsB,KAAK,aAAa,KAAK,CAAC,gBAAqB;AACvE,YAAI,UAAU,YAAY,IAAI;AAC5B,iBAAO,YAAY,GAAG,SAAS;AAAA,QACjC;AACA,eAAO;AAAA,MACT,CAAC;AAGD,UAAI,CAAC,qBAAqB;AACxB;AAAA,MACF;AAEA,cAAQ,OAAO;AAAA,QACb,SAAS,kDAAkD,GAAG;AAAA,QAC9D;AAAA,MACF,CAAC;AAAA,IACH;AAAA,EACF;AAAA,EAEA,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,99 +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-async-client-component.ts
21
- var no_async_client_component_exports = {};
22
- __export(no_async_client_component_exports, {
23
- noAsyncClientComponent: () => noAsyncClientComponent
24
- });
25
- module.exports = __toCommonJS(no_async_client_component_exports);
26
-
27
- // src/utils/define-rule.ts
28
- var defineRule = (rule) => rule;
29
-
30
- // src/rules/no-async-client-component.ts
31
- var url = "https://nextjs.org/docs/messages/no-async-client-component";
32
- var description = "Prevent client components from being async functions.";
33
- var message = `${description} See: ${url}`;
34
- var isCapitalized = (str) => /[A-Z]/.test(str[0] ?? "");
35
- var noAsyncClientComponent = defineRule({
36
- create: (context) => ({
37
- Program: (node) => {
38
- let isClientComponent = false;
39
- for (const block of node.body) {
40
- if (block.type === "ExpressionStatement" && block.expression.type === "Literal" && block.expression.value === "use client") {
41
- isClientComponent = true;
42
- }
43
- if (block.type === "ExportDefaultDeclaration" && isClientComponent) {
44
- if (block.declaration?.type === "FunctionDeclaration" && block.declaration.async && isCapitalized(block.declaration.id.name)) {
45
- context.report({
46
- message,
47
- node: block
48
- });
49
- }
50
- if (block.declaration.type === "Identifier" && isCapitalized(block.declaration.name)) {
51
- const targetName = block.declaration.name;
52
- const functionDeclaration = node.body.find((localBlock) => {
53
- if (localBlock.type === "FunctionDeclaration" && localBlock.id.name === targetName) {
54
- return true;
55
- }
56
- if (localBlock.type === "VariableDeclaration" && localBlock.declarations.find(
57
- (declaration) => declaration.id?.type === "Identifier" && declaration.id.name === targetName
58
- )) {
59
- return true;
60
- }
61
- return false;
62
- });
63
- if (functionDeclaration?.type === "FunctionDeclaration" && functionDeclaration.async) {
64
- context.report({
65
- message,
66
- node: functionDeclaration
67
- });
68
- }
69
- if (functionDeclaration?.type === "VariableDeclaration") {
70
- const varDeclarator = functionDeclaration.declarations.find(
71
- (declaration) => declaration.id?.type === "Identifier" && declaration.id.name === targetName
72
- );
73
- if (varDeclarator?.init?.type === "ArrowFunctionExpression" && varDeclarator.init.async) {
74
- context.report({
75
- message,
76
- node: functionDeclaration
77
- });
78
- }
79
- }
80
- }
81
- }
82
- }
83
- }
84
- }),
85
- meta: {
86
- docs: {
87
- description,
88
- recommended: true,
89
- url
90
- },
91
- schema: [],
92
- type: "problem"
93
- }
94
- });
95
- // Annotate the CommonJS export names for ESM import in node:
96
- 0 && (module.exports = {
97
- noAsyncClientComponent
98
- });
99
- //# sourceMappingURL=no-async-client-component.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/rules/no-async-client-component.ts","../../src/utils/define-rule.ts"],"sourcesContent":["import { defineRule } from \"../utils/define-rule.js\";\n\nconst url = \"https://nextjs.org/docs/messages/no-async-client-component\";\nconst description = \"Prevent client components from being async functions.\";\nconst message = `${description} See: ${url}`;\n\nconst isCapitalized = (str: string): boolean => /[A-Z]/.test(str[0] ?? \"\");\n\nexport const noAsyncClientComponent = defineRule({\n create: (context: any) => ({\n Program: (node: any) => {\n let isClientComponent = false;\n\n for (const block of node.body) {\n if (\n block.type === \"ExpressionStatement\" &&\n block.expression.type === \"Literal\" &&\n block.expression.value === \"use client\"\n ) {\n isClientComponent = true;\n }\n\n if (block.type === \"ExportDefaultDeclaration\" && isClientComponent) {\n // export default async function MyComponent() {...}\n if (\n block.declaration?.type === \"FunctionDeclaration\" &&\n block.declaration.async &&\n isCapitalized(block.declaration.id.name)\n ) {\n context.report({\n message,\n node: block,\n });\n }\n\n // async function MyComponent() {...}; export default MyComponent;\n if (\n block.declaration.type === \"Identifier\" &&\n isCapitalized(block.declaration.name)\n ) {\n const targetName = block.declaration.name;\n\n const functionDeclaration = node.body.find((localBlock: any) => {\n if (\n localBlock.type === \"FunctionDeclaration\" &&\n localBlock.id.name === targetName\n ) {\n return true;\n }\n\n if (\n localBlock.type === \"VariableDeclaration\" &&\n localBlock.declarations.find(\n (declaration: any) =>\n declaration.id?.type === \"Identifier\" &&\n declaration.id.name === targetName,\n )\n ) {\n return true;\n }\n\n return false;\n });\n\n if (\n functionDeclaration?.type === \"FunctionDeclaration\" &&\n functionDeclaration.async\n ) {\n context.report({\n message,\n node: functionDeclaration,\n });\n }\n\n if (functionDeclaration?.type === \"VariableDeclaration\") {\n const varDeclarator = functionDeclaration.declarations.find(\n (declaration: any) =>\n declaration.id?.type === \"Identifier\" &&\n declaration.id.name === targetName,\n );\n\n if (\n varDeclarator?.init?.type === \"ArrowFunctionExpression\" &&\n varDeclarator.init.async\n ) {\n context.report({\n message,\n node: functionDeclaration,\n });\n }\n }\n }\n }\n }\n },\n }),\n\n meta: {\n docs: {\n description,\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;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AM,gBAAgB,oBAAoB,aAAa;AAAA,gBACrD,CAAC,gBACC,YAAY,IAAI,SAAS,gBACzB,YAAY,GAAG,SAAS;AAAA,cAC5B;AAEA,kBACE,eAAe,MAAM,SAAS,6BAC9B,cAAc,KAAK,OACnB;AACA,wBAAQ,OAAO;AAAA,kBACb;AAAA,kBACA,MAAM;AAAA,gBACR,CAAC;AAAA,cACH;AAAA,YACF;AAAA,UACF;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAAA,EAEA,MAAM;AAAA,IACJ,MAAM;AAAA,MACJ;AAAA,MACA,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 noAsyncClientComponent: eslint.Rule.RuleModule;
4
-
5
- export { noAsyncClientComponent };
@@ -1,5 +0,0 @@
1
- import * as eslint from 'eslint';
2
-
3
- declare const noAsyncClientComponent: eslint.Rule.RuleModule;
4
-
5
- export { noAsyncClientComponent };
@@ -1,72 +0,0 @@
1
- // src/utils/define-rule.ts
2
- var defineRule = (rule) => rule;
3
-
4
- // src/rules/no-async-client-component.ts
5
- var url = "https://nextjs.org/docs/messages/no-async-client-component";
6
- var description = "Prevent client components from being async functions.";
7
- var message = `${description} See: ${url}`;
8
- var isCapitalized = (str) => /[A-Z]/.test(str[0] ?? "");
9
- var noAsyncClientComponent = defineRule({
10
- create: (context) => ({
11
- Program: (node) => {
12
- let isClientComponent = false;
13
- for (const block of node.body) {
14
- if (block.type === "ExpressionStatement" && block.expression.type === "Literal" && block.expression.value === "use client") {
15
- isClientComponent = true;
16
- }
17
- if (block.type === "ExportDefaultDeclaration" && isClientComponent) {
18
- if (block.declaration?.type === "FunctionDeclaration" && block.declaration.async && isCapitalized(block.declaration.id.name)) {
19
- context.report({
20
- message,
21
- node: block
22
- });
23
- }
24
- if (block.declaration.type === "Identifier" && isCapitalized(block.declaration.name)) {
25
- const targetName = block.declaration.name;
26
- const functionDeclaration = node.body.find((localBlock) => {
27
- if (localBlock.type === "FunctionDeclaration" && localBlock.id.name === targetName) {
28
- return true;
29
- }
30
- if (localBlock.type === "VariableDeclaration" && localBlock.declarations.find(
31
- (declaration) => declaration.id?.type === "Identifier" && declaration.id.name === targetName
32
- )) {
33
- return true;
34
- }
35
- return false;
36
- });
37
- if (functionDeclaration?.type === "FunctionDeclaration" && functionDeclaration.async) {
38
- context.report({
39
- message,
40
- node: functionDeclaration
41
- });
42
- }
43
- if (functionDeclaration?.type === "VariableDeclaration") {
44
- const varDeclarator = functionDeclaration.declarations.find(
45
- (declaration) => declaration.id?.type === "Identifier" && declaration.id.name === targetName
46
- );
47
- if (varDeclarator?.init?.type === "ArrowFunctionExpression" && varDeclarator.init.async) {
48
- context.report({
49
- message,
50
- node: functionDeclaration
51
- });
52
- }
53
- }
54
- }
55
- }
56
- }
57
- }
58
- }),
59
- meta: {
60
- docs: {
61
- description,
62
- recommended: true,
63
- url
64
- },
65
- schema: [],
66
- type: "problem"
67
- }
68
- });
69
- export {
70
- noAsyncClientComponent
71
- };
72
- //# sourceMappingURL=no-async-client-component.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/utils/define-rule.ts","../../src/rules/no-async-client-component.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-async-client-component\";\nconst description = \"Prevent client components from being async functions.\";\nconst message = `${description} See: ${url}`;\n\nconst isCapitalized = (str: string): boolean => /[A-Z]/.test(str[0] ?? \"\");\n\nexport const noAsyncClientComponent = defineRule({\n create: (context: any) => ({\n Program: (node: any) => {\n let isClientComponent = false;\n\n for (const block of node.body) {\n if (\n block.type === \"ExpressionStatement\" &&\n block.expression.type === \"Literal\" &&\n block.expression.value === \"use client\"\n ) {\n isClientComponent = true;\n }\n\n if (block.type === \"ExportDefaultDeclaration\" && isClientComponent) {\n // export default async function MyComponent() {...}\n if (\n block.declaration?.type === \"FunctionDeclaration\" &&\n block.declaration.async &&\n isCapitalized(block.declaration.id.name)\n ) {\n context.report({\n message,\n node: block,\n });\n }\n\n // async function MyComponent() {...}; export default MyComponent;\n if (\n block.declaration.type === \"Identifier\" &&\n isCapitalized(block.declaration.name)\n ) {\n const targetName = block.declaration.name;\n\n const functionDeclaration = node.body.find((localBlock: any) => {\n if (\n localBlock.type === \"FunctionDeclaration\" &&\n localBlock.id.name === targetName\n ) {\n return true;\n }\n\n if (\n localBlock.type === \"VariableDeclaration\" &&\n localBlock.declarations.find(\n (declaration: any) =>\n declaration.id?.type === \"Identifier\" &&\n declaration.id.name === targetName,\n )\n ) {\n return true;\n }\n\n return false;\n });\n\n if (\n functionDeclaration?.type === \"FunctionDeclaration\" &&\n functionDeclaration.async\n ) {\n context.report({\n message,\n node: functionDeclaration,\n });\n }\n\n if (functionDeclaration?.type === \"VariableDeclaration\") {\n const varDeclarator = functionDeclaration.declarations.find(\n (declaration: any) =>\n declaration.id?.type === \"Identifier\" &&\n declaration.id.name === targetName,\n );\n\n if (\n varDeclarator?.init?.type === \"ArrowFunctionExpression\" &&\n varDeclarator.init.async\n ) {\n context.report({\n message,\n node: functionDeclaration,\n });\n }\n }\n }\n }\n }\n },\n }),\n\n meta: {\n docs: {\n description,\n recommended: true,\n url,\n },\n schema: [],\n type: \"problem\",\n },\n});\n"],"mappings":";AAEO,IAAM,aAAa,CAAC,SAA2C;;;ACAtE,IAAM,MAAM;AACZ,IAAM,cAAc;AACpB,IAAM,UAAU,GAAG,WAAW,SAAS,GAAG;AAE1C,IAAM,gBAAgB,CAAC,QAAyB,QAAQ,KAAK,IAAI,CAAC,KAAK,EAAE;AAElE,IAAM,yBAAyB,WAAW;AAAA,EAC/C,QAAQ,CAAC,aAAkB;AAAA,IACzB,SAAS,CAAC,SAAc;AACtB,UAAI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F;AAAA,EACF;AAAA,EAEA,MAAM;AAAA,IACJ,MAAM;AAAA,MACJ;AAAA,MACA,aAAa;AAAA,MACb;AAAA,IACF;AAAA,IACA,QAAQ,CAAC;AAAA,IACT,MAAM;AAAA,EACR;AACF,CAAC;","names":[]}
@@ -1,94 +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-before-interactive-script-outside-document.ts
31
- var no_before_interactive_script_outside_document_exports = {};
32
- __export(no_before_interactive_script_outside_document_exports, {
33
- noBeforeInteractiveScriptOutsideDocument: () => noBeforeInteractiveScriptOutsideDocument
34
- });
35
- module.exports = __toCommonJS(no_before_interactive_script_outside_document_exports);
36
- var path = __toESM(require("path"), 1);
37
-
38
- // src/utils/define-rule.ts
39
- var defineRule = (rule) => rule;
40
-
41
- // src/rules/no-before-interactive-script-outside-document.ts
42
- var url = "https://nextjs.org/docs/messages/no-before-interactive-script-outside-document";
43
- var convertToCorrectSeparator = (str) => str.replaceAll(/[/\\]/g, path.sep);
44
- var noBeforeInteractiveScriptOutsideDocument = defineRule({
45
- create: (context) => {
46
- let scriptImportName = null;
47
- return {
48
- 'ImportDeclaration[source.value="next/script"] > ImportDefaultSpecifier'(node) {
49
- scriptImportName = node.local.name;
50
- },
51
- JSXOpeningElement: (node) => {
52
- const pathname = convertToCorrectSeparator(context.filename);
53
- const isInAppDir = pathname.includes(`${path.sep}app${path.sep}`);
54
- if (isInAppDir) {
55
- return;
56
- }
57
- if (!scriptImportName) {
58
- return;
59
- }
60
- if (node.name && node.name.name !== scriptImportName) {
61
- return;
62
- }
63
- const strategy = node.attributes.find(
64
- (child) => child.name && child.name.name === "strategy"
65
- );
66
- if (!strategy?.value || strategy.value.value !== "beforeInteractive") {
67
- return;
68
- }
69
- const document = context.filename.split("pages", 2)[1];
70
- if (document && path.parse(document).name.startsWith("_document")) {
71
- return;
72
- }
73
- context.report({
74
- message: `\`next/script\`'s \`beforeInteractive\` strategy should not be used outside of \`pages/_document.js\`. See: ${url}`,
75
- node
76
- });
77
- }
78
- };
79
- },
80
- meta: {
81
- docs: {
82
- description: "Prevent usage of `next/script`'s `beforeInteractive` strategy outside of `pages/_document.js`.",
83
- recommended: true,
84
- url
85
- },
86
- schema: [],
87
- type: "problem"
88
- }
89
- });
90
- // Annotate the CommonJS export names for ESM import in node:
91
- 0 && (module.exports = {
92
- noBeforeInteractiveScriptOutsideDocument
93
- });
94
- //# sourceMappingURL=no-before-interactive-script-outside-document.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/rules/no-before-interactive-script-outside-document.ts","../../src/utils/define-rule.ts"],"sourcesContent":["import * as path from \"node:path\";\n\nimport { defineRule } from \"../utils/define-rule.js\";\n\nconst url =\n \"https://nextjs.org/docs/messages/no-before-interactive-script-outside-document\";\n\nconst convertToCorrectSeparator = (str: string) =>\n str.replaceAll(/[/\\\\]/g, path.sep);\n\nexport const noBeforeInteractiveScriptOutsideDocument = defineRule({\n create: (context: any) => {\n let scriptImportName: null | string = null;\n\n return {\n 'ImportDeclaration[source.value=\"next/script\"] > ImportDefaultSpecifier'(\n node: any,\n ) {\n scriptImportName = node.local.name;\n },\n JSXOpeningElement: (node: any) => {\n const pathname = convertToCorrectSeparator(context.filename);\n\n const isInAppDir = pathname.includes(`${path.sep}app${path.sep}`);\n\n // This rule shouldn't fire in `app/`\n if (isInAppDir) {\n return;\n }\n\n if (!scriptImportName) {\n return;\n }\n\n if (node.name && node.name.name !== scriptImportName) {\n return;\n }\n\n const strategy = node.attributes.find(\n (child: any) => child.name && child.name.name === \"strategy\",\n );\n\n if (!strategy?.value || strategy.value.value !== \"beforeInteractive\") {\n return;\n }\n\n const document = context.filename.split(\"pages\", 2)[1];\n if (document && path.parse(document).name.startsWith(\"_document\")) {\n return;\n }\n\n context.report({\n message: `\\`next/script\\`'s \\`beforeInteractive\\` strategy should not be used outside of \\`pages/_document.js\\`. See: ${url}`,\n node,\n });\n },\n };\n },\n meta: {\n docs: {\n description:\n \"Prevent usage of `next/script`'s `beforeInteractive` strategy outside of `pages/_document.js`.\",\n recommended: true,\n url,\n },\n schema: [],\n type: \"problem\",\n },\n});\n","import type { Rule } from \"eslint\";\n\nexport const defineRule = (rule: Rule.RuleModule): Rule.RuleModule => rule;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,WAAsB;;;ACEf,IAAM,aAAa,CAAC,SAA2C;;;ADEtE,IAAM,MACJ;AAEF,IAAM,4BAA4B,CAAC,QACjC,IAAI,WAAW,UAAe,QAAG;AAE5B,IAAM,2CAA2C,WAAW;AAAA,EACjE,QAAQ,CAAC,YAAiB;AACxB,QAAI,mBAAkC;AAEtC,WAAO;AAAA,MACL,yEACE,MACA;AACA,2BAAmB,KAAK,MAAM;AAAA,MAChC;AAAA,MACA,mBAAmB,CAAC,SAAc;AAChC,cAAM,WAAW,0BAA0B,QAAQ,QAAQ;AAE3D,cAAM,aAAa,SAAS,SAAS,GAAQ,QAAG,MAAW,QAAG,EAAE;AAGhE,YAAI,YAAY;AACd;AAAA,QACF;AAEA,YAAI,CAAC,kBAAkB;AACrB;AAAA,QACF;AAEA,YAAI,KAAK,QAAQ,KAAK,KAAK,SAAS,kBAAkB;AACpD;AAAA,QACF;AAEA,cAAM,WAAW,KAAK,WAAW;AAAA,UAC/B,CAAC,UAAe,MAAM,QAAQ,MAAM,KAAK,SAAS;AAAA,QACpD;AAEA,YAAI,CAAC,UAAU,SAAS,SAAS,MAAM,UAAU,qBAAqB;AACpE;AAAA,QACF;AAEA,cAAM,WAAW,QAAQ,SAAS,MAAM,SAAS,CAAC,EAAE,CAAC;AACrD,YAAI,YAAiB,WAAM,QAAQ,EAAE,KAAK,WAAW,WAAW,GAAG;AACjE;AAAA,QACF;AAEA,gBAAQ,OAAO;AAAA,UACb,SAAS,+GAA+G,GAAG;AAAA,UAC3H;AAAA,QACF,CAAC;AAAA,MACH;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 noBeforeInteractiveScriptOutsideDocument: eslint.Rule.RuleModule;
4
-
5
- export { noBeforeInteractiveScriptOutsideDocument };
@@ -1,5 +0,0 @@
1
- import * as eslint from 'eslint';
2
-
3
- declare const noBeforeInteractiveScriptOutsideDocument: eslint.Rule.RuleModule;
4
-
5
- export { noBeforeInteractiveScriptOutsideDocument };
@@ -1,59 +0,0 @@
1
- // src/rules/no-before-interactive-script-outside-document.ts
2
- import * as path from "node:path";
3
-
4
- // src/utils/define-rule.ts
5
- var defineRule = (rule) => rule;
6
-
7
- // src/rules/no-before-interactive-script-outside-document.ts
8
- var url = "https://nextjs.org/docs/messages/no-before-interactive-script-outside-document";
9
- var convertToCorrectSeparator = (str) => str.replaceAll(/[/\\]/g, path.sep);
10
- var noBeforeInteractiveScriptOutsideDocument = defineRule({
11
- create: (context) => {
12
- let scriptImportName = null;
13
- return {
14
- 'ImportDeclaration[source.value="next/script"] > ImportDefaultSpecifier'(node) {
15
- scriptImportName = node.local.name;
16
- },
17
- JSXOpeningElement: (node) => {
18
- const pathname = convertToCorrectSeparator(context.filename);
19
- const isInAppDir = pathname.includes(`${path.sep}app${path.sep}`);
20
- if (isInAppDir) {
21
- return;
22
- }
23
- if (!scriptImportName) {
24
- return;
25
- }
26
- if (node.name && node.name.name !== scriptImportName) {
27
- return;
28
- }
29
- const strategy = node.attributes.find(
30
- (child) => child.name && child.name.name === "strategy"
31
- );
32
- if (!strategy?.value || strategy.value.value !== "beforeInteractive") {
33
- return;
34
- }
35
- const document = context.filename.split("pages", 2)[1];
36
- if (document && path.parse(document).name.startsWith("_document")) {
37
- return;
38
- }
39
- context.report({
40
- message: `\`next/script\`'s \`beforeInteractive\` strategy should not be used outside of \`pages/_document.js\`. See: ${url}`,
41
- node
42
- });
43
- }
44
- };
45
- },
46
- meta: {
47
- docs: {
48
- description: "Prevent usage of `next/script`'s `beforeInteractive` strategy outside of `pages/_document.js`.",
49
- recommended: true,
50
- url
51
- },
52
- schema: [],
53
- type: "problem"
54
- }
55
- });
56
- export {
57
- noBeforeInteractiveScriptOutsideDocument
58
- };
59
- //# sourceMappingURL=no-before-interactive-script-outside-document.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/rules/no-before-interactive-script-outside-document.ts","../../src/utils/define-rule.ts"],"sourcesContent":["import * as path from \"node:path\";\n\nimport { defineRule } from \"../utils/define-rule.js\";\n\nconst url =\n \"https://nextjs.org/docs/messages/no-before-interactive-script-outside-document\";\n\nconst convertToCorrectSeparator = (str: string) =>\n str.replaceAll(/[/\\\\]/g, path.sep);\n\nexport const noBeforeInteractiveScriptOutsideDocument = defineRule({\n create: (context: any) => {\n let scriptImportName: null | string = null;\n\n return {\n 'ImportDeclaration[source.value=\"next/script\"] > ImportDefaultSpecifier'(\n node: any,\n ) {\n scriptImportName = node.local.name;\n },\n JSXOpeningElement: (node: any) => {\n const pathname = convertToCorrectSeparator(context.filename);\n\n const isInAppDir = pathname.includes(`${path.sep}app${path.sep}`);\n\n // This rule shouldn't fire in `app/`\n if (isInAppDir) {\n return;\n }\n\n if (!scriptImportName) {\n return;\n }\n\n if (node.name && node.name.name !== scriptImportName) {\n return;\n }\n\n const strategy = node.attributes.find(\n (child: any) => child.name && child.name.name === \"strategy\",\n );\n\n if (!strategy?.value || strategy.value.value !== \"beforeInteractive\") {\n return;\n }\n\n const document = context.filename.split(\"pages\", 2)[1];\n if (document && path.parse(document).name.startsWith(\"_document\")) {\n return;\n }\n\n context.report({\n message: `\\`next/script\\`'s \\`beforeInteractive\\` strategy should not be used outside of \\`pages/_document.js\\`. See: ${url}`,\n node,\n });\n },\n };\n },\n meta: {\n docs: {\n description:\n \"Prevent usage of `next/script`'s `beforeInteractive` strategy outside of `pages/_document.js`.\",\n recommended: true,\n url,\n },\n schema: [],\n type: \"problem\",\n },\n});\n","import type { Rule } from \"eslint\";\n\nexport const defineRule = (rule: Rule.RuleModule): Rule.RuleModule => rule;\n"],"mappings":";AAAA,YAAY,UAAU;;;ACEf,IAAM,aAAa,CAAC,SAA2C;;;ADEtE,IAAM,MACJ;AAEF,IAAM,4BAA4B,CAAC,QACjC,IAAI,WAAW,UAAe,QAAG;AAE5B,IAAM,2CAA2C,WAAW;AAAA,EACjE,QAAQ,CAAC,YAAiB;AACxB,QAAI,mBAAkC;AAEtC,WAAO;AAAA,MACL,yEACE,MACA;AACA,2BAAmB,KAAK,MAAM;AAAA,MAChC;AAAA,MACA,mBAAmB,CAAC,SAAc;AAChC,cAAM,WAAW,0BAA0B,QAAQ,QAAQ;AAE3D,cAAM,aAAa,SAAS,SAAS,GAAQ,QAAG,MAAW,QAAG,EAAE;AAGhE,YAAI,YAAY;AACd;AAAA,QACF;AAEA,YAAI,CAAC,kBAAkB;AACrB;AAAA,QACF;AAEA,YAAI,KAAK,QAAQ,KAAK,KAAK,SAAS,kBAAkB;AACpD;AAAA,QACF;AAEA,cAAM,WAAW,KAAK,WAAW;AAAA,UAC/B,CAAC,UAAe,MAAM,QAAQ,MAAM,KAAK,SAAS;AAAA,QACpD;AAEA,YAAI,CAAC,UAAU,SAAS,SAAS,MAAM,UAAU,qBAAqB;AACpE;AAAA,QACF;AAEA,cAAM,WAAW,QAAQ,SAAS,MAAM,SAAS,CAAC,EAAE,CAAC;AACrD,YAAI,YAAiB,WAAM,QAAQ,EAAE,KAAK,WAAW,WAAW,GAAG;AACjE;AAAA,QACF;AAEA,gBAAQ,OAAO;AAAA,UACb,SAAS,+GAA+G,GAAG;AAAA,UAC3H;AAAA,QACF,CAAC;AAAA,MACH;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":[]}