@checkdigit/eslint-plugin 7.7.0-PR.107-79c1 → 7.7.0-PR.107-46e4

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.
@@ -29,12 +29,14 @@ var rule = createRule({
29
29
  return {
30
30
  ImportDeclaration(node) {
31
31
  const importPath = node.source.value;
32
- if (importPath.startsWith(".") && !importPath.endsWith(".ts") && !importPath.endsWith(".json") && !SERVICE_TYPINGS_IMPORT_PATH_PREFIX.test(importPath)) {
32
+ if (importPath.startsWith(".") && !importPath.endsWith(".ts") && !importPath.endsWith(".json")) {
33
+ const isServiceTypingImport = SERVICE_TYPINGS_IMPORT_PATH_PREFIX.test(importPath);
34
+ const newImportPath = isServiceTypingImport && !importPath.endsWith("/index.ts") ? `${importPath}/index.ts` : `${importPath}.ts`;
33
35
  context.report({
34
36
  loc: node.source.loc,
35
37
  messageId: REQUIRE_TS_EXTENSION_IMPORTS,
36
38
  *fix(fixer) {
37
- yield fixer.replaceText(node.source, `'${importPath}.ts'`);
39
+ yield fixer.replaceText(node.source, `'${newImportPath}'`);
38
40
  }
39
41
  });
40
42
  }
@@ -47,4 +49,4 @@ export {
47
49
  require_ts_extension_imports_default as default,
48
50
  ruleId
49
51
  };
50
- //# sourceMappingURL=data:application/json;base64,ewogICJ2ZXJzaW9uIjogMywKICAic291cmNlcyI6IFsiLi4vc3JjL3JlcXVpcmUtdHMtZXh0ZW5zaW9uLWltcG9ydHMudHMiXSwKICAibWFwcGluZ3MiOiAiO0FBUUEsU0FBUyxtQkFBbUI7QUFDNUIsT0FBTyx5QkFBeUI7QUFFekIsSUFBTSxTQUFTO0FBQ3RCLElBQU0sK0JBQStCO0FBQ3JDLElBQU0scUNBQXFDO0FBRTNDLElBQU0sYUFBeUQsWUFBWTtBQUFBLEVBQVksQ0FBQyxTQUN0RixvQkFBb0IsSUFBSTtBQUMxQjtBQUVBLElBQU0sT0FBc0MsV0FBVztBQUFBLEVBQ3JELE1BQU07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IsS0FBSyxLQUFLLE9BQU87QUFBQSxZQUNqQixXQUFXO0FBQUEsWUFDWCxDQUFDLElBQUksT0FBTztBQUNWLG9CQUFNLE1BQU0sWUFBWSxLQUFLLFFBQVEsSUFBSSxhQUFhLEdBQUc7QUFBQSxZQUMzRDtBQUFBLFVBQ0YsQ0FBQztBQUFBLFFBQ0g7QUFBQSxNQUNGO0FBQUEsSUFDRjtBQUFBLEVBQ0Y7QUFDRixDQUFDO0FBRUQsSUFBTyx1Q0FBUTsiLAogICJuYW1lcyI6IFtdCn0K
package/package.json CHANGED
@@ -1 +1 @@
1
- {"name":"@checkdigit/eslint-plugin","version":"7.7.0-PR.107-79c1","description":"Check Digit eslint plugins","keywords":["eslint","eslintplugin"],"homepage":"https://github.com/checkdigit/eslint-plugin#readme","bugs":{"url":"https://github.com/checkdigit/eslint-plugin/issues"},"repository":{"type":"git","url":"https://github.com/checkdigit/eslint-plugin"},"license":"MIT","author":"Check Digit, LLC","sideEffects":false,"type":"module","exports":{".":{"types":"./dist-types/index.d.ts","import":"./dist-mjs/index.mjs","default":"./dist-mjs/index.mjs"}},"files":["src","dist-types","dist-mjs","!src/**/test/**","!src/**/*.test.ts","!src/**/*.spec.ts","!dist-types/**/test/**","!dist-types/**/*.test.d.ts","!dist-types/**/*.spec.d.ts","!dist-mjs/**/test/**","!dist-mjs/**/*.test.mjs","!dist-mjs/**/*.spec.mjs","SECURITY.md"],"scripts":{"build:dist-mjs":"rimraf dist-mjs && npx builder --type=module --sourceMap --outDir=dist-mjs && node dist-mjs/index.mjs","build:dist-types":"rimraf dist-types && npx builder --type=types --outDir=dist-types","ci:compile":"tsc --noEmit","ci:coverage":"NODE_OPTIONS=\"--disable-warning ExperimentalWarning --experimental-vm-modules\" jest --coverage=true","ci:lint":"npm run lint","ci:style":"npm run prettier","ci:test":"NODE_OPTIONS=\"--disable-warning ExperimentalWarning --experimental-vm-modules\" jest --coverage=false","lint":"eslint --max-warnings 0 .","lint:fix":"eslint --max-warnings 0 --fix .","prepare":"","prepublishOnly":"npm run build:dist-types && npm run build:dist-mjs","prettier":"prettier --ignore-path .gitignore --list-different .","prettier:fix":"prettier --ignore-path .gitignore --write .","test":"npm run ci:compile && npm run ci:test && npm run ci:lint && npm run ci:style"},"prettier":"@checkdigit/prettier-config","jest":{"preset":"@checkdigit/jest-config"},"dependencies":{"@typescript-eslint/type-utils":"^8.18.0","@typescript-eslint/utils":"^8.18.0","ts-api-utils":"^2.0.0"},"devDependencies":{"@checkdigit/jest-config":"^6.0.2","@checkdigit/prettier-config":"^6.0.0","@checkdigit/typescript-config":"^9.0.0","@eslint/js":"^9.16.0","@types/eslint":"^9.6.1","@types/eslint-config-prettier":"^6.11.3","@typescript-eslint/parser":"^8.18.0","@typescript-eslint/rule-tester":"^8.18.0","eslint":"^9.16.0","eslint-config-prettier":"^9.1.0","eslint-import-resolver-typescript":"^3.7.0","eslint-plugin-eslint-plugin":"^6.3.2","eslint-plugin-import":"^2.31.0","eslint-plugin-no-only-tests":"^3.3.0","eslint-plugin-no-secrets":"^2.1.1","eslint-plugin-node":"^11.1.0","eslint-plugin-sonarjs":"1.0.4","http-status-codes":"^2.3.0","rimraf":"^6.0.1","typescript-eslint":"^8.18.0"},"peerDependencies":{"eslint":">=9 <10"},"engines":{"node":">=20.17"}}
1
+ {"name":"@checkdigit/eslint-plugin","version":"7.7.0-PR.107-46e4","description":"Check Digit eslint plugins","keywords":["eslint","eslintplugin"],"homepage":"https://github.com/checkdigit/eslint-plugin#readme","bugs":{"url":"https://github.com/checkdigit/eslint-plugin/issues"},"repository":{"type":"git","url":"https://github.com/checkdigit/eslint-plugin"},"license":"MIT","author":"Check Digit, LLC","sideEffects":false,"type":"module","exports":{".":{"types":"./dist-types/index.d.ts","import":"./dist-mjs/index.mjs","default":"./dist-mjs/index.mjs"}},"files":["src","dist-types","dist-mjs","!src/**/test/**","!src/**/*.test.ts","!src/**/*.spec.ts","!dist-types/**/test/**","!dist-types/**/*.test.d.ts","!dist-types/**/*.spec.d.ts","!dist-mjs/**/test/**","!dist-mjs/**/*.test.mjs","!dist-mjs/**/*.spec.mjs","SECURITY.md"],"scripts":{"build:dist-mjs":"rimraf dist-mjs && npx builder --type=module --sourceMap --outDir=dist-mjs && node dist-mjs/index.mjs","build:dist-types":"rimraf dist-types && npx builder --type=types --outDir=dist-types","ci:compile":"tsc --noEmit","ci:coverage":"NODE_OPTIONS=\"--disable-warning ExperimentalWarning --experimental-vm-modules\" jest --coverage=true","ci:lint":"npm run lint","ci:style":"npm run prettier","ci:test":"NODE_OPTIONS=\"--disable-warning ExperimentalWarning --experimental-vm-modules\" jest --coverage=false","lint":"eslint --max-warnings 0 .","lint:fix":"eslint --max-warnings 0 --fix .","prepare":"","prepublishOnly":"npm run build:dist-types && npm run build:dist-mjs","prettier":"prettier --ignore-path .gitignore --list-different .","prettier:fix":"prettier --ignore-path .gitignore --write .","test":"npm run ci:compile && npm run ci:test && npm run ci:lint && npm run ci:style"},"prettier":"@checkdigit/prettier-config","jest":{"preset":"@checkdigit/jest-config"},"dependencies":{"@typescript-eslint/type-utils":"^8.18.0","@typescript-eslint/utils":"^8.18.0","ts-api-utils":"^2.0.0"},"devDependencies":{"@checkdigit/jest-config":"^6.0.2","@checkdigit/prettier-config":"^6.0.0","@checkdigit/typescript-config":"^9.0.0","@eslint/js":"^9.16.0","@types/eslint":"^9.6.1","@types/eslint-config-prettier":"^6.11.3","@typescript-eslint/parser":"^8.18.0","@typescript-eslint/rule-tester":"^8.18.0","eslint":"^9.16.0","eslint-config-prettier":"^9.1.0","eslint-import-resolver-typescript":"^3.7.0","eslint-plugin-eslint-plugin":"^6.3.2","eslint-plugin-import":"^2.31.0","eslint-plugin-no-only-tests":"^3.3.0","eslint-plugin-no-secrets":"^2.1.1","eslint-plugin-node":"^11.1.0","eslint-plugin-sonarjs":"1.0.4","http-status-codes":"^2.3.0","rimraf":"^6.0.1","typescript-eslint":"^8.18.0"},"peerDependencies":{"eslint":">=9 <10"},"engines":{"node":">=20.17"}}
@@ -11,6 +11,8 @@ import getDocumentationUrl from './get-documentation-url.ts';
11
11
 
12
12
  export const ruleId = 'require-ts-extension-imports';
13
13
  const REQUIRE_TS_EXTENSION_IMPORTS = 'REQUIRE-TS-EXTENSION-IMPORTS';
14
+
15
+ // Matches paths that start with one or more ../, followed by services
14
16
  const SERVICE_TYPINGS_IMPORT_PATH_PREFIX = /(?<path>\.\.\/)+services/u;
15
17
 
16
18
  const createRule: ReturnType<typeof ESLintUtils.RuleCreator> = ESLintUtils.RuleCreator((name) =>
@@ -39,17 +41,16 @@ const rule: ReturnType<typeof createRule> = createRule({
39
41
  return {
40
42
  ImportDeclaration(node) {
41
43
  const importPath = node.source.value;
42
- if (
43
- importPath.startsWith('.') &&
44
- !importPath.endsWith('.ts') &&
45
- !importPath.endsWith('.json') &&
46
- !SERVICE_TYPINGS_IMPORT_PATH_PREFIX.test(importPath)
47
- ) {
44
+ if (importPath.startsWith('.') && !importPath.endsWith('.ts') && !importPath.endsWith('.json')) {
45
+ const isServiceTypingImport = SERVICE_TYPINGS_IMPORT_PATH_PREFIX.test(importPath);
46
+ const newImportPath =
47
+ isServiceTypingImport && !importPath.endsWith('/index.ts') ? `${importPath}/index.ts` : `${importPath}.ts`;
48
+
48
49
  context.report({
49
50
  loc: node.source.loc,
50
51
  messageId: REQUIRE_TS_EXTENSION_IMPORTS,
51
52
  *fix(fixer) {
52
- yield fixer.replaceText(node.source, `'${importPath}.ts'`);
53
+ yield fixer.replaceText(node.source, `'${newImportPath}'`);
53
54
  },
54
55
  });
55
56
  }