@atlaspack/eslint-plugin 2.14.2-dev.3853 → 2.14.2-dev.3872

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaspack/eslint-plugin",
3
- "version": "2.14.2-dev.3853+84eec3484",
3
+ "version": "2.14.2-dev.3872+207d003c0",
4
4
  "license": "(MIT OR Apache-2.0)",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
@@ -25,5 +25,5 @@
25
25
  "peerDependencies": {
26
26
  "eslint": "^8.57.0 || ^9.0.0"
27
27
  },
28
- "gitHead": "84eec348413c647de4872f902c4bc8ff54c347f3"
28
+ "gitHead": "207d003c0f1d4ffa6a1c52d2f8841d998616c523"
29
29
  }
package/lib/index.d.ts DELETED
@@ -1,56 +0,0 @@
1
- import { PluginDocs } from "src/utils";
2
- import { RuleListener, RuleModule } from "@typescript-eslint/utils/ts-eslint";
3
- export const name: string, version: string;
4
- export const rules: {
5
- 'importcond-type-annotations': RuleModule<"addTypeAnnotation" | "wrongTypeAnnotation" | "suggestTypeAnnotation", [], PluginDocs, RuleListener>;
6
- 'no-importcond-exports': RuleModule<"noImportCondExports", [], PluginDocs, RuleListener>;
7
- };
8
- export const plugin: {
9
- readonly meta: {
10
- readonly name: string;
11
- readonly version: string;
12
- };
13
- readonly rules: {
14
- 'importcond-type-annotations': RuleModule<"addTypeAnnotation" | "wrongTypeAnnotation" | "suggestTypeAnnotation", [], PluginDocs, RuleListener>;
15
- 'no-importcond-exports': RuleModule<"noImportCondExports", [], PluginDocs, RuleListener>;
16
- };
17
- readonly configs: {
18
- readonly recommended: {
19
- readonly plugins: readonly ["@atlaspack"];
20
- readonly rules: {
21
- readonly '@atlaspack/importcond-type-annotations': "error";
22
- readonly '@atlaspack/no-importcond-exports': "error";
23
- };
24
- };
25
- readonly 'flat/recommended': {
26
- readonly plugins: {
27
- readonly '@atlaspack': any;
28
- };
29
- readonly rules: {
30
- readonly '@atlaspack/importcond-type-annotations': "error";
31
- readonly '@atlaspack/no-importcond-exports': "error";
32
- };
33
- };
34
- };
35
- };
36
- export const configs: {
37
- readonly recommended: {
38
- readonly plugins: readonly ["@atlaspack"];
39
- readonly rules: {
40
- readonly '@atlaspack/importcond-type-annotations': "error";
41
- readonly '@atlaspack/no-importcond-exports': "error";
42
- };
43
- };
44
- readonly 'flat/recommended': {
45
- readonly plugins: {
46
- readonly '@atlaspack': any;
47
- };
48
- readonly rules: {
49
- readonly '@atlaspack/importcond-type-annotations': "error";
50
- readonly '@atlaspack/no-importcond-exports': "error";
51
- };
52
- };
53
- };
54
- export default plugin;
55
-
56
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"mappings":";;AGIA,OAAO,mCACyD,CAAC;AAEjE,OAAO,MAAM;;;CAGZ,CAAC;AAUF,OAAO,MAAM,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;CAYT,CAAC;AAYX,OAAO,MAAM;;;;;;;;;;;;;;;;;CAAwB,CAAC;AAEtC,eAAe,MAAM,CAAC","sources":["packages/core/eslint-plugin/src/packages/core/eslint-plugin/src/utils/index.ts","packages/core/eslint-plugin/src/packages/core/eslint-plugin/src/rules/importcond-type-annotations/index.ts","packages/core/eslint-plugin/src/packages/core/eslint-plugin/src/rules/no-importcond-exports/index.ts","packages/core/eslint-plugin/src/packages/core/eslint-plugin/src/index.ts","packages/core/eslint-plugin/src/index.ts"],"sourcesContent":[null,null,null,null,"import importCondTypeAnnotationsRule from './rules/importcond-type-annotations';\nimport noImportCondExportsRule from './rules/no-importcond-exports';\n\n// eslint-disable-next-line @typescript-eslint/no-require-imports\nexport const {name, version} =\n require('../package.json') as typeof import('../package.json');\n\nexport const rules = {\n 'importcond-type-annotations': importCondTypeAnnotationsRule,\n 'no-importcond-exports': noImportCondExportsRule,\n};\n\nconst recommended = {\n plugins: ['@atlaspack'],\n rules: {\n '@atlaspack/importcond-type-annotations': 'error',\n '@atlaspack/no-importcond-exports': 'error',\n },\n} as const;\n\nexport const plugin = {\n meta: {\n name,\n version,\n },\n rules,\n configs: {\n recommended,\n get 'flat/recommended'() {\n return flatRecommended;\n },\n },\n} as const;\n\nconst flatRecommended = {\n plugins: {\n '@atlaspack': plugin,\n },\n rules: {\n '@atlaspack/importcond-type-annotations': 'error',\n '@atlaspack/no-importcond-exports': 'error',\n },\n} as const;\n\nexport const configs = plugin.configs;\n\nexport default plugin;\n"],"names":[],"version":3,"file":"index.d.ts.map","sourceRoot":"../../../../"}
package/lib/index.js DELETED
@@ -1,247 +0,0 @@
1
- var $kWQCm$typescripteslintutils = require("@typescript-eslint/utils");
2
-
3
-
4
- function $parcel$defineInteropFlag(a) {
5
- Object.defineProperty(a, '__esModule', {value: true, configurable: true});
6
- }
7
-
8
- function $parcel$export(e, n, v, s) {
9
- Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
10
- }
11
-
12
- var $parcel$global = globalThis;
13
-
14
- var $parcel$modules = {};
15
- var $parcel$inits = {};
16
-
17
- var parcelRequire = $parcel$global["parcelRequired8fd"];
18
-
19
- if (parcelRequire == null) {
20
- parcelRequire = function(id) {
21
- if (id in $parcel$modules) {
22
- return $parcel$modules[id].exports;
23
- }
24
- if (id in $parcel$inits) {
25
- var init = $parcel$inits[id];
26
- delete $parcel$inits[id];
27
- var module = {id: id, exports: {}};
28
- $parcel$modules[id] = module;
29
- init.call(module.exports, module, module.exports);
30
- return module.exports;
31
- }
32
- var err = new Error("Cannot find module '" + id + "'");
33
- err.code = 'MODULE_NOT_FOUND';
34
- throw err;
35
- };
36
-
37
- parcelRequire.register = function register(id, init) {
38
- $parcel$inits[id] = init;
39
- };
40
-
41
- $parcel$global["parcelRequired8fd"] = parcelRequire;
42
- }
43
-
44
- var parcelRegister = parcelRequire.register;
45
- parcelRegister("ge4Mt", function(module, exports) {
46
- module.exports = JSON.parse("{\"name\":\"@atlaspack/eslint-plugin\",\"version\":\"2.14.2-dev.3853+84eec3484\",\"license\":\"(MIT OR Apache-2.0)\",\"main\":\"lib/index.js\",\"types\":\"lib/index.d.ts\",\"source\":\"src/index.ts\",\"repository\":{\"type\":\"git\",\"url\":\"https://github.com/atlassian-labs/atlaspack.git\"},\"publishConfig\":{\"access\":\"public\"},\"engines\":{\"node\":\">= 16.0.0\"},\"dependencies\":{\"@typescript-eslint/utils\":\"^8.31.1\"},\"devDependencies\":{\"@typescript-eslint/rule-tester\":\"^8.31.1\",\"typescript-eslint\":\"^8.31.1\"},\"peerDependencies\":{\"eslint\":\"^8.57.0 || ^9.0.0\"},\"gitHead\":\"84eec348413c647de4872f902c4bc8ff54c347f3\"}");
47
-
48
- });
49
-
50
-
51
- $parcel$defineInteropFlag(module.exports);
52
-
53
- $parcel$export(module.exports, "name", () => $3f52bc2bbb9aa3d8$export$a8ff84c12d48cfa6);
54
- $parcel$export(module.exports, "version", () => $3f52bc2bbb9aa3d8$export$83d89fbfd8236492);
55
- $parcel$export(module.exports, "rules", () => $3f52bc2bbb9aa3d8$export$354076178bdef094);
56
- $parcel$export(module.exports, "plugin", () => $3f52bc2bbb9aa3d8$export$ca524d3785e2543);
57
- $parcel$export(module.exports, "configs", () => $3f52bc2bbb9aa3d8$export$c884d9dcb329c3c);
58
- $parcel$export(module.exports, "default", () => $3f52bc2bbb9aa3d8$export$2e2bcd8739ae039);
59
- /**
60
- * @file Automatically adds type annotations for conditional import (importCond) usages
61
- */
62
- const $2f8f3cc371e6d9a5$export$56e87122f905fac0 = (0, $kWQCm$typescripteslintutils.ESLintUtils).RuleCreator((name)=>`https://github.com/atlassian-labs/atlaspack/tree/main/packages/core/eslint-plugin/src/rules/${name}/README.md`);
63
-
64
-
65
- const $62ed09825cfca72a$export$16059a9982ca14f7 = 'importcond-type-annotations';
66
- const $62ed09825cfca72a$export$defe85febe8b728c = {
67
- addTypeAnnotation: 'This conditional import usage needs a type annotation. Please apply the autofix so that the type annotation is correct.',
68
- wrongTypeAnnotation: 'The type annotation for this conditional import usage is incorrect. Please apply the suggestion to fix it.',
69
- suggestTypeAnnotation: 'Fix the type annotation for this conditional import usage.'
70
- }; // satisfies Record<string, string>; // Uncomment this line once prettier is updated to a version that supports it
71
- const $62ed09825cfca72a$var$generateFix = (firstArgText, secondArgText, thirdArgText)=>{
72
- return `importCond${`<typeof import(${secondArgText}), typeof import(${thirdArgText})>`}(${firstArgText}, ${secondArgText}, ${thirdArgText})`;
73
- };
74
- const $62ed09825cfca72a$var$rule = (0, $2f8f3cc371e6d9a5$export$56e87122f905fac0)({
75
- name: $62ed09825cfca72a$export$16059a9982ca14f7,
76
- meta: {
77
- docs: {
78
- description: 'Ensures that importCond function calls have correct type annotations.',
79
- recommended: true
80
- },
81
- messages: $62ed09825cfca72a$export$defe85febe8b728c,
82
- schema: [],
83
- type: 'problem',
84
- fixable: 'code',
85
- hasSuggestions: true
86
- },
87
- defaultOptions: [],
88
- create (context) {
89
- return {
90
- CallExpression (node) {
91
- // Check if the function being called is `importCond`
92
- // Note that this is a global, so we don't need to check the imports
93
- if (node.callee.type === 'Identifier' && node.callee.name === 'importCond') {
94
- const args = node.arguments;
95
- // Ensure there are at least 3 arguments
96
- // If not, then there will be type-checking errors anyway
97
- if (args.length < 3) return;
98
- const [firstArg, secondArg, thirdArg] = args;
99
- // Get the source code for the arguments
100
- const { sourceCode: sourceCode } = context;
101
- const firstArgText = sourceCode.getText(firstArg);
102
- const secondArgText = sourceCode.getText(secondArg);
103
- const thirdArgText = sourceCode.getText(thirdArg);
104
- // Check if the type annotation is missing or incorrect
105
- // Whether it's called typeArguments or typeParameters depends on the version of typescript-eslint
106
- const typeArguments = node.typeArguments ?? node.typeParameters;
107
- if (!typeArguments) // No type annotation exists at all
108
- context.report({
109
- node: node,
110
- messageId: 'addTypeAnnotation',
111
- // Apply autofix instead of suggestion, because there was no type annotation in the first place.
112
- fix: (fixer)=>{
113
- const fixedCode = $62ed09825cfca72a$var$generateFix(firstArgText, secondArgText, thirdArgText);
114
- return fixer.replaceText(node, fixedCode);
115
- }
116
- });
117
- else if (typeArguments.params.length !== 2 || sourceCode.getText(typeArguments.params[0]) !== `typeof import(${secondArgText})` || sourceCode.getText(typeArguments.params[1]) !== `typeof import(${thirdArgText})`) // Type annotation is present, but incorrect
118
- context.report({
119
- node: node,
120
- messageId: 'wrongTypeAnnotation',
121
- // We should be more cautious here, so we make it a suggestion instead of an autofix
122
- suggest: [
123
- {
124
- messageId: 'suggestTypeAnnotation',
125
- fix: (fixer)=>{
126
- const fixedCode = $62ed09825cfca72a$var$generateFix(firstArgText, secondArgText, thirdArgText);
127
- return fixer.replaceText(node, fixedCode);
128
- }
129
- }
130
- ]
131
- });
132
- }
133
- }
134
- };
135
- }
136
- });
137
- var $62ed09825cfca72a$export$2e2bcd8739ae039 = $62ed09825cfca72a$var$rule;
138
-
139
-
140
- /**
141
- * @file Bans directly exporting Atlaspack conditional imports (importCond) from a file, as this is not expressly supported and will break in tests.
142
- */
143
- const $f0c6a78c725779ec$export$16059a9982ca14f7 = 'no-importcond-exports';
144
- const $f0c6a78c725779ec$export$defe85febe8b728c = {
145
- noImportCondExports: "Directly exporting Atlaspack conditional imports (importCond) from a file is not supported and will break in tests. If you need the component for testing, please import the old and new versions of the components or modules directly in the test file instead.\n\nDoes your use case require exporting the component? Reach out to #atlaspack-contextual-imports so we can help find a workaround."
146
- }; // satisfies Record<string, string>; // Uncomment this line once prettier is updated to a version that supports it
147
- const $f0c6a78c725779ec$var$rule = (0, $2f8f3cc371e6d9a5$export$56e87122f905fac0)({
148
- name: $f0c6a78c725779ec$export$16059a9982ca14f7,
149
- meta: {
150
- docs: {
151
- description: 'Bans directly exporting Atlaspack conditional imports (importCond) from a file, as this is not expressly supported and will break in tests.',
152
- recommended: true
153
- },
154
- messages: $f0c6a78c725779ec$export$defe85febe8b728c,
155
- schema: [],
156
- type: 'problem'
157
- },
158
- defaultOptions: [],
159
- create (context) {
160
- // Track variables initialized with `importCond`
161
- const importCondVariables = new Set();
162
- const namedExportStatements = new Set();
163
- const defaultExportStatements = new Set();
164
- return {
165
- VariableDeclarator (node) {
166
- if (node.init && node.init.type === 'CallExpression' && node.init.callee.type === 'Identifier' && node.init.callee.name === 'importCond' && node.id.type === 'Identifier') // Add the variable name to the tracked set
167
- importCondVariables.add(node.id.name);
168
- },
169
- 'Program:exit' () {
170
- // Check if any named export references a tracked variable
171
- for (const exportStatement of namedExportStatements)exportStatement.specifiers.forEach((specifier)=>{
172
- if (specifier.type === 'ExportSpecifier' && specifier.local.type === 'Identifier' && importCondVariables.has(specifier.local.name)) context.report({
173
- node: specifier,
174
- messageId: 'noImportCondExports'
175
- });
176
- });
177
- for (const exportStatement of defaultExportStatements)if (exportStatement.declaration.type === 'Identifier' && importCondVariables.has(exportStatement.declaration.name)) context.report({
178
- node: exportStatement,
179
- messageId: 'noImportCondExports'
180
- });
181
- },
182
- ExportNamedDeclaration (node) {
183
- // Check if a variable declaration is directly exported
184
- if (node.declaration && node.declaration.type === 'VariableDeclaration' && node.declaration.declarations) node.declaration.declarations.forEach((declaration)=>{
185
- if (declaration.init && declaration.init.type === 'CallExpression' && declaration.init.callee.type === 'Identifier' && declaration.init.callee.name === 'importCond') context.report({
186
- node: declaration,
187
- messageId: 'noImportCondExports'
188
- });
189
- });
190
- else namedExportStatements.add(node);
191
- },
192
- ExportDefaultDeclaration (node) {
193
- // Check if the default export is a tracked variable or an `importCond` call
194
- if (node.declaration.type === 'CallExpression' && node.declaration.callee.type === 'Identifier' && node.declaration.callee.name === 'importCond') context.report({
195
- node: node,
196
- messageId: 'noImportCondExports'
197
- });
198
- else defaultExportStatements.add(node);
199
- }
200
- };
201
- }
202
- });
203
- var $f0c6a78c725779ec$export$2e2bcd8739ae039 = $f0c6a78c725779ec$var$rule;
204
-
205
-
206
-
207
- const { name: $3f52bc2bbb9aa3d8$export$a8ff84c12d48cfa6, version: $3f52bc2bbb9aa3d8$export$83d89fbfd8236492 } = (parcelRequire("ge4Mt"));
208
- const $3f52bc2bbb9aa3d8$export$354076178bdef094 = {
209
- 'importcond-type-annotations': (0, $62ed09825cfca72a$export$2e2bcd8739ae039),
210
- 'no-importcond-exports': (0, $f0c6a78c725779ec$export$2e2bcd8739ae039)
211
- };
212
- const $3f52bc2bbb9aa3d8$var$recommended = {
213
- plugins: [
214
- '@atlaspack'
215
- ],
216
- rules: {
217
- '@atlaspack/importcond-type-annotations': 'error',
218
- '@atlaspack/no-importcond-exports': 'error'
219
- }
220
- };
221
- const $3f52bc2bbb9aa3d8$export$ca524d3785e2543 = {
222
- meta: {
223
- name: $3f52bc2bbb9aa3d8$export$a8ff84c12d48cfa6,
224
- version: $3f52bc2bbb9aa3d8$export$83d89fbfd8236492
225
- },
226
- rules: $3f52bc2bbb9aa3d8$export$354076178bdef094,
227
- configs: {
228
- recommended: $3f52bc2bbb9aa3d8$var$recommended,
229
- get 'flat/recommended' () {
230
- return $3f52bc2bbb9aa3d8$var$flatRecommended;
231
- }
232
- }
233
- };
234
- const $3f52bc2bbb9aa3d8$var$flatRecommended = {
235
- plugins: {
236
- '@atlaspack': $3f52bc2bbb9aa3d8$export$ca524d3785e2543
237
- },
238
- rules: {
239
- '@atlaspack/importcond-type-annotations': 'error',
240
- '@atlaspack/no-importcond-exports': 'error'
241
- }
242
- };
243
- const $3f52bc2bbb9aa3d8$export$c884d9dcb329c3c = $3f52bc2bbb9aa3d8$export$ca524d3785e2543.configs;
244
- var $3f52bc2bbb9aa3d8$export$2e2bcd8739ae039 = $3f52bc2bbb9aa3d8$export$ca524d3785e2543;
245
-
246
-
247
- //# sourceMappingURL=index.js.map
package/lib/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAAA,iBAAiBE,KAAKC,KAAK,CAAC;;;;;;;;;;;;;AEA5B;;;ACOO,MAAMe,4CAAa4C,CAAAA,GAAAA,wCAAAA,EAAYC,WAAW,CAC9CzD,CAAAA,OACE,CAAA,4F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A,IACEA,KAAK2C,WAAW,CAAClD,IAAI,KAAK,oBAC1BO,KAAK2C,WAAW,CAAC1C,MAAM,CAACR,IAAI,KAAK,gBACjCO,KAAK2C,WAAW,CAAC1C,MAAM,CAACnC,IAAI,KAAK,cAEjCgC,QAAQgB,MAAM,CAAC;0BACbd;oBACAe,WAAW;gBACb;qBAEAe,wBAAwBK,GAAG,CAACnC;YAEhC;QACF;IACF;AACF;IAEA,2CAAeZ;;;;AHrHR,MAAM,QAACtB,yCAAI,WAAEC,yCAAAA,EAAQ,GAC1BC;AAEK,MAAMC,4CAAQ;IACnB,+BAA+BL,CAAAA,GAAAA,wCAAAA;IAC/B,yBAAyBC,CAAAA,GAAAA,wCAAzB;AACF;AAEA,MAAMK,oCAAc;IAClBC,SAAS;QAAC;KAAa;IACvBF,OAAO;QACL,0CAA0C;QAC1C,oCAAoC;IACtC;AACF;AAEO,MAAMI,2CAAS;IACpBC,MAAM;cACJR;iBACAC;IACF;WACAE;IACAM,SAAS;qBACPL;QACA,IAAI,sBAAqB;YACvB,OAAOO;QACT;IACF;AACF;AAEA,MAAMA,wCAAkB;IACtBN,SAAS;QACP,cAAcE;IAChB;IACAJ,OAAO;QACL,0CAA0C;QAC1C,oCAAoC;IACtC;AACF;AAEO,MAAMM,2CAAUF,yCAAOE,OAAO;IAErC,2CAAeF","sources":["packages/core/eslint-plugin/package.json","packages/core/eslint-plugin/src/index.ts","packages/core/eslint-plugin/src/rules/importcond-type-annotations/index.ts","packages/core/eslint-plugin/src/utils/index.ts","packages/core/eslint-plugin/src/rules/no-importcond-exports/index.ts"],"sourcesContent":["{\n \"name\": \"@atlaspack/eslint-plugin\",\n \"version\": \"2.14.2-dev.3853+84eec3484\",\n \"license\": \"(MIT OR Apache-2.0)\",\n \"main\": \"lib/index.js\",\n \"types\": \"lib/index.d.ts\",\n \"source\": \"src/index.ts\",\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"https://github.com/atlassian-labs/atlaspack.git\"\n },\n \"publishConfig\": {\n \"access\": \"public\"\n },\n \"engines\": {\n \"node\": \">= 16.0.0\"\n },\n \"dependencies\": {\n \"@typescript-eslint/utils\": \"^8.31.1\"\n },\n \"devDependencies\": {\n \"@typescript-eslint/rule-tester\": \"^8.31.1\",\n \"typescript-eslint\": \"^8.31.1\"\n },\n \"peerDependencies\": {\n \"eslint\": \"^8.57.0 || ^9.0.0\"\n },\n \"gitHead\": \"84eec348413c647de4872f902c4bc8ff54c347f3\"\n}\n","import importCondTypeAnnotationsRule from './rules/importcond-type-annotations';\nimport noImportCondExportsRule from './rules/no-importcond-exports';\n\n// eslint-disable-next-line @typescript-eslint/no-require-imports\nexport const {name, version} =\n require('../package.json') as typeof import('../package.json');\n\nexport const rules = {\n 'importcond-type-annotations': importCondTypeAnnotationsRule,\n 'no-importcond-exports': noImportCondExportsRule,\n};\n\nconst recommended = {\n plugins: ['@atlaspack'],\n rules: {\n '@atlaspack/importcond-type-annotations': 'error',\n '@atlaspack/no-importcond-exports': 'error',\n },\n} as const;\n\nexport const plugin = {\n meta: {\n name,\n version,\n },\n rules,\n configs: {\n recommended,\n get 'flat/recommended'() {\n return flatRecommended;\n },\n },\n} as const;\n\nconst flatRecommended = {\n plugins: {\n '@atlaspack': plugin,\n },\n rules: {\n '@atlaspack/importcond-type-annotations': 'error',\n '@atlaspack/no-importcond-exports': 'error',\n },\n} as const;\n\nexport const configs = plugin.configs;\n\nexport default plugin;\n","/**\n * @file Automatically adds type annotations for conditional import (importCond) usages\n */\nimport type {TSESTree} from '@typescript-eslint/utils';\nimport {createRule} from '../../utils/index';\n\nexport const RULE_NAME = 'importcond-type-annotations';\n\nexport const messages = {\n addTypeAnnotation:\n 'This conditional import usage needs a type annotation. Please apply the autofix so that the type annotation is correct.',\n wrongTypeAnnotation:\n 'The type annotation for this conditional import usage is incorrect. Please apply the suggestion to fix it.',\n suggestTypeAnnotation:\n 'Fix the type annotation for this conditional import usage.',\n}; // satisfies Record<string, string>; // Uncomment this line once prettier is updated to a version that supports it\n\nexport type Options = [];\n\nconst generateFix = (\n firstArgText: string,\n secondArgText: string,\n thirdArgText: string,\n): string => {\n const correctTypeAnnotation = `<typeof import(${secondArgText}), typeof import(${thirdArgText})>`;\n return `importCond${correctTypeAnnotation}(${firstArgText}, ${secondArgText}, ${thirdArgText})`;\n};\n\nconst rule = createRule<Options, keyof typeof messages>({\n name: RULE_NAME,\n meta: {\n docs: {\n description:\n 'Ensures that importCond function calls have correct type annotations.',\n recommended: true,\n },\n messages,\n schema: [],\n type: 'problem',\n fixable: 'code',\n hasSuggestions: true,\n },\n defaultOptions: [],\n create(context) {\n return {\n CallExpression(node) {\n // Check if the function being called is `importCond`\n // Note that this is a global, so we don't need to check the imports\n if (\n node.callee.type === 'Identifier' &&\n node.callee.name === 'importCond'\n ) {\n const args = node.arguments;\n\n // Ensure there are at least 3 arguments\n // If not, then there will be type-checking errors anyway\n if (args.length < 3) {\n return;\n }\n\n const [firstArg, secondArg, thirdArg] = args;\n\n // Get the source code for the arguments\n const {sourceCode} = context;\n const firstArgText = sourceCode.getText(firstArg);\n const secondArgText = sourceCode.getText(secondArg);\n const thirdArgText = sourceCode.getText(thirdArg);\n\n // Check if the type annotation is missing or incorrect\n // Whether it's called typeArguments or typeParameters depends on the version of typescript-eslint\n const typeArguments:\n | TSESTree.TSTypeParameterInstantiation\n | undefined = node.typeArguments ?? (node as any).typeParameters;\n if (!typeArguments) {\n // No type annotation exists at all\n context.report({\n node,\n messageId: 'addTypeAnnotation',\n // Apply autofix instead of suggestion, because there was no type annotation in the first place.\n fix: (fixer) => {\n const fixedCode = generateFix(\n firstArgText,\n secondArgText,\n thirdArgText,\n );\n return fixer.replaceText(node, fixedCode);\n },\n });\n } else if (\n typeArguments.params.length !== 2 ||\n sourceCode.getText(typeArguments.params[0]) !==\n `typeof import(${secondArgText})` ||\n sourceCode.getText(typeArguments.params[1]) !==\n `typeof import(${thirdArgText})`\n ) {\n // Type annotation is present, but incorrect\n context.report({\n node,\n messageId: 'wrongTypeAnnotation',\n // We should be more cautious here, so we make it a suggestion instead of an autofix\n suggest: [\n {\n messageId: 'suggestTypeAnnotation',\n fix: (fixer) => {\n const fixedCode = generateFix(\n firstArgText,\n secondArgText,\n thirdArgText,\n );\n return fixer.replaceText(node, fixedCode);\n },\n },\n ],\n });\n }\n }\n },\n };\n },\n});\n\nexport default rule;\n","import {ESLintUtils} from '@typescript-eslint/utils';\n\nexport interface PluginDocs {\n description: string;\n recommended?: boolean;\n}\n\nexport const createRule = ESLintUtils.RuleCreator<PluginDocs>(\n (name) =>\n `https://github.com/atlassian-labs/atlaspack/tree/main/packages/core/eslint-plugin/src/rules/${name}/README.md`,\n);\n","/**\n * @file Bans directly exporting Atlaspack conditional imports (importCond) from a file, as this is not expressly supported and will break in tests.\n */\nimport {createRule} from '../../utils/index';\nimport {TSESTree} from '@typescript-eslint/utils';\n\nexport const RULE_NAME = 'no-importcond-exports';\n\nexport const messages = {\n noImportCondExports:\n 'Directly exporting Atlaspack conditional imports (importCond) from a file is not supported and will break in tests. If you need the component for testing, please import the old and new versions of the components or modules directly in the test file instead.\\n\\n' +\n 'Does your use case require exporting the component? Reach out to #atlaspack-contextual-imports so we can help find a workaround.',\n}; // satisfies Record<string, string>; // Uncomment this line once prettier is updated to a version that supports it\n\nexport type Options = [];\n\nconst rule = createRule<Options, keyof typeof messages>({\n name: RULE_NAME,\n meta: {\n docs: {\n description:\n 'Bans directly exporting Atlaspack conditional imports (importCond) from a file, as this is not expressly supported and will break in tests.',\n recommended: true,\n },\n messages,\n schema: [],\n type: 'problem',\n },\n defaultOptions: [],\n create(context) {\n // Track variables initialized with `importCond`\n const importCondVariables = new Set<string>();\n const namedExportStatements = new Set<TSESTree.ExportNamedDeclaration>();\n const defaultExportStatements =\n new Set<TSESTree.ExportDefaultDeclaration>();\n\n return {\n VariableDeclarator(node) {\n if (\n node.init &&\n node.init.type === 'CallExpression' &&\n node.init.callee.type === 'Identifier' &&\n node.init.callee.name === 'importCond' &&\n node.id.type === 'Identifier'\n ) {\n // Add the variable name to the tracked set\n importCondVariables.add(node.id.name);\n }\n },\n 'Program:exit'(_node) {\n // Check if any named export references a tracked variable\n for (const exportStatement of namedExportStatements) {\n exportStatement.specifiers.forEach((specifier) => {\n if (\n specifier.type === 'ExportSpecifier' &&\n specifier.local.type === 'Identifier' &&\n importCondVariables.has(specifier.local.name)\n ) {\n context.report({\n node: specifier,\n messageId: 'noImportCondExports',\n });\n }\n });\n }\n\n for (const exportStatement of defaultExportStatements) {\n if (\n exportStatement.declaration.type === 'Identifier' &&\n importCondVariables.has(exportStatement.declaration.name)\n ) {\n context.report({\n node: exportStatement,\n messageId: 'noImportCondExports',\n });\n }\n }\n },\n ExportNamedDeclaration(node) {\n // Check if a variable declaration is directly exported\n if (\n node.declaration &&\n node.declaration.type === 'VariableDeclaration' &&\n node.declaration.declarations\n ) {\n node.declaration.declarations.forEach((declaration) => {\n if (\n declaration.init &&\n declaration.init.type === 'CallExpression' &&\n declaration.init.callee.type === 'Identifier' &&\n declaration.init.callee.name === 'importCond'\n ) {\n context.report({\n node: declaration,\n messageId: 'noImportCondExports',\n });\n }\n });\n } else {\n namedExportStatements.add(node);\n }\n },\n ExportDefaultDeclaration(node) {\n // Check if the default export is a tracked variable or an `importCond` call\n if (\n node.declaration.type === 'CallExpression' &&\n node.declaration.callee.type === 'Identifier' &&\n node.declaration.callee.name === 'importCond'\n ) {\n context.report({\n node,\n messageId: 'noImportCondExports',\n });\n } else {\n defaultExportStatements.add(node);\n }\n },\n };\n },\n});\n\nexport default rule;\n"],"names":["module","exports","JSON","parse","importCondTypeAnnotationsRule","noImportCondExportsRule","name","version","require","rules","recommended","plugins","const","plugin","meta","configs","flat/recommended","flatRecommended","createRule","RULE_NAME","messages","addTypeAnnotation","wrongTypeAnnotation","suggestTypeAnnotation","generateFix","firstArgText","secondArgText","thirdArgText","rule","Options","docs","description","schema","type","fixable","hasSuggestions","defaultOptions","create","context","CallExpression","node","callee","args","arguments","length","firstArg","secondArg","thirdArg","sourceCode","getText","typeArguments","TSESTree","TSTypeParameterInstantiation","typeParameters","report","messageId","fix","fixer","fixedCode","replaceText","params","suggest","ESLintUtils","RuleCreator","PluginDocs","noImportCondExports","importCondVariables","Set","namedExportStatements","ExportNamedDeclaration","defaultExportStatements","ExportDefaultDeclaration","VariableDeclarator","init","id","add","Program:exit","exportStatement","specifiers","forEach","specifier","local","has","declaration","declarations"],"version":3,"file":"index.js.map","sourceRoot":"../../../../"}