1
- // eslint.config.ts
1
+ import path from "path" ;
2
+ import fs from "fs" ;
2
3
import js from "@eslint/js" ;
3
4
import tseslint from "typescript-eslint" ;
4
5
import stylistic from "@stylistic/eslint-plugin" ;
@@ -8,13 +9,15 @@ import prettierPlugin from "eslint-plugin-prettier";
8
9
import prettierConfig from "eslint-config-prettier/flat" ;
9
10
import prettierRecommended from "eslint-plugin-prettier/recommended" ;
10
11
12
+ const consumerTsconfig = path . resolve ( process . cwd ( ) , "tsconfig.json" ) ,
13
+ parserProject = fs . existsSync ( consumerTsconfig ) ? consumerTsconfig : undefined ;
14
+
11
15
export default tseslint . config (
12
16
js . configs . recommended ,
13
17
stylistic . configs . recommended ,
14
- ...tseslint . configs . recommended ,
15
- ...tseslint . configs . recommendedTypeChecked ,
16
- ...tseslint . configs . stylisticTypeChecked ,
17
18
jsdoc . configs [ "flat/recommended-typescript" ] ,
19
+ ...tseslint . configs . strictTypeChecked ,
20
+ ...tseslint . configs . stylisticTypeChecked ,
18
21
{
19
22
ignores : [ "dist" , "node_modules" ] ,
20
23
plugins : {
@@ -26,9 +29,7 @@ export default tseslint.config(
26
29
} ,
27
30
languageOptions : {
28
31
parser : tseslint . parser ,
29
- parserOptions : {
30
- project : "./tsconfig.json" ,
31
- } ,
32
+ parserOptions : parserProject ? { project : parserProject } : undefined ,
32
33
} ,
33
34
rules : {
34
35
// --- stylistic ---
@@ -46,14 +47,11 @@ export default tseslint.config(
46
47
"@stylistic/no-extra-semi" : "error" ,
47
48
48
49
// --- typescript-eslint ---
49
- "@typescript-eslint/ban-types" : "warn" ,
50
50
"@typescript-eslint/consistent-generic-constructors" : [ "error" , "constructor" ] ,
51
51
"@typescript-eslint/consistent-type-exports" : "error" ,
52
52
"@typescript-eslint/consistent-type-imports" : "error" ,
53
53
"@typescript-eslint/explicit-function-return-type" : "error" ,
54
54
"@typescript-eslint/explicit-member-accessibility" : [ "error" , { accessibility : "no-public" } ] ,
55
- "@typescript-eslint/no-explicit-any" : "error" ,
56
- "@typescript-eslint/no-inferrable-types" : "error" ,
57
55
"@typescript-eslint/member-ordering" : [
58
56
"error" ,
59
57
{
@@ -126,6 +124,12 @@ export default tseslint.config(
126
124
} ,
127
125
} ,
128
126
] ,
127
+ "@typescript-eslint/no-explicit-any" : "error" ,
128
+ "@typescript-eslint/no-inferrable-types" : "error" ,
129
+ "@typescript-eslint/no-restricted-types" : "warn" ,
130
+ "@typescript-eslint/no-empty-object-type" : "warn" ,
131
+ "@typescript-eslint/no-unsafe-function-type" : "warn" ,
132
+ "@typescript-eslint/no-wrapper-object-types" : "warn" ,
129
133
"@typescript-eslint/no-unnecessary-type-arguments" : "error" ,
130
134
"@typescript-eslint/no-unnecessary-type-assertion" : "error" ,
131
135
"@typescript-eslint/no-unused-vars" : [
@@ -138,15 +142,15 @@ export default tseslint.config(
138
142
} ,
139
143
] ,
140
144
"@typescript-eslint/no-var-requires" : "error" ,
141
- "@typescript-eslint/prefer-readonly" : "error" ,
142
145
"@typescript-eslint/no-magic-numbers" : [
143
146
"error" ,
144
147
{ ignoreEnums : true , ignoreNumericLiteralTypes : true } ,
145
148
] ,
146
149
"@typescript-eslint/no-unused-expressions" : "error" ,
147
- "@typescript-eslint/no -throw-literal " : "error" ,
150
+ "@typescript-eslint/only -throw-error " : "error" ,
148
151
"@typescript-eslint/no-empty-function" : "error" ,
149
152
"@typescript-eslint/no-useless-constructor" : "error" ,
153
+ "@typescript-eslint/prefer-readonly" : "error" ,
150
154
151
155
// --- core rules ---
152
156
"no-console" : "error" ,
@@ -196,7 +200,6 @@ export default tseslint.config(
196
200
// disabilitazioni duplicate (sostituite da @typescript-eslint)
197
201
"no-useless-constructor" : "off" ,
198
202
"no-empty-function" : "off" ,
199
- "no-throw-literal" : "off" ,
200
203
"no-unused-expressions" : "off" ,
201
204
"no-magic-numbers" : "off" ,
202
205
} ,
0 commit comments