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

Relative exclude paths don't work when when run via overcommit #74

Closed
mattbrictson opened this issue Nov 14, 2017 · 2 comments
Closed
Labels

Comments

@mattbrictson
Copy link
Contributor

My project has a .slim-lint.yml in the root of the project containing the following:

exclude:
  - 'lib/templates/slim/**/*'

When run via overcommit, the exclusion is not honored:

$ overcommit -r
Analyze with slim-lint.....................................[SlimLint] FAILED
Unexpected output: unable to determine line number or type of error/warning for output:
(Using Ruby 2.4 parser; configure using `TargetRubyVersion` parameter, under `AllCops`)
/Users/mbrictson/Code/my-rails-app/lib/templates/slim/scaffold/_form.html.slim:6 [W] RuboCop: Lint/Syntax: unexpected token tIDENTIFIER

From what I can tell, this is because overcommit calls the slim-lint command with a list of absolute paths. These absolute paths don't match when compared to the relative exclude pattern.

My current workaround is to prepend a glob wildcard like this:

exclude:
  # Leading "**" is needed for compatibility with overcommit
  - '**/lib/templates/slim/**/*'

However I think a better solution would be for slim-lint to resolve relative paths as relative to the location of the .slim-lint.yml file. This would be consistent with RuboCop's behavior: rubocop/rubocop#892

@sds sds closed this as completed in ef9a07f Nov 21, 2017
@sds sds added the bug label Nov 21, 2017
@sds
Copy link
Owner

sds commented Nov 21, 2017

Thanks for the report, @mattbrictson!

@RKushnir
Copy link

RKushnir commented Dec 27, 2017

@sds The change works only for the top-level excludes, but brakes the linter-specific excludes, like this:

linters:
  LineLength:
    exclude:
      - 'app/views/layouts/mailer.html.slim'

Here's the relevant code

if SlimLint::Utils.any_glob_matches?(linter_config['exclude'], file)

A workaround seems to be to prepend **/ to the path.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants