Skip to content

Commit 86b660e

Browse files
committed
fix: Correct file ignore check for node_modules on Windows
1 parent 6db1f14 commit 86b660e

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/eslint-adapter.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ export class ESLintAdapter {
132132
}
133133

134134
private getESLintResult(fileName: string, sourceFile: ts.SourceFile) {
135-
if (this.ignoredFilepathMap.get(fileName) === true) return [];
135+
if (this.ignoredFilepathMap.get(fileName.replace(/\\/g, '/')) === true) return [];
136136
const configArray = this.configProvider.getConfigArrayForFile(fileName);
137137
const configFileContent = configArray.extractConfig(fileName).toCompatibleObjectAsConfigFileContent();
138138
if (!isParserModuleNameValid(configFileContent.parser, path.join("@typescript-eslint", "parser"))) {
@@ -146,12 +146,12 @@ export class ESLintAdapter {
146146
}
147147

148148
public checkFileToBeIgnored(fileName: string) {
149-
if (fileName.indexOf("node_modules" + path.sep) !== -1) return;
150-
if (!fileName.endsWith(".ts") && !fileName.endsWith(".tsx")) return;
149+
if (/node_modules[\\/]/i.test(fileName) || !/\.tsx?$/i.test(fileName)) return;
150+
const normalized = fileName.replace(/\\/g, '/');
151151
Promise.resolve()
152152
.then(() => new ESLint())
153-
.then(eslint => eslint.isPathIgnored(fileName))
154-
.then(result => this.ignoredFilepathMap.set(fileName, result));
153+
.then(eslint => eslint.isPathIgnored(normalized))
154+
.then(result => this.ignoredFilepathMap.set(normalized, result));
155155
}
156156

157157
public getSemanticDiagnostics(

0 commit comments

Comments
 (0)