@@ -2,12 +2,12 @@ import { eslintRulesExtra } from "./official-eslint-rules.cjs"
2
2
import { pluginImportRulesExtra , pluginImportTypeScriptRulesExtra } from "./plugin-import-rules.cjs"
3
3
import { pluginNodeRules } from "./plugin-node-rules.cjs"
4
4
import makeSynchronous from "make-synchronous"
5
- import { findOneFile } from "./utils.cjs"
5
+ import { findFilesForGroups } from "./utils.cjs"
6
6
import type { GlobifiedEntry } from "globify-gitignore"
7
7
import { Linter } from "eslint"
8
8
9
9
const tsFiles = [ "**/*.tsx" , "**/*.ts" , "**/*.mts" , "**/*.cts" ]
10
- const project = [ "**/tsconfig.json" , "!**/node_modules/**/tsconfig.json" ]
10
+ const tscConfigFiles = [ "**/tsconfig.json" , "!**/node_modules/**/tsconfig.json" ]
11
11
12
12
async function globifyGitIgnoreFileWithDeps ( cwd : string , include : boolean ) {
13
13
try {
@@ -54,18 +54,15 @@ function disableProjectBasedRules() {
54
54
)
55
55
56
56
// check if there are any ts files
57
- const hasTsFile = findOneFile ( cwd , tsFiles , ignore )
57
+ const [ hasTscConfig , hasTsFile ] = findFilesForGroups ( cwd , [ tscConfigFiles , tsFiles ] , ignore )
58
58
59
59
// return if there are no ts files
60
60
if ( ! hasTsFile ) {
61
61
return true
62
62
}
63
63
64
- // check if there is a tsconfig.json file
65
- const hasTsConfig = findOneFile ( cwd , project , ignore )
66
-
67
64
// 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
69
66
70
67
if ( disable ) {
71
68
console . warn (
@@ -132,7 +129,7 @@ export const tsConfig: Linter.ConfigOverride<Linter.RulesRecord> = {
132
129
files : tsFiles ,
133
130
parser : "@typescript-eslint/parser" ,
134
131
parserOptions : {
135
- project,
132
+ project : tscConfigFiles ,
136
133
createDefaultProgram : true , // otherwise Eslint will error if a ts file is not covered by one of the tsconfig.json files
137
134
} ,
138
135
plugins : [ "@typescript-eslint" , "node" , "import" , "only-warn" ] ,
0 commit comments