Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion crates/rstack-ignore/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
7 changes: 7 additions & 0 deletions packages/rstack/tests/fmt/ignore.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down