1
- // @ts -check
2
-
3
1
import url from "node:url" ;
4
2
3
+ // @ts -expect-error - this is a valid import
5
4
import eslint from "@eslint/js" ;
5
+ import gitignore from "eslint-config-flat-gitignore" ;
6
+ // @ts -expect-error - this is a valid import
6
7
import eslintCommentsPlugin from "eslint-plugin-eslint-comments" ;
8
+ // @ts -expect-error - this is a valid import
7
9
import eslintPluginPlugin from "eslint-plugin-eslint-plugin" ;
8
- import gitignore from "eslint-config-flat-gitignore" ;
9
10
import jsdocPlugin from "eslint-plugin-jsdoc" ;
11
+ // @ts -expect-error - this is a valid import
10
12
import perfectionist from "eslint-plugin-perfectionist" ;
13
+ // @ts -expect-error - this is a valid import
11
14
import perfectionistNatural from "eslint-plugin-perfectionist/configs/recommended-natural" ;
12
15
import simpleImportSortPlugin from "eslint-plugin-simple-import-sort" ;
16
+ // @ts -expect-error - this is a valid import
13
17
import unicornPlugin from "eslint-plugin-unicorn" ;
14
- import tseslint from "typescript-eslint" ;
15
18
import vitest from "eslint-plugin-vitest" ;
19
+ import tseslint from "typescript-eslint" ;
16
20
17
21
const dirname = url . fileURLToPath ( new URL ( "." , import . meta. url ) ) ;
18
22
@@ -22,18 +26,17 @@ export default tseslint.config(
22
26
// note - intentionally uses computed syntax to make it easy to sort the keys
23
27
plugins : {
24
28
[ "@typescript-eslint" ] : tseslint . plugin ,
25
- [ "eslint-plugin" ] : eslintPluginPlugin ,
26
29
[ "eslint-comments" ] : eslintCommentsPlugin ,
30
+ [ "eslint-plugin" ] : eslintPluginPlugin ,
27
31
[ "jsdoc" ] : jsdocPlugin ,
28
- [ "simple-import-sort" ] : simpleImportSortPlugin ,
29
32
[ "perfectionist" ] : perfectionist ,
33
+ [ "simple-import-sort" ] : simpleImportSortPlugin ,
30
34
[ "unicorn" ] : unicornPlugin ,
31
35
} ,
32
36
} ,
33
37
// extends ...
34
38
eslint . configs . recommended ,
35
39
...tseslint . configs . strictTypeChecked ,
36
- // @ts -ignore
37
40
perfectionistNatural ,
38
41
jsdocPlugin . configs [ "flat/recommended-typescript-error" ] ,
39
42
// base config
@@ -51,30 +54,30 @@ export default tseslint.config(
51
54
} ,
52
55
} ,
53
56
rules : {
54
- "@typescript-eslint/no-confusing-void-expression" : "off" ,
55
- "@typescript-eslint/ban-types" : "off" ,
56
57
"@typescript-eslint/ban-ts-comment" : [
57
58
"error" ,
58
59
{
60
+ minimumDescriptionLength : 5 ,
61
+ "ts-check" : false ,
59
62
"ts-expect-error" : "allow-with-description" ,
60
63
"ts-ignore" : true ,
61
64
"ts-nocheck" : true ,
62
- "ts-check" : false ,
63
- minimumDescriptionLength : 5 ,
64
65
} ,
65
66
] ,
67
+ "@typescript-eslint/ban-types" : "off" ,
66
68
"@typescript-eslint/consistent-type-imports" : [ "error" , {
67
- prefer : "type-imports" ,
68
69
disallowTypeAnnotations : true ,
70
+ prefer : "type-imports" ,
69
71
} ] ,
70
72
"@typescript-eslint/explicit-function-return-type" : "off" ,
73
+ "@typescript-eslint/no-confusing-void-expression" : "off" ,
71
74
"@typescript-eslint/no-explicit-any" : "error" ,
72
75
"@typescript-eslint/no-unused-vars" : [
73
76
"error" ,
74
77
{
78
+ argsIgnorePattern : "^_" ,
75
79
caughtErrors : "all" ,
76
80
varsIgnorePattern : "^_" ,
77
- argsIgnorePattern : "^_" ,
78
81
} ,
79
82
] ,
80
83
"@typescript-eslint/prefer-nullish-coalescing" : [
@@ -85,18 +88,43 @@ export default tseslint.config(
85
88
} ,
86
89
] ,
87
90
"array-callback-return" : "off" ,
91
+ curly : "off" ,
92
+ eqeqeq : [ "error" , "always" ] ,
93
+ "eslint-comments/disable-enable-pair" : [ "error" , { allowWholeFile : true } ] ,
94
+ "eslint-comments/no-aggregating-enable" : "error" ,
95
+ "eslint-comments/no-duplicate-disable" : "error" ,
96
+ "eslint-comments/no-unlimited-disable" : "error" ,
97
+ "eslint-comments/no-unused-disable" : "error" ,
98
+ "eslint-comments/no-unused-enable" : "error" ,
99
+ "eslint-comments/no-use" : [
100
+ "error" ,
101
+ {
102
+ allow : [
103
+ "eslint-disable" ,
104
+ "eslint-disable-line" ,
105
+ "eslint-disable-next-line" ,
106
+ "eslint-enable" ,
107
+ "global" ,
108
+ ] ,
109
+ } ,
110
+ ] ,
111
+ "eslint-plugin/require-meta-docs-url" : "off" ,
112
+ "jsdoc/check-param-names" : "off" ,
113
+ "jsdoc/check-tag-names" : "off" ,
114
+ "jsdoc/informative-docs" : "warn" ,
115
+ "jsdoc/require-jsdoc" : "off" ,
116
+ "jsdoc/require-param" : "off" ,
117
+ "jsdoc/require-param-description" : "off" ,
118
+ "jsdoc/require-returns" : "off" ,
119
+ "jsdoc/require-yields" : "off" ,
120
+ "jsdoc/tag-lines" : "off" ,
88
121
"logical-assignment-operators" : "error" ,
89
122
"max-depth" : [ "warn" , 3 ] ,
90
123
"no-console" : "error" ,
91
124
"no-else-return" : "error" ,
92
125
"no-fallthrough" : [ "error" , { commentPattern : ".*intentional fallthrough.*" } ] ,
93
126
"no-mixed-operators" : "error" ,
94
127
"no-process-exit" : "error" ,
95
- "no-undef" : "off" ,
96
- "one-var" : [ "error" , "never" ] ,
97
- "prefer-object-has-own" : "error" ,
98
- curly : "off" ,
99
- eqeqeq : [ "error" , "always" ] ,
100
128
"no-restricted-syntax" : [
101
129
"error" ,
102
130
{
@@ -116,19 +144,16 @@ export default tseslint.config(
116
144
selector : 'ImportDeclaration[source.value="."]' ,
117
145
} ,
118
146
] ,
119
- "simple-import-sort/imports" : "warn" ,
120
- "simple-import-sort/exports" : "warn" ,
121
- "unicorn/template-indent" : "warn" ,
147
+ "no-undef" : "off" ,
148
+ "one-var" : [ "error" , "never" ] ,
122
149
"perfectionist/sort-exports" : "off" ,
123
150
"perfectionist/sort-imports" : "off" ,
124
151
"perfectionist/sort-named-exports" : "off" ,
125
152
"perfectionist/sort-named-imports" : "off" ,
126
153
"perfectionist/sort-object-types" : [
127
154
"warn" ,
128
155
{
129
- order : "asc" ,
130
156
type : "natural" ,
131
- groups : [ "id" , "type" , "meta" , "unknown" ] ,
132
157
"custom-groups" : {
133
158
id : [ "_" , "id" , "key" ] ,
134
159
type : [ "type" , "kind" ] ,
@@ -139,15 +164,14 @@ export default tseslint.config(
139
164
"description" ,
140
165
] ,
141
166
} ,
167
+ groups : [ "id" , "type" , "meta" , "unknown" ] ,
168
+ order : "asc" ,
142
169
} ,
143
170
] ,
144
171
"perfectionist/sort-objects" : [
145
172
"warn" ,
146
173
{
147
- order : "asc" ,
148
174
type : "natural" ,
149
- "partition-by-comment" : "Part:**" ,
150
- groups : [ "id" , "type" , "meta" , "unknown" ] ,
151
175
"custom-groups" : {
152
176
id : [ "_" , "id" , "key" ] ,
153
177
type : [ "type" , "kind" ] ,
@@ -158,50 +182,30 @@ export default tseslint.config(
158
182
"description" ,
159
183
] ,
160
184
} ,
185
+ groups : [ "id" , "type" , "meta" , "unknown" ] ,
186
+ order : "asc" ,
187
+ "partition-by-comment" : "Part:**" ,
161
188
} ,
162
189
] ,
163
190
"perfectionist/sort-union-types" : [
164
191
"warn" ,
165
192
{
166
- order : "asc" ,
167
193
type : "natural" ,
194
+ order : "asc" ,
168
195
} ,
169
196
] ,
170
- "eslint-plugin/require-meta-docs-url" : "off" ,
171
- "eslint-comments/disable-enable-pair" : [ "error" , { allowWholeFile : true } ] ,
172
- "eslint-comments/no-aggregating-enable" : "error" ,
173
- "eslint-comments/no-duplicate-disable" : "error" ,
174
- "eslint-comments/no-unlimited-disable" : "error" ,
175
- "eslint-comments/no-unused-disable" : "error" ,
176
- "eslint-comments/no-unused-enable" : "error" ,
177
- "eslint-comments/no-use" : [
178
- "error" ,
179
- {
180
- allow : [
181
- "eslint-disable" ,
182
- "eslint-disable-line" ,
183
- "eslint-disable-next-line" ,
184
- "eslint-enable" ,
185
- "global" ,
186
- ] ,
187
- } ,
188
- ] ,
189
- "jsdoc/check-tag-names" : "off" ,
190
- "jsdoc/check-param-names" : "off" ,
191
- "jsdoc/require-jsdoc" : "off" ,
192
- "jsdoc/require-param" : "off" ,
193
- "jsdoc/require-param-description" : "off" ,
194
- "jsdoc/require-returns" : "off" ,
195
- "jsdoc/require-yields" : "off" ,
196
- "jsdoc/tag-lines" : "off" ,
197
- "jsdoc/informative-docs" : "warn" ,
197
+ "prefer-object-has-own" : "error" ,
198
+ "simple-import-sort/exports" : "warn" ,
199
+ "simple-import-sort/imports" : "warn" ,
200
+ "unicorn/template-indent" : "warn" ,
198
201
} ,
199
202
} ,
200
203
{
201
- files : [ "**/*.js" ] ,
202
204
extends : [ tseslint . configs . disableTypeChecked ] ,
205
+ files : [ "**/*.js" ] ,
203
206
rules : {
204
207
// turn off rules that don't apply to JS code
208
+ "@typescript-eslint/no-var-requires" : "off" ,
205
209
} ,
206
210
} ,
207
211
{
@@ -211,11 +215,15 @@ export default tseslint.config(
211
215
"**/spec.{ts,tsx,cts,mts}" ,
212
216
"**/test.{ts,tsx,cts,mts}" ,
213
217
] ,
218
+ languageOptions : {
219
+ globals : {
220
+ ...vitest . environments . env . globals ,
221
+ } ,
222
+ } ,
214
223
plugins : {
215
224
vitest,
216
225
} ,
217
226
rules : {
218
- // @ts -ignore
219
227
...vitest . configs . recommended . rules ,
220
228
"@typescript-eslint/no-empty-function" : [ "error" , { allow : [ "arrowFunctions" ] } ] ,
221
229
"@typescript-eslint/no-non-null-assertion" : "off" ,
@@ -224,9 +232,19 @@ export default tseslint.config(
224
232
"@typescript-eslint/no-unsafe-member-access" : "off" ,
225
233
"@typescript-eslint/no-unsafe-return" : "off" ,
226
234
} ,
235
+ } ,
236
+ {
237
+ extends : [ tseslint . configs . disableTypeChecked ] ,
238
+ files : [
239
+ "*.config.{ts,tsx,cts,mts}" ,
240
+ ] ,
227
241
languageOptions : {
228
- globals : {
229
- ...vitest . environments . env . globals ,
242
+ parserOptions : {
243
+ project : [
244
+ "tsconfig.json" ,
245
+ ] ,
246
+ tsconfigRootDir : dirname ,
247
+ warnOnUnsupportedTypeScriptVersion : false ,
230
248
} ,
231
249
} ,
232
250
} ,
@@ -236,7 +254,6 @@ export default tseslint.config(
236
254
"docs" ,
237
255
"examples" ,
238
256
"website" ,
239
- "eslint.config.mjs" ,
240
257
] ,
241
258
} ,
242
259
) ;
0 commit comments