@checkdigit/eslint-plugin 7.7.0-PR.107-a288 → 7.7.0-PR.107-b80e

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.
@@ -2,7 +2,6 @@
2
2
  import path from "path";
3
3
  import fs from "fs";
4
4
  import { ESLintUtils } from "@typescript-eslint/utils";
5
- import "@typescript-eslint/typescript-estree";
6
5
  import getDocumentationUrl from "./get-documentation-url.mjs";
7
6
  var ruleId = "require-ts-extension-imports";
8
7
  var REQUIRE_TS_EXTENSION_IMPORTS = "REQUIRE-TS-EXTENSION-IMPORTS";
@@ -30,16 +29,18 @@ var rule = createRule({
30
29
  const importPath = node.source.value;
31
30
  if (importPath.startsWith(".") && !importPath.endsWith(".ts") && !importPath.endsWith(".json")) {
32
31
  const absoluteImportPath = path.resolve(path.dirname(filename), importPath);
33
- const stats = fs.statSync(absoluteImportPath);
34
- const isDirectory = stats.isDirectory();
35
- const fixedPath = isDirectory ? `${importPath}/index.ts` : `${importPath}.ts`;
36
- context.report({
37
- loc: node.source.loc,
38
- messageId: REQUIRE_TS_EXTENSION_IMPORTS,
39
- *fix(fixer) {
40
- yield fixer.replaceText(node.source, `'${fixedPath}'`);
41
- }
42
- });
32
+ if (fs.existsSync(absoluteImportPath) || fs.existsSync(`${absoluteImportPath}.ts`)) {
33
+ const stats = fs.existsSync(absoluteImportPath) ? fs.statSync(absoluteImportPath) : fs.statSync(`${absoluteImportPath}.ts`);
34
+ const isDirectory = stats.isDirectory();
35
+ const fixedPath = isDirectory ? `${importPath}/index.ts` : `${importPath}.ts`;
36
+ context.report({
37
+ loc: node.source.loc,
38
+ messageId: REQUIRE_TS_EXTENSION_IMPORTS,
39
+ *fix(fixer) {
40
+ yield fixer.replaceText(node.source, `'${fixedPath}'`);
41
+ }
42
+ });
43
+ }
43
44
  }
44
45
  }
45
46
  };
@@ -50,4 +51,4 @@ export {
50
51
  require_ts_extension_imports_default as default,
51
52
  ruleId
52
53
  };
53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it 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.1","@typescript-eslint/utils":"^8.18.1","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.17.0","@types/eslint":"^9.6.1","@types/eslint-config-prettier":"^6.11.3","@typescript-eslint/parser":"^8.18.1","@typescript-eslint/rule-tester":"^8.18.1","eslint":"^9.17.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.1"},"peerDependencies":{"eslint":">=9 <10"},"engines":{"node":">=20.17"}}
1
+ {"name":"@checkdigit/eslint-plugin","version":"7.7.0-PR.107-b80e","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.1","@typescript-eslint/utils":"^8.18.1","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.17.0","@types/eslint":"^9.6.1","@types/eslint-config-prettier":"^6.11.3","@typescript-eslint/parser":"^8.18.1","@typescript-eslint/rule-tester":"^8.18.1","eslint":"^9.17.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.1"},"peerDependencies":{"eslint":">=9 <10"},"engines":{"node":">=20.17"}}
@@ -9,7 +9,6 @@
9
9
  import path from 'path';
10
10
  import fs from 'fs';
11
11
  import { ESLintUtils } from '@typescript-eslint/utils';
12
- import { TSESTree } from '@typescript-eslint/typescript-estree';
13
12
  import getDocumentationUrl from './get-documentation-url.ts';
14
13
 
15
14
  export const ruleId = 'require-ts-extension-imports';
@@ -36,20 +35,24 @@ const rule: ReturnType<typeof createRule> = createRule({
36
35
  create(context) {
37
36
  const filename = context.filename;
38
37
  return {
39
- ImportDeclaration(node: TSESTree.ImportDeclaration) {
38
+ ImportDeclaration(node) {
40
39
  const importPath = node.source.value;
41
40
  if (importPath.startsWith('.') && !importPath.endsWith('.ts') && !importPath.endsWith('.json')) {
42
41
  const absoluteImportPath = path.resolve(path.dirname(filename), importPath);
43
- const stats = fs.statSync(absoluteImportPath);
44
- const isDirectory = stats.isDirectory();
45
- const fixedPath = isDirectory ? `${importPath}/index.ts` : `${importPath}.ts`;
46
- context.report({
47
- loc: node.source.loc,
48
- messageId: REQUIRE_TS_EXTENSION_IMPORTS,
49
- *fix(fixer) {
50
- yield fixer.replaceText(node.source, `'${fixedPath}'`);
51
- },
52
- });
42
+ if (fs.existsSync(absoluteImportPath) || fs.existsSync(`${absoluteImportPath}.ts`)) {
43
+ const stats = fs.existsSync(absoluteImportPath)
44
+ ? fs.statSync(absoluteImportPath)
45
+ : fs.statSync(`${absoluteImportPath}.ts`);
46
+ const isDirectory = stats.isDirectory();
47
+ const fixedPath = isDirectory ? `${importPath}/index.ts` : `${importPath}.ts`;
48
+ context.report({
49
+ loc: node.source.loc,
50
+ messageId: REQUIRE_TS_EXTENSION_IMPORTS,
51
+ *fix(fixer) {
52
+ yield fixer.replaceText(node.source, `'${fixedPath}'`);
53
+ },
54
+ });
55
+ }
53
56
  }
54
57
  },
55
58
  };