@@ -28,6 +28,9 @@ const biomeConfigPath = path.join(rootPath, BIOME_JSON)
2828const gitignorePath = path . join ( rootPath , GIT_IGNORE )
2929
3030const biomeConfig = require ( biomeConfigPath )
31+ const nodeGlobalsConfig = Object . fromEntries (
32+ Object . entries ( globals . node ) . map ( ( [ k ] ) => [ k , 'readonly' ] )
33+ )
3134
3235const sharedPlugins = {
3336 'sort-destructure-keys' : sortDestructureKeysPlugin ,
@@ -41,6 +44,14 @@ const sharedRules = {
4144 'no-new' : 'error' ,
4245 'no-proto' : 'error' ,
4346 'no-undef' : 'error' ,
47+ 'no-unused-vars' : [
48+ 'error' ,
49+ {
50+ argsIgnorePattern : '^_|^this$' ,
51+ ignoreRestSiblings : true ,
52+ varsIgnorePattern : '^_'
53+ }
54+ ] ,
4455 'no-var' : 'error' ,
4556 'no-warning-comments' : [ 'warn' , { terms : [ 'fixme' ] } ] ,
4657 'prefer-const' : 'error' ,
@@ -137,29 +148,31 @@ module.exports = [
137148 } ,
138149 {
139150 files : [ '**/*.ts' ] ,
151+ ...js . configs . recommended ,
140152 ...importFlatConfigsForModule . typescript ,
141153 languageOptions : {
154+ ...js . configs . recommended . languageOptions ,
142155 ...importFlatConfigsForModule . typescript . languageOptions ,
143156 globals : {
157+ ...js . configs . recommended . languageOptions ?. globals ,
144158 ...importFlatConfigsForModule . typescript . languageOptions ?. globals ,
159+ ...nodeGlobalsConfig ,
145160 BufferConstructor : 'readonly' ,
146161 BufferEncoding : 'readonly' ,
147- NodeJS : 'readonly' ,
148- ...Object . fromEntries (
149- Object . entries ( globals . node ) . map ( ( [ k ] ) => [ k , 'readonly' ] )
150- )
162+ NodeJS : 'readonly'
151163 } ,
152164 parser : tsParser ,
153165 parserOptions : {
166+ ...js . configs . recommended . languageOptions ?. parserOptions ,
154167 ...importFlatConfigsForModule . typescript . languageOptions ?. parserOptions ,
155168 projectService : {
156169 ...importFlatConfigsForModule . typescript . languageOptions
157170 ?. parserOptions ?. projectService ,
158171 allowDefaultProject : [
159172 'test/*.ts' ,
160- // src/utils/*
173+ // Allow paths like src/utils/*.test.ts.
161174 'src/*/*.test.ts' ,
162- // src/commands/xyz/*
175+ // Allow paths like src/commands/optimize/*.test.ts.
163176 'src/*/*/*.test.ts'
164177 ] ,
165178 defaultProject : 'tsconfig.json' ,
@@ -170,15 +183,18 @@ module.exports = [
170183 }
171184 } ,
172185 linterOptions : {
186+ ...js . configs . recommended . linterOptions ,
173187 ...importFlatConfigsForModule . typescript . linterOptions ,
174188 reportUnusedDisableDirectives : 'off'
175189 } ,
176190 plugins : {
191+ ...js . configs . recommended . plugins ,
177192 ...importFlatConfigsForModule . typescript . plugins ,
178193 ...sharedPlugins ,
179194 '@typescript-eslint' : tsEslint . plugin
180195 } ,
181196 rules : {
197+ ...js . configs . recommended . rules ,
182198 ...importFlatConfigsForModule . typescript . rules ,
183199 ...sharedRules ,
184200 '@typescript-eslint/array-type' : [ 'error' , { default : 'array-simple' } ] ,
@@ -199,20 +215,30 @@ module.exports = [
199215 // not awaiting promises *outside* of try/catch/finally, which is not what
200216 // we want), and it's nice to await before returning anyways, since you get
201217 // 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'
209223 }
210224 } ,
211225 {
212226 files : [ '**/*.{c,}js' ] ,
213227 ...js . configs . recommended ,
214228 ...importFlatConfigsForScript . recommended ,
215229 ...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+ } ,
216242 plugins : {
217243 ...js . configs . recommended . plugins ,
218244 ...importFlatConfigsForScript . recommended . plugins ,
@@ -240,22 +266,36 @@ module.exports = [
240266 version : constants . maintainedNodeVersions . last
241267 }
242268 ] ,
243- 'n/prefer-node-protocol' : 'error' ,
244- 'no-unused-vars' : [
245- 'error' ,
246- { argsIgnorePattern : '^_|^this$' , ignoreRestSiblings : true }
247- ]
269+ 'n/prefer-node-protocol' : 'error'
248270 }
249271 } ,
250272 {
251273 files : [ '**/*.mjs' ] ,
274+ ...js . configs . recommended ,
252275 ...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+ } ,
253289 plugins : {
290+ ...js . configs . recommended . plugins ,
254291 ...importFlatConfigsForModule . recommended . plugins ,
292+ ...nodePlugin . configs [ 'flat/recommended-module' ] . plugins ,
255293 ...sharedPlugins
256294 } ,
257295 rules : {
296+ ...js . configs . recommended . rules ,
258297 ...importFlatConfigsForModule . recommended . rules ,
298+ ...nodePlugin . configs [ 'flat/recommended-module' ] . rules ,
259299 ...sharedRules
260300 }
261301 }
0 commit comments