diff --git a/packages/knip/src/util/glob-core.ts b/packages/knip/src/util/glob-core.ts index a13db7c23..babce2ad1 100644 --- a/packages/knip/src/util/glob-core.ts +++ b/packages/knip/src/util/glob-core.ts @@ -54,7 +54,7 @@ export const parseAndConvertGitignorePatterns = (patterns: string, ancestor?: st .split(/\r?\n/) .filter(line => line.trim() && !line.startsWith('#')) .flatMap(line => { - const pattern = line.replace(/(? { { negated: false, patterns: ['c', 'c/**'] }, ]); }); + +test('parseAndConvertGitignorePatterns (hashes)', async () => { + const gitignorePatterns = ['#comment', 'ends-with-hash#', String.raw`\#starts-with-hash`]; + const globPatterns = parse(gitignorePatterns.join(EOL)); + assert.deepEqual(globPatterns, [ + { negated: false, patterns: ['**/ends-with-hash#', '**/ends-with-hash#/**'] }, + { negated: false, patterns: ['**/#starts-with-hash', '**/#starts-with-hash/**'] }, + ]); +});