@@ -32,6 +32,7 @@ import depend from 'eslint-plugin-depend';
3232import globals from "globals" ;
3333import fs from "node:fs" ;
3434import path from "node:path" ;
35+ import { cwd } from "node:process" ;
3536import { Config , defineConfig , globalIgnores } from "eslint/config" ;
3637import type { RuleDefinition , RuleDefinitionTypeOptions , RulesConfig } from "@eslint/core" ;
3738
@@ -222,7 +223,12 @@ const flatRecommendedConfig: Config[] = defineConfig([
222223 "@microsoft/sdl" : sdl ,
223224 depend
224225 } ,
225- files : [ '**/*.js' , "**/*.jsx" ] ,
226+ files : [
227+ '**/*.js' ,
228+ "**/*.jsx" ,
229+ '**/*.cjs' ,
230+ '**/*.mjs' ,
231+ ] ,
226232 extends : tseslint . configs . recommended as Config [ ] ,
227233 rules : {
228234 ...flatRecommendedGeneralRules ,
@@ -235,7 +241,12 @@ const flatRecommendedConfig: Config[] = defineConfig([
235241 "@microsoft/sdl" : sdl ,
236242 depend
237243 } ,
238- files : [ '**/*.ts' , "**/*.tsx" ] ,
244+ files : [
245+ '**/*.ts' ,
246+ '**/*.tsx' ,
247+ '**/*.cts' ,
248+ '**/*.mts' ,
249+ ] ,
239250 extends : tseslint . configs . recommendedTypeChecked as Config [ ] ,
240251 rules : {
241252 ...flatRecommendedGeneralRules ,
@@ -269,9 +280,42 @@ const flatRecommendedConfig: Config[] = defineConfig([
269280 sleep : "readonly"
270281 }
271282 } ,
272- }
283+ } ,
284+ {
285+ languageOptions : {
286+ parserOptions : {
287+ ecmaFeatures : {
288+ jsx : true
289+ } ,
290+ projectService : {
291+ allowDefaultProject : [
292+ '*.js' ,
293+ '*.jsx' ,
294+ '*.cjs' ,
295+ '*.mjs' ,
296+ ] ,
297+ } ,
298+ tsconfigRootDir : getRootFolder ( ) ?? ''
299+ } ,
300+ }
301+ } ,
302+ globalIgnores ( [
303+ 'node_modules' ,
304+ ] )
273305] ) ;
274306
307+ function getRootFolder ( ) : string | null {
308+ let currentFolder = cwd ( ) ;
309+ while ( currentFolder !== '.' && currentFolder !== '/' ) {
310+ if ( fs . existsSync ( path . join ( currentFolder , 'package.json' ) ) ) {
311+ return currentFolder ;
312+ }
313+ currentFolder = path . dirname ( currentFolder ) ;
314+ }
315+
316+ return null ;
317+ }
318+
275319const hybridRecommendedConfig : Config [ ] = defineConfig ( {
276320 rules : recommendedPluginRulesConfig ,
277321 extends : flatRecommendedConfig
0 commit comments