Skip to content
This repository was archived by the owner on Oct 10, 2025. It is now read-only.

Commit 10f8e17

Browse files
fix: Infinite loop when checking ignored files without a .contextignore file created
1 parent d701e2c commit 10f8e17

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

linters/typescript/src/contextignore_linter.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -161,11 +161,10 @@ export class ContextignoreLinter {
161161
*/
162162
public isIgnored(filePath: string, relativeTo: string): boolean {
163163
try {
164-
const directoryPath = path.dirname(filePath);
165-
let currentDir = directoryPath;
164+
let currentDir = path.dirname(filePath);
166165

167166
// Traverse up the directory tree to find the nearest .contextignore file
168-
while (currentDir.length >= relativeTo.length) {
167+
do {
169168
const ig = this.ignoreCache.get(currentDir);
170169
if (ig) {
171170
const relativeFilePath = path.relative(currentDir, filePath);
@@ -174,7 +173,7 @@ export class ContextignoreLinter {
174173
return ignored;
175174
}
176175
currentDir = path.dirname(currentDir);
177-
}
176+
} while (currentDir.length >= relativeTo.length && currentDir !== path.dirname(currentDir));
178177

179178
this.log(LogLevel.DEBUG, `File ${filePath} is not ignored (no .contextignore found)`);
180179
return false;

0 commit comments

Comments
 (0)