@atlaspack/eslint-plugin 2.14.2-typescript-8a6ec6c8b.0 → 2.14.2-typescript-e769947a5.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.
package/lib/index.d.ts CHANGED
@@ -24,7 +24,26 @@ export const plugin: {
24
24
  };
25
25
  readonly 'flat/recommended': {
26
26
  readonly plugins: {
27
- readonly '@atlaspack': any;
27
+ readonly '@atlaspack': {
28
+ readonly meta: {
29
+ readonly name: string;
30
+ readonly version: string;
31
+ };
32
+ readonly rules: {
33
+ 'importcond-type-annotations': RuleModule<"addTypeAnnotation" | "wrongTypeAnnotation" | "suggestTypeAnnotation", [], PluginDocs, RuleListener>;
34
+ 'no-importcond-exports': RuleModule<"noImportCondExports", [], PluginDocs, RuleListener>;
35
+ };
36
+ readonly 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': /*elided*/ any;
45
+ };
46
+ };
28
47
  };
29
48
  readonly rules: {
30
49
  readonly '@atlaspack/importcond-type-annotations': "error";
@@ -43,7 +62,17 @@ export const configs: {
43
62
  };
44
63
  readonly 'flat/recommended': {
45
64
  readonly plugins: {
46
- readonly '@atlaspack': any;
65
+ readonly '@atlaspack': {
66
+ readonly meta: {
67
+ readonly name: string;
68
+ readonly version: string;
69
+ };
70
+ readonly rules: {
71
+ 'importcond-type-annotations': RuleModule<"addTypeAnnotation" | "wrongTypeAnnotation" | "suggestTypeAnnotation", [], PluginDocs, RuleListener>;
72
+ 'no-importcond-exports': RuleModule<"noImportCondExports", [], PluginDocs, RuleListener>;
73
+ };
74
+ readonly configs: /*elided*/ any;
75
+ };
47
76
  };
48
77
  readonly rules: {
49
78
  readonly '@atlaspack/importcond-type-annotations': "error";
@@ -1 +1 @@
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":"../../../../"}
1
+ {"mappings":";;AGGA,OAAO,mCAEyD,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\nexport const {name, version} =\n // eslint-disable-next-line @typescript-eslint/no-var-requires, @typescript-eslint/no-require-imports\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 CHANGED
@@ -43,7 +43,7 @@ if (parcelRequire == null) {
43
43
 
44
44
  var parcelRegister = parcelRequire.register;
45
45
  parcelRegister("ge4Mt", function(module, exports) {
46
- module.exports = JSON.parse("{\"name\":\"@atlaspack/eslint-plugin\",\"version\":\"2.14.2-typescript-8a6ec6c8b.0\",\"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\":\"8a6ec6c8bed0bbf5461f5b0f899577a576906051\"}");
46
+ module.exports = JSON.parse("{\"name\":\"@atlaspack/eslint-plugin\",\"version\":\"2.14.2-typescript-e769947a5.0\",\"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\"},\"scripts\":{\"check-ts\":\"tsc --noEmit --project .\"},\"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/types\":\"^8.31.1\",\"typescript-eslint\":\"^8.31.1\"},\"peerDependencies\":{\"eslint\":\"^8.57.0 || ^9.0.0\"},\"gitHead\":\"e769947a5b0c22d9477211ac1ce6614e6bf9def3\"}");
47
47
 
48
48
  });
49
49
 
@@ -167,6 +167,7 @@ const $f0c6a78c725779ec$var$rule = (0, $2f8f3cc371e6d9a5$export$56e87122f905fac0
167
167
  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
168
168
  importCondVariables.add(node.id.name);
169
169
  },
170
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
170
171
  'Program:exit' (_node) {
171
172
  // Check if any named export references a tracked variable
172
173
  for (const exportStatement of namedExportStatements)exportStatement.specifiers.forEach((specifier)=>{
@@ -205,7 +206,8 @@ var $f0c6a78c725779ec$export$2e2bcd8739ae039 = $f0c6a78c725779ec$var$rule;
205
206
 
206
207
 
207
208
 
208
- const { name: $3f52bc2bbb9aa3d8$export$a8ff84c12d48cfa6, version: $3f52bc2bbb9aa3d8$export$83d89fbfd8236492 } = (parcelRequire("ge4Mt"));
209
+ const { name: $3f52bc2bbb9aa3d8$export$a8ff84c12d48cfa6, version: $3f52bc2bbb9aa3d8$export$83d89fbfd8236492 } = // eslint-disable-next-line @typescript-eslint/no-var-requires, @typescript-eslint/no-require-imports
210
+ (parcelRequire("ge4Mt"));
209
211
  const $3f52bc2bbb9aa3d8$export$354076178bdef094 = {
210
212
  'importcond-type-annotations': (0, $62ed09825cfca72a$export$2e2bcd8739ae039),
211
213
  'no-importcond-exports': (0, $f0c6a78c725779ec$export$2e2bcd8739ae039)
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAAA,iBAAiBE,KAAKC,KAAK,CAAC;;;;;;;;;;;;;AEA5B;;;ACOO,MAAMe,4CAAa6C,CAAAA,GAAAA,wCAAAA,EAAYC,WAAW,CAC9C1D,CAAAA,OACE,CAAA,4FAAA,EAA8FA,KAAK,UAAA,CACxG;;CDRA;AAIO,MAAMa,4CAAY;AAElB,MAAMC,4CAAW;IACtBC,mBACE;IACFC,qBACE;IACFC,uBACE;AACJ,GAAG,oHAAH;AAIA,MAAMC,oCAAcA,CAClBC,cACAC,eACAC;IAEA,MAAMC,wBAAyB,CAAA,eAAA,EAAiBF,cAAc,iBAAA,EAAmBC,aAAa,EAAA,CAAG;IACjG,OAAQ,CAAA,UAAA,EAAYC,sBAAsB,CAAA,EAAGH,aAAa,EAAA,EAAIC,cAAc,EAAA,EAAIC,a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EC,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-typescript-8a6ec6c8b.0\",\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\": \"8a6ec6c8bed0bbf5461f5b0f899577a576906051\"\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","correctTypeAnnotation","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","_node","exportStatement","specifiers","forEach","specifier","local","has","declaration","declarations"],"version":3,"file":"index.js.map","sourceRoot":"../../../../"}
1
+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BmD,YAAYX,IAAI,CAAChC,MAAM,CAACR,IAAI,KAAK,gBACjCmD,YAAYX,IAAI,CAAChC,MAAM,CAACpC,IAAI,KAAK,cAEjCiC,QAAQgB,MAAM,CAAC;wBACbd,MAAM4C;wBACN7B,WAAW;oBACb;gBAEJ;qBAEAa,sBAAsBO,GAAG,CAACnC;YAE9B;YACA+B,0BAAyB/B,IAAI;gBAC3B,4EAAA;gBACA,IACEA,KAAK4C,WAAW,CAACnD,IAAI,KAAK,oBAC1BO,KAAK4C,WAAW,CAAC3C,MAAM,CAACR,IAAI,KAAK,gBACjCO,KAAK4C,WAAW,CAAC3C,MAAM,CAACpC,IAAI,KAAK,cAEjCiC,QAAQgB,MAAM,CAAC;0BACbd;oBACAe,WAAW;gBACb;qBAEAe,wBAAwBK,GAAG,CAACnC;YAEhC;QACF;IACF;AACF;IAEA,2CAAeZ;;;;AHvHR,MAAM,QAACvB,yCAAI,WAAEC,yCAAAA,EAAQ,GAC1B,qGAAA;AACAC;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-typescript-e769947a5.0\",\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 \"scripts\": {\n \"check-ts\": \"tsc --noEmit --project .\"\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/types\": \"^8.31.1\",\n \"typescript-eslint\": \"^8.31.1\"\n },\n \"peerDependencies\": {\n \"eslint\": \"^8.57.0 || ^9.0.0\"\n },\n \"gitHead\": \"e769947a5b0c22d9477211ac1ce6614e6bf9def3\"\n}\n","import importCondTypeAnnotationsRule from './rules/importcond-type-annotations';\nimport noImportCondExportsRule from './rules/no-importcond-exports';\n\nexport const {name, version} =\n // eslint-disable-next-line @typescript-eslint/no-var-requires, @typescript-eslint/no-require-imports\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 */\n\nimport type {TSESTree} from '@typescript-eslint/types';\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 // eslint-disable-next-line @typescript-eslint/no-explicit-any\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 // eslint-disable-next-line @typescript-eslint/no-unused-vars\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","correctTypeAnnotation","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","_node","exportStatement","specifiers","forEach","specifier","local","has","declaration","declarations"],"version":3,"file":"index.js.map","sourceRoot":"../../../../"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaspack/eslint-plugin",
3
- "version": "2.14.2-typescript-8a6ec6c8b.0",
3
+ "version": "2.14.2-typescript-e769947a5.0",
4
4
  "license": "(MIT OR Apache-2.0)",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
@@ -9,6 +9,9 @@
9
9
  "type": "git",
10
10
  "url": "https://github.com/atlassian-labs/atlaspack.git"
11
11
  },
12
+ "scripts": {
13
+ "check-ts": "tsc --noEmit --project ."
14
+ },
12
15
  "publishConfig": {
13
16
  "access": "public"
14
17
  },
@@ -20,10 +23,11 @@
20
23
  },
21
24
  "devDependencies": {
22
25
  "@typescript-eslint/rule-tester": "^8.31.1",
26
+ "@typescript-eslint/types": "^8.31.1",
23
27
  "typescript-eslint": "^8.31.1"
24
28
  },
25
29
  "peerDependencies": {
26
30
  "eslint": "^8.57.0 || ^9.0.0"
27
31
  },
28
- "gitHead": "8a6ec6c8bed0bbf5461f5b0f899577a576906051"
32
+ "gitHead": "e769947a5b0c22d9477211ac1ce6614e6bf9def3"
29
33
  }
package/src/index.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  import importCondTypeAnnotationsRule from './rules/importcond-type-annotations';
2
2
  import noImportCondExportsRule from './rules/no-importcond-exports';
3
3
 
4
- // eslint-disable-next-line @typescript-eslint/no-require-imports
5
4
  export const {name, version} =
5
+ // eslint-disable-next-line @typescript-eslint/no-var-requires, @typescript-eslint/no-require-imports
6
6
  require('../package.json') as typeof import('../package.json');
7
7
 
8
8
  export const rules = {
@@ -1,7 +1,8 @@
1
1
  /**
2
2
  * @file Automatically adds type annotations for conditional import (importCond) usages
3
3
  */
4
- import type {TSESTree} from '@typescript-eslint/utils';
4
+
5
+ import type {TSESTree} from '@typescript-eslint/types';
5
6
  import {createRule} from '../../utils/index';
6
7
 
7
8
  export const RULE_NAME = 'importcond-type-annotations';
@@ -70,6 +71,7 @@ const rule = createRule<Options, keyof typeof messages>({
70
71
  // Whether it's called typeArguments or typeParameters depends on the version of typescript-eslint
71
72
  const typeArguments:
72
73
  | TSESTree.TSTypeParameterInstantiation
74
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
73
75
  | undefined = node.typeArguments ?? (node as any).typeParameters;
74
76
  if (!typeArguments) {
75
77
  // No type annotation exists at all
@@ -47,6 +47,7 @@ const rule = createRule<Options, keyof typeof messages>({
47
47
  importCondVariables.add(node.id.name);
48
48
  }
49
49
  },
50
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
50
51
  'Program:exit'(_node) {
51
52
  // Check if any named export references a tracked variable
52
53
  for (const exportStatement of namedExportStatements) {
package/test/utils.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import * as mocha from 'mocha';
2
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
2
3
  import tseslint from 'typescript-eslint';
3
4
  import {RuleTester} from '@typescript-eslint/rule-tester';
4
- import path from 'node:path';
5
5
 
6
6
  RuleTester.afterAll = mocha.after;
7
7