diff --git a/crates/rstack-ignore/src/lib.rs b/crates/rstack-ignore/src/lib.rs index 842db51f..965307ef 100644 --- a/crates/rstack-ignore/src/lib.rs +++ b/crates/rstack-ignore/src/lib.rs @@ -68,7 +68,9 @@ impl SourceMatcher { for line in source.patterns.split('\n') { let line = line.strip_suffix('\r').unwrap_or(line); let line = line.strip_prefix('\u{feff}').unwrap_or(line); - builder.add_line(None, line)?; + // Gitignore files and the previous JavaScript matcher treat malformed lines as + // nonmatching, while continuing to apply the remaining valid rules. + let _ = builder.add_line(None, line); } Ok(Self { diff --git a/packages/rstack/tests/fmt/ignore.test.ts b/packages/rstack/tests/fmt/ignore.test.ts index 1d033618..68220775 100644 --- a/packages/rstack/tests/fmt/ignore.test.ts +++ b/packages/rstack/tests/fmt/ignore.test.ts @@ -29,6 +29,13 @@ test('matches gitignore patterns relative to the config root', async () => { expect(isIgnored(path.join(rootPath, 'src/index.js'))).toBe(false); }); +test('skips malformed patterns without discarding valid patterns', async () => { + const isIgnored = await createMatcher(['ignored.js', 'malformed\\']); + + expect(isIgnored(path.join(rootPath, 'ignored.js'))).toBe(true); + expect(isIgnored(path.join(rootPath, 'other.js'))).toBe(false); +}); + test('distinguishes directory-only patterns from files', async () => { const isIgnored = await createMatcher(['dist/']); const directoryPath = path.join(rootPath, 'dist');