eslint-config-decent 2.1.0 → 2.2.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/README.md +17 -7
- package/dist/index.cjs +2 -2
- package/dist/index.d.cts +1 -0
- package/dist/index.d.mts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.mjs +2 -2
- package/package.json +8 -8
- package/src/index.ts +2 -1
- package/src/rules/requireExtensionRule.ts +1 -1
package/README.md
CHANGED
|
@@ -11,7 +11,9 @@ A decent ESLint configuration for TypeScript projects.
|
|
|
11
11
|
|
|
12
12
|
import { config } from 'eslint-config-decent';
|
|
13
13
|
|
|
14
|
-
export default config(
|
|
14
|
+
export default config({
|
|
15
|
+
tsconfigRootDir: import.meta.dirname,
|
|
16
|
+
});
|
|
15
17
|
```
|
|
16
18
|
|
|
17
19
|
## Override parserOptions
|
|
@@ -22,11 +24,12 @@ export default config();
|
|
|
22
24
|
import { config } from 'eslint-config-decent';
|
|
23
25
|
|
|
24
26
|
export default config({
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
27
|
+
parserOptions: {
|
|
28
|
+
projectService: {
|
|
29
|
+
defaultProject: 'tsconfig.json',
|
|
30
|
+
},
|
|
31
|
+
tsconfigRootDir: import.meta.dirname,
|
|
28
32
|
},
|
|
29
|
-
tsconfigRootDir: import.meta.dirname,
|
|
30
33
|
});
|
|
31
34
|
```
|
|
32
35
|
|
|
@@ -39,6 +42,7 @@ import { config } from 'eslint-config-decent';
|
|
|
39
42
|
|
|
40
43
|
export default config({
|
|
41
44
|
enableRequireExtensions: false,
|
|
45
|
+
tsconfigRootDir: import.meta.dirname,
|
|
42
46
|
});
|
|
43
47
|
```
|
|
44
48
|
|
|
@@ -50,7 +54,9 @@ export default config({
|
|
|
50
54
|
import { config } from 'eslint-config-decent';
|
|
51
55
|
|
|
52
56
|
export default [
|
|
53
|
-
...config(
|
|
57
|
+
...config({
|
|
58
|
+
tsconfigRootDir: import.meta.dirname,
|
|
59
|
+
}),
|
|
54
60
|
{
|
|
55
61
|
files: ['**/*.ts'],
|
|
56
62
|
rules: {
|
|
@@ -68,7 +74,11 @@ export default [
|
|
|
68
74
|
import { tsEslintConfig } from 'eslint-config-decent';
|
|
69
75
|
import tsEslint from 'typescript-eslint';
|
|
70
76
|
|
|
71
|
-
export default tsEslint(
|
|
77
|
+
export default tsEslint(
|
|
78
|
+
...tsEslintConfig({
|
|
79
|
+
tsconfigRootDir: import.meta.dirname,
|
|
80
|
+
}),
|
|
81
|
+
);
|
|
72
82
|
```
|
|
73
83
|
|
|
74
84
|
## License
|
package/dist/index.cjs
CHANGED
|
@@ -316,7 +316,7 @@ const requireExtensionRule = utils.ESLintUtils.RuleCreator(() => "https://github
|
|
|
316
316
|
if (!importPath || !importPath.startsWith(".") || importPath.endsWith(".js")) {
|
|
317
317
|
return;
|
|
318
318
|
}
|
|
319
|
-
const resolvedPath = path.resolve(path.dirname(context.
|
|
319
|
+
const resolvedPath = path.resolve(path.dirname(context.filename), importPath);
|
|
320
320
|
if (!fs.existsSync(resolvedPath)) {
|
|
321
321
|
context.report({
|
|
322
322
|
node: source,
|
|
@@ -761,7 +761,7 @@ function tsEslintConfig(options) {
|
|
|
761
761
|
projectService: {
|
|
762
762
|
defaultProject: "tsconfig.json"
|
|
763
763
|
},
|
|
764
|
-
tsconfigRootDir: undefined,
|
|
764
|
+
tsconfigRootDir: options?.tsconfigRootDir ?? undefined,
|
|
765
765
|
...options?.parserOptions
|
|
766
766
|
}
|
|
767
767
|
};
|
package/dist/index.d.cts
CHANGED
|
@@ -53,6 +53,7 @@ declare const configs: {
|
|
|
53
53
|
|
|
54
54
|
interface DefaultConfigOptions {
|
|
55
55
|
parserOptions?: NonNullable<ConfigWithExtends['languageOptions']>['parserOptions'];
|
|
56
|
+
tsconfigRootDir?: string;
|
|
56
57
|
enableRequireExtensionRule?: boolean;
|
|
57
58
|
enableJest?: boolean;
|
|
58
59
|
enableMocha?: boolean;
|
package/dist/index.d.mts
CHANGED
|
@@ -53,6 +53,7 @@ declare const configs: {
|
|
|
53
53
|
|
|
54
54
|
interface DefaultConfigOptions {
|
|
55
55
|
parserOptions?: NonNullable<ConfigWithExtends['languageOptions']>['parserOptions'];
|
|
56
|
+
tsconfigRootDir?: string;
|
|
56
57
|
enableRequireExtensionRule?: boolean;
|
|
57
58
|
enableJest?: boolean;
|
|
58
59
|
enableMocha?: boolean;
|
package/dist/index.d.ts
CHANGED
|
@@ -53,6 +53,7 @@ declare const configs: {
|
|
|
53
53
|
|
|
54
54
|
interface DefaultConfigOptions {
|
|
55
55
|
parserOptions?: NonNullable<ConfigWithExtends['languageOptions']>['parserOptions'];
|
|
56
|
+
tsconfigRootDir?: string;
|
|
56
57
|
enableRequireExtensionRule?: boolean;
|
|
57
58
|
enableJest?: boolean;
|
|
58
59
|
enableMocha?: boolean;
|
package/dist/index.mjs
CHANGED
|
@@ -295,7 +295,7 @@ const requireExtensionRule = ESLintUtils.RuleCreator(() => "https://github.com/j
|
|
|
295
295
|
if (!importPath || !importPath.startsWith(".") || importPath.endsWith(".js")) {
|
|
296
296
|
return;
|
|
297
297
|
}
|
|
298
|
-
const resolvedPath = resolve(dirname(context.
|
|
298
|
+
const resolvedPath = resolve(dirname(context.filename), importPath);
|
|
299
299
|
if (!existsSync(resolvedPath)) {
|
|
300
300
|
context.report({
|
|
301
301
|
node: source,
|
|
@@ -740,7 +740,7 @@ function tsEslintConfig(options) {
|
|
|
740
740
|
projectService: {
|
|
741
741
|
defaultProject: "tsconfig.json"
|
|
742
742
|
},
|
|
743
|
-
tsconfigRootDir: import.meta.dirname,
|
|
743
|
+
tsconfigRootDir: options?.tsconfigRootDir ?? import.meta.dirname,
|
|
744
744
|
...options?.parserOptions
|
|
745
745
|
}
|
|
746
746
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-config-decent",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.2.0",
|
|
4
4
|
"description": "A decent ESLint configuration",
|
|
5
5
|
"main": "./dist/index.cjs",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
@@ -73,13 +73,13 @@
|
|
|
73
73
|
},
|
|
74
74
|
"dependencies": {
|
|
75
75
|
"@eslint/compat": "1.1.1",
|
|
76
|
-
"@eslint/js": "9.9.
|
|
77
|
-
"@typescript-eslint/utils": "8.
|
|
76
|
+
"@eslint/js": "9.9.1",
|
|
77
|
+
"@typescript-eslint/utils": "8.3.0",
|
|
78
78
|
"eslint-config-prettier": "9.1.0",
|
|
79
79
|
"eslint-plugin-import-x": "3.1.0",
|
|
80
80
|
"eslint-plugin-jest": "28.8.0",
|
|
81
81
|
"eslint-plugin-jest-dom": "5.4.0",
|
|
82
|
-
"eslint-plugin-jsdoc": "50.
|
|
82
|
+
"eslint-plugin-jsdoc": "50.2.2",
|
|
83
83
|
"eslint-plugin-jsx-a11y": "6.9.0",
|
|
84
84
|
"eslint-plugin-mocha": "10.5.0",
|
|
85
85
|
"eslint-plugin-prettier": "5.2.1",
|
|
@@ -90,13 +90,13 @@
|
|
|
90
90
|
"eslint-plugin-testing-library": "6.3.0",
|
|
91
91
|
"eslint-plugin-unicorn": "55.0.0",
|
|
92
92
|
"globals": "15.9.0",
|
|
93
|
-
"typescript-eslint": "8.
|
|
93
|
+
"typescript-eslint": "8.3.0"
|
|
94
94
|
},
|
|
95
95
|
"devDependencies": {
|
|
96
|
-
"@swc/core": "^1.7.
|
|
96
|
+
"@swc/core": "^1.7.18",
|
|
97
97
|
"@types/node": ">=22",
|
|
98
|
-
"eslint": "^9.9.
|
|
99
|
-
"husky": "^9.1.
|
|
98
|
+
"eslint": "^9.9.1",
|
|
99
|
+
"husky": "^9.1.5",
|
|
100
100
|
"lint-staged": "^15.2.9",
|
|
101
101
|
"markdownlint-cli": "^0.41.0",
|
|
102
102
|
"npm-run-all": "^4.1.5",
|
package/src/index.ts
CHANGED
|
@@ -34,6 +34,7 @@ export {
|
|
|
34
34
|
|
|
35
35
|
export interface DefaultConfigOptions {
|
|
36
36
|
parserOptions?: NonNullable<ConfigWithExtends['languageOptions']>['parserOptions'];
|
|
37
|
+
tsconfigRootDir?: string;
|
|
37
38
|
enableRequireExtensionRule?: boolean;
|
|
38
39
|
enableJest?: boolean;
|
|
39
40
|
enableMocha?: boolean;
|
|
@@ -65,7 +66,7 @@ export function tsEslintConfig(options?: DefaultConfigOptions): ConfigWithExtend
|
|
|
65
66
|
projectService: {
|
|
66
67
|
defaultProject: 'tsconfig.json',
|
|
67
68
|
},
|
|
68
|
-
tsconfigRootDir: import.meta.dirname,
|
|
69
|
+
tsconfigRootDir: options?.tsconfigRootDir ?? import.meta.dirname,
|
|
69
70
|
...options?.parserOptions,
|
|
70
71
|
},
|
|
71
72
|
};
|
|
@@ -29,7 +29,7 @@ export const requireExtensionRule = ESLintUtils.RuleCreator(() => 'https://githu
|
|
|
29
29
|
return;
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
const resolvedPath = resolve(dirname(context.
|
|
32
|
+
const resolvedPath = resolve(dirname(context.filename), importPath);
|
|
33
33
|
|
|
34
34
|
// If the import/export path doesn't end with a file extension, report an error
|
|
35
35
|
// eslint-disable-next-line security/detect-non-literal-fs-filename
|