Fix bug with excluding files by linter #255
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
When excluding files from specific linters, globs that are relative to the application root directory do not exclude files matching the glob. For example, the following snippet from the readme:
...would not actually exclude the
DeprecatedClasses
linter for any views underapp/views/shared/deprecated/**
I have reproduced this bug in a separate git repository as follows.
The following commit joshski/erblint-exclude-bug-demo@6477573
erb_lint
to a new rails 7 appErbSafety
lint rule.The subsequent commit in the same repo demonstrates the bug is fixed, using the revision of
erb_lint
proposed by this PR.joshski/erblint-exclude-bug-demo@bcace06
Solution
When the
ErbLint::Runner
rejects linters for a given processed source file, match against exclusion globs using a filename relative to thebase_path
of theERBLint::FileLoader
.