diff --git a/packages/knip/src/util/glob-core.ts b/packages/knip/src/util/glob-core.ts index e948fe063..a13db7c23 100644 --- a/packages/knip/src/util/glob-core.ts +++ b/packages/knip/src/util/glob-core.ts @@ -111,18 +111,18 @@ export const findAndParseGitignores = async (cwd: string) => { const patterns = readFileSync(filePath, 'utf8'); for (const rule of parseAndConvertGitignorePatterns(patterns, ancestor)) { - const [pattern, extraPattern] = rule.patterns; + const [pattern1, pattern2] = rule.patterns; if (rule.negated) { if (base === '' || base.startsWith('..')) { - if (!unignores.includes(extraPattern)) { + if (!unignores.includes(pattern2)) { unignores.push(...rule.patterns); - dirUnignores.add(pattern); - dirUnignores.add(extraPattern); + dirUnignores.add(pattern1); + dirUnignores.add(pattern2); } } else { - if (!unignores.includes(extraPattern.startsWith('**/') ? extraPattern : `**/${extraPattern}`)) { - const unignore = join(base, pattern); - const extraUnignore = join(base, extraPattern); + if (!unignores.includes(pattern2.startsWith('**/') ? pattern2 : `**/${pattern2}`)) { + const unignore = join(base, pattern1); + const extraUnignore = join(base, pattern2); unignores.push(unignore, extraUnignore); dirUnignores.add(unignore); dirUnignores.add(extraUnignore); @@ -130,21 +130,17 @@ export const findAndParseGitignores = async (cwd: string) => { } } else { if (base === '' || base.startsWith('..')) { - if (!ignores.has(extraPattern)) { - ignores.add(pattern); - ignores.add(extraPattern); - dirIgnores.add(pattern); - dirIgnores.add(extraPattern); - } + ignores.add(pattern1); + ignores.add(pattern2); + dirIgnores.add(pattern1); + dirIgnores.add(pattern2); } else { - if (!ignores.has(extraPattern.startsWith('**/') ? extraPattern : `**/${extraPattern}`)) { - const ignore = join(base, pattern); - const extraIgnore = join(base, extraPattern); - ignores.add(ignore); - ignores.add(extraIgnore); - dirIgnores.add(ignore); - dirIgnores.add(extraIgnore); - } + const ignore = join(base, pattern1); + const extraIgnore = join(base, pattern2); + ignores.add(ignore); + ignores.add(extraIgnore); + dirIgnores.add(ignore); + dirIgnores.add(extraIgnore); } } }