@@ -2,12 +2,12 @@ import { eslintRulesExtra } from "./official-eslint-rules.cjs"
22import { pluginImportRulesExtra , pluginImportTypeScriptRulesExtra } from "./plugin-import-rules.cjs"
33import { pluginNodeRules } from "./plugin-node-rules.cjs"
44import makeSynchronous from "make-synchronous"
5- import { findOneFile } from "./utils.cjs"
5+ import { findFilesForGroups } from "./utils.cjs"
66import type { GlobifiedEntry } from "globify-gitignore"
77import { Linter } from "eslint"
88
99const tsFiles = [ "**/*.tsx" , "**/*.ts" , "**/*.mts" , "**/*.cts" ]
10- const project = [ "**/tsconfig.json" , "!**/node_modules/**/tsconfig.json" ]
10+ const tscConfigFiles = [ "**/tsconfig.json" , "!**/node_modules/**/tsconfig.json" ]
1111
1212async function globifyGitIgnoreFileWithDeps ( cwd : string , include : boolean ) {
1313 try {
@@ -54,18 +54,15 @@ function disableProjectBasedRules() {
5454 )
5555
5656 // check if there are any ts files
57- const hasTsFile = findOneFile ( cwd , tsFiles , ignore )
57+ const [ hasTscConfig , hasTsFile ] = findFilesForGroups ( cwd , [ tscConfigFiles , tsFiles ] , ignore )
5858
5959 // return if there are no ts files
6060 if ( ! hasTsFile ) {
6161 return true
6262 }
6363
64- // check if there is a tsconfig.json file
65- const hasTsConfig = findOneFile ( cwd , project , ignore )
66-
6764 // if there is no tsconfig.json file, but there are ts files, disable the project-based rules
68- const disable = ! hasTsConfig && hasTsFile
65+ const disable = ! hasTscConfig && hasTsFile
6966
7067 if ( disable ) {
7168 console . warn (
@@ -132,7 +129,7 @@ export const tsConfig: Linter.ConfigOverride<Linter.RulesRecord> = {
132129 files : tsFiles ,
133130 parser : "@typescript-eslint/parser" ,
134131 parserOptions : {
135- project,
132+ project : tscConfigFiles ,
136133 createDefaultProgram : true , // otherwise Eslint will error if a ts file is not covered by one of the tsconfig.json files
137134 } ,
138135 plugins : [ "@typescript-eslint" , "node" , "import" , "only-warn" ] ,
0 commit comments