Skip to content

Commit

Permalink
fix: Match ignore-pattern starting with "./"
Browse files Browse the repository at this point in the history
Providing an ignore pattern e.g. via CLI `--ignore-pattern` did not work
when the path started with "./".

Fixes: #407
  • Loading branch information
matz3 committed Dec 3, 2024
1 parent 8f0911d commit 4eb2758
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions src/linter/linter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,11 @@ function buildPatterns(patterns: string[]) {
pattern += "**/*";
}

// Remove leading "./" from the pattern, as it otherwise would not match
if (pattern.startsWith("./")) {
pattern = pattern.slice(2);
}

return new Minimatch(pattern, {flipNegate: true});
});
}
Expand Down
2 changes: 1 addition & 1 deletion test/lib/linter/linter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ test.serial("lint: Ignore files from library.with.custom.paths", async (t) => {
ignorePatterns: [
"src/",
"!src/main/",
"ui5.yaml",
"./ui5.yaml", // Relative paths starting with "./" should match the same as without it
],
});

Expand Down

0 comments on commit 4eb2758

Please sign in to comment.