@checkdigit/eslint-plugin 7.7.0-PR.107-e11e → 7.7.0-PR.107-5830
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,4 +1,5 @@
|
|
|
1
1
|
// src/require-ts-extension-imports.ts
|
|
2
|
+
import path from "path";
|
|
2
3
|
import fs from "fs";
|
|
3
4
|
import { ESLintUtils } from "@typescript-eslint/utils";
|
|
4
5
|
import "@typescript-eslint/typescript-estree";
|
|
@@ -24,14 +25,12 @@ var rule = createRule({
|
|
|
24
25
|
defaultOptions: [],
|
|
25
26
|
create(context) {
|
|
26
27
|
const filename = context.filename;
|
|
27
|
-
if (!filename.endsWith(".ts")) {
|
|
28
|
-
return {};
|
|
29
|
-
}
|
|
30
28
|
return {
|
|
31
29
|
ImportDeclaration(node) {
|
|
32
30
|
const importPath = node.source.value;
|
|
33
31
|
if (importPath.startsWith(".") && !importPath.endsWith(".ts") && !importPath.endsWith(".json") && fs.existsSync(importPath)) {
|
|
34
|
-
const
|
|
32
|
+
const absoluteImportPath = path.resolve(path.dirname(filename), importPath);
|
|
33
|
+
const stats = fs.statSync(absoluteImportPath);
|
|
35
34
|
const isDirectory = stats.isDirectory();
|
|
36
35
|
const fixedPath = isDirectory ? `${importPath}/index.ts` : `${importPath}.ts`;
|
|
37
36
|
context.report({
|
|
@@ -51,4 +50,4 @@ export {
|
|
|
51
50
|
require_ts_extension_imports_default as default,
|
|
52
51
|
ruleId
|
|
53
52
|
};
|
|
54
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
53
|
+
//# sourceMappingURL=data:application/json;base64,ewogICJ2ZXJzaW9uIjogMywKICAic291cmNlcyI6IFsiLi4vc3JjL3JlcXVpcmUtdHMtZXh0ZW5zaW9uLWltcG9ydHMudHMiXSwKICAibWFwcGluZ3MiOiAiO0FBUUEsT0FBTyxVQUFVO0FBQ2pCLE9BQU8sUUFBUTtBQUNmLFNBQVMsbUJBQW1CO0FBQzV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FDWCxDQUFDLElBQUksT0FBTztBQUNWLG9CQUFNLE1BQU0sWUFBWSxLQUFLLFFBQVEsSUFBSSxTQUFTLEdBQUc7QUFBQSxZQUN2RDtBQUFBLFVBQ0YsQ0FBQztBQUFBLFFBQ0g7QUFBQSxNQUNGO0FBQUEsSUFDRjtBQUFBLEVBQ0Y7QUFDRixDQUFDO0FBRUQsSUFBTyx1Q0FBUTsiLAogICJuYW1lcyI6IFtdCn0K
|
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-5830","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"}}
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
* This code is licensed under the MIT license (see LICENSE.txt for details).
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
+
import path from 'path';
|
|
9
10
|
import fs from 'fs';
|
|
10
11
|
import { ESLintUtils } from '@typescript-eslint/utils';
|
|
11
12
|
import { TSESTree } from '@typescript-eslint/typescript-estree';
|
|
@@ -34,9 +35,6 @@ const rule: ReturnType<typeof createRule> = createRule({
|
|
|
34
35
|
defaultOptions: [],
|
|
35
36
|
create(context) {
|
|
36
37
|
const filename = context.filename;
|
|
37
|
-
if (!filename.endsWith('.ts')) {
|
|
38
|
-
return {};
|
|
39
|
-
}
|
|
40
38
|
return {
|
|
41
39
|
ImportDeclaration(node: TSESTree.ImportDeclaration) {
|
|
42
40
|
const importPath = node.source.value;
|
|
@@ -46,7 +44,8 @@ const rule: ReturnType<typeof createRule> = createRule({
|
|
|
46
44
|
!importPath.endsWith('.json') &&
|
|
47
45
|
fs.existsSync(importPath)
|
|
48
46
|
) {
|
|
49
|
-
const
|
|
47
|
+
const absoluteImportPath = path.resolve(path.dirname(filename), importPath);
|
|
48
|
+
const stats = fs.statSync(absoluteImportPath);
|
|
50
49
|
const isDirectory = stats.isDirectory();
|
|
51
50
|
const fixedPath = isDirectory ? `${importPath}/index.ts` : `${importPath}.ts`;
|
|
52
51
|
context.report({
|