@checkdigit/eslint-plugin 7.7.0-PR.107-2ef2 → 7.7.0-PR.107-f3d4
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.
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
// src/require-ts-extension-imports.ts
|
|
2
|
-
import fs from "node:fs";
|
|
3
|
-
import { ESLintUtils } from "@typescript-eslint/utils";
|
|
4
2
|
import "@typescript-eslint/typescript-estree";
|
|
3
|
+
import { ESLintUtils } from "@typescript-eslint/utils";
|
|
5
4
|
import getDocumentationUrl from "./get-documentation-url.mjs";
|
|
6
5
|
var ruleId = "require-ts-extension-imports";
|
|
7
6
|
var REQUIRE_TS_EXTENSION_IMPORTS = "REQUIRE-TS-EXTENSION-IMPORTS";
|
|
@@ -30,14 +29,12 @@ var rule = createRule({
|
|
|
30
29
|
return {
|
|
31
30
|
ImportDeclaration(node) {
|
|
32
31
|
const importPath = node.source.value;
|
|
33
|
-
if (importPath.startsWith(".") && !importPath.endsWith(".ts") && !importPath.endsWith(".json")
|
|
34
|
-
const stats = fs.statSync(importPath);
|
|
35
|
-
const isDirectory = stats.isDirectory();
|
|
32
|
+
if (importPath.startsWith(".") && !importPath.endsWith(".ts") && !importPath.endsWith(".json")) {
|
|
36
33
|
context.report({
|
|
37
|
-
|
|
34
|
+
loc: node.source.loc,
|
|
38
35
|
messageId: REQUIRE_TS_EXTENSION_IMPORTS,
|
|
39
36
|
fix(fixer) {
|
|
40
|
-
const fixedPath =
|
|
37
|
+
const fixedPath = `${importPath}.ts`;
|
|
41
38
|
return fixer.replaceText(node.source, `'${fixedPath}'`);
|
|
42
39
|
}
|
|
43
40
|
});
|
|
@@ -51,4 +48,4 @@ export {
|
|
|
51
48
|
require_ts_extension_imports_default as default,
|
|
52
49
|
ruleId
|
|
53
50
|
};
|
|
54
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
51
|
+
//# sourceMappingURL=data:application/json;base64,ewogICJ2ZXJz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UFHLFVBQVU7QUFDL0IscUJBQU8sTUFBTSxZQUFZLEtBQUssUUFBUSxJQUFJLFNBQVMsR0FBRztBQUFBLFlBQ3hEO0FBQUEsVUFDRixDQUFDO0FBQUEsUUFDSDtBQUFBLE1BQ0Y7QUFBQSxJQUNGO0FBQUEsRUFDRjtBQUNGLENBQUM7QUFFRCxJQUFPLHVDQUFROyIsCiAgIm5hbWVzIjogW10KfQo=
|
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"@checkdigit/eslint-plugin","version":"7.7.0-PR.107-
|
|
1
|
+
{"name":"@checkdigit/eslint-plugin","version":"7.7.0-PR.107-f3d4","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"}}
|
|
@@ -6,9 +6,8 @@
|
|
|
6
6
|
* This code is licensed under the MIT license (see LICENSE.txt for details).
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import fs from 'node:fs';
|
|
10
|
-
import { ESLintUtils } from '@typescript-eslint/utils';
|
|
11
9
|
import { TSESTree } from '@typescript-eslint/typescript-estree';
|
|
10
|
+
import { ESLintUtils } from '@typescript-eslint/utils';
|
|
12
11
|
import getDocumentationUrl from './get-documentation-url.ts';
|
|
13
12
|
|
|
14
13
|
export const ruleId = 'require-ts-extension-imports';
|
|
@@ -40,19 +39,12 @@ const rule: ReturnType<typeof createRule> = createRule({
|
|
|
40
39
|
return {
|
|
41
40
|
ImportDeclaration(node: TSESTree.ImportDeclaration) {
|
|
42
41
|
const importPath = node.source.value;
|
|
43
|
-
if (
|
|
44
|
-
importPath.startsWith('.') &&
|
|
45
|
-
!importPath.endsWith('.ts') &&
|
|
46
|
-
!importPath.endsWith('.json') &&
|
|
47
|
-
fs.existsSync(importPath)
|
|
48
|
-
) {
|
|
49
|
-
const stats = fs.statSync(importPath);
|
|
50
|
-
const isDirectory = stats.isDirectory();
|
|
42
|
+
if (importPath.startsWith('.') && !importPath.endsWith('.ts') && !importPath.endsWith('.json')) {
|
|
51
43
|
context.report({
|
|
52
|
-
|
|
44
|
+
loc: node.source.loc,
|
|
53
45
|
messageId: REQUIRE_TS_EXTENSION_IMPORTS,
|
|
54
46
|
fix(fixer) {
|
|
55
|
-
const fixedPath =
|
|
47
|
+
const fixedPath = `${importPath}.ts`;
|
|
56
48
|
return fixer.replaceText(node.source, `'${fixedPath}'`);
|
|
57
49
|
},
|
|
58
50
|
});
|