Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bug with excluding files by linter #255

Merged
merged 1 commit into from
Jun 13, 2022

Conversation

joshski
Copy link

@joshski joshski commented May 27, 2022

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:

---
linters:
  DeprecatedClasses:
    enabled: true
    exclude:
      - 'app/views/shared/deprecated/**'

...would not actually exclude the DeprecatedClasses linter for any views under app/views/shared/deprecated/**

I have reproduced this bug in a separate git repository as follows.

The following commit joshski/erblint-exclude-bug-demo@6477573

  • adds erb_lint to a new rails 7 app
  • violates the ErbSafety lint rule.
  • includes a script to reproduce the bug.

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 the base_path of the ERBLint::FileLoader.

@rafaelfranca rafaelfranca merged commit 943506f into Shopify:main Jun 13, 2022
@shopify-shipit shopify-shipit bot temporarily deployed to production June 15, 2022 23:51 Inactive
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants