@@ -28,6 +28,9 @@ const biomeConfigPath = path.join(rootPath, BIOME_JSON)
28
28
const gitignorePath = path . join ( rootPath , GIT_IGNORE )
29
29
30
30
const biomeConfig = require ( biomeConfigPath )
31
+ const nodeGlobalsConfig = Object . fromEntries (
32
+ Object . entries ( globals . node ) . map ( ( [ k ] ) => [ k , 'readonly' ] )
33
+ )
31
34
32
35
const sharedPlugins = {
33
36
'sort-destructure-keys' : sortDestructureKeysPlugin ,
@@ -41,6 +44,14 @@ const sharedRules = {
41
44
'no-new' : 'error' ,
42
45
'no-proto' : 'error' ,
43
46
'no-undef' : 'error' ,
47
+ 'no-unused-vars' : [
48
+ 'error' ,
49
+ {
50
+ argsIgnorePattern : '^_|^this$' ,
51
+ ignoreRestSiblings : true ,
52
+ varsIgnorePattern : '^_'
53
+ }
54
+ ] ,
44
55
'no-var' : 'error' ,
45
56
'no-warning-comments' : [ 'warn' , { terms : [ 'fixme' ] } ] ,
46
57
'prefer-const' : 'error' ,
@@ -137,29 +148,31 @@ module.exports = [
137
148
} ,
138
149
{
139
150
files : [ '**/*.ts' ] ,
151
+ ...js . configs . recommended ,
140
152
...importFlatConfigsForModule . typescript ,
141
153
languageOptions : {
154
+ ...js . configs . recommended . languageOptions ,
142
155
...importFlatConfigsForModule . typescript . languageOptions ,
143
156
globals : {
157
+ ...js . configs . recommended . languageOptions ?. globals ,
144
158
...importFlatConfigsForModule . typescript . languageOptions ?. globals ,
159
+ ...nodeGlobalsConfig ,
145
160
BufferConstructor : 'readonly' ,
146
161
BufferEncoding : 'readonly' ,
147
- NodeJS : 'readonly' ,
148
- ...Object . fromEntries (
149
- Object . entries ( globals . node ) . map ( ( [ k ] ) => [ k , 'readonly' ] )
150
- )
162
+ NodeJS : 'readonly'
151
163
} ,
152
164
parser : tsParser ,
153
165
parserOptions : {
166
+ ...js . configs . recommended . languageOptions ?. parserOptions ,
154
167
...importFlatConfigsForModule . typescript . languageOptions ?. parserOptions ,
155
168
projectService : {
156
169
...importFlatConfigsForModule . typescript . languageOptions
157
170
?. parserOptions ?. projectService ,
158
171
allowDefaultProject : [
159
172
'test/*.ts' ,
160
- // src/utils/*
173
+ // Allow paths like src/utils/*.test.ts.
161
174
'src/*/*.test.ts' ,
162
- // src/commands/xyz/*
175
+ // Allow paths like src/commands/optimize/*.test.ts.
163
176
'src/*/*/*.test.ts'
164
177
] ,
165
178
defaultProject : 'tsconfig.json' ,
@@ -170,15 +183,18 @@ module.exports = [
170
183
}
171
184
} ,
172
185
linterOptions : {
186
+ ...js . configs . recommended . linterOptions ,
173
187
...importFlatConfigsForModule . typescript . linterOptions ,
174
188
reportUnusedDisableDirectives : 'off'
175
189
} ,
176
190
plugins : {
191
+ ...js . configs . recommended . plugins ,
177
192
...importFlatConfigsForModule . typescript . plugins ,
178
193
...sharedPlugins ,
179
194
'@typescript-eslint' : tsEslint . plugin
180
195
} ,
181
196
rules : {
197
+ ...js . configs . recommended . rules ,
182
198
...importFlatConfigsForModule . typescript . rules ,
183
199
...sharedRules ,
184
200
'@typescript-eslint/array-type' : [ 'error' , { default : 'array-simple' } ] ,
@@ -199,20 +215,30 @@ module.exports = [
199
215
// not awaiting promises *outside* of try/catch/finally, which is not what
200
216
// we want), and it's nice to await before returning anyways, since you get
201
217
// a slightly more comprehensive stack trace upon promise rejection.
202
- '@typescript-eslint/return-await' : [ 'error' , 'always' ]
203
- }
204
- } ,
205
- {
206
- files : [ 'test/**/*.ts' ] ,
207
- rules : {
208
- '@typescript-eslint/no-floating-promises' : 'off'
218
+ '@typescript-eslint/return-await' : [ 'error' , 'always' ] ,
219
+ // Disable no-redeclare and no-unused-vars rule because they don't play
220
+ // well with TypeScript.
221
+ 'no-redeclare' : 'off' ,
222
+ 'no-unused-vars' : 'off'
209
223
}
210
224
} ,
211
225
{
212
226
files : [ '**/*.{c,}js' ] ,
213
227
...js . configs . recommended ,
214
228
...importFlatConfigsForScript . recommended ,
215
229
...nodePlugin . configs [ 'flat/recommended-script' ] ,
230
+ languageOptions : {
231
+ ...js . configs . recommended . languageOptions ,
232
+ ...importFlatConfigsForModule . recommended . languageOptions ,
233
+ ...nodePlugin . configs [ 'flat/recommended-script' ] . languageOptions ,
234
+ globals : {
235
+ ...js . configs . recommended . languageOptions ?. globals ,
236
+ ...importFlatConfigsForModule . recommended . languageOptions ?. globals ,
237
+ ...nodePlugin . configs [ 'flat/recommended-script' ] . languageOptions
238
+ ?. globals ,
239
+ ...nodeGlobalsConfig
240
+ }
241
+ } ,
216
242
plugins : {
217
243
...js . configs . recommended . plugins ,
218
244
...importFlatConfigsForScript . recommended . plugins ,
@@ -240,22 +266,36 @@ module.exports = [
240
266
version : constants . maintainedNodeVersions . last
241
267
}
242
268
] ,
243
- 'n/prefer-node-protocol' : 'error' ,
244
- 'no-unused-vars' : [
245
- 'error' ,
246
- { argsIgnorePattern : '^_|^this$' , ignoreRestSiblings : true }
247
- ]
269
+ 'n/prefer-node-protocol' : 'error'
248
270
}
249
271
} ,
250
272
{
251
273
files : [ '**/*.mjs' ] ,
274
+ ...js . configs . recommended ,
252
275
...importFlatConfigsForModule . recommended ,
276
+ ...nodePlugin . configs [ 'flat/recommended-module' ] ,
277
+ languageOptions : {
278
+ ...js . configs . recommended . languageOptions ,
279
+ ...importFlatConfigsForModule . recommended . languageOptions ,
280
+ ...nodePlugin . configs [ 'flat/recommended-module' ] . languageOptions ,
281
+ globals : {
282
+ ...js . configs . recommended . languageOptions ?. globals ,
283
+ ...importFlatConfigsForModule . recommended . languageOptions ?. globals ,
284
+ ...nodePlugin . configs [ 'flat/recommended-module' ] . languageOptions
285
+ ?. globals ,
286
+ ...nodeGlobalsConfig
287
+ }
288
+ } ,
253
289
plugins : {
290
+ ...js . configs . recommended . plugins ,
254
291
...importFlatConfigsForModule . recommended . plugins ,
292
+ ...nodePlugin . configs [ 'flat/recommended-module' ] . plugins ,
255
293
...sharedPlugins
256
294
} ,
257
295
rules : {
296
+ ...js . configs . recommended . rules ,
258
297
...importFlatConfigsForModule . recommended . rules ,
298
+ ...nodePlugin . configs [ 'flat/recommended-module' ] . rules ,
259
299
...sharedRules
260
300
}
261
301
}
0 commit comments