Shopify / erb_lint

Lint your ERB or HTML files
MIT License
676 stars 122 forks source link

Add `--show-linter-names` option #340

Closed andyw8 closed 6 months ago

andyw8 commented 10 months ago

Closes #336

This PR adds a --show-linter-names option. It prepends each offence with the linter name.

It applies only to the Multiline and Compact reporters. The JSON and JUnit reporters already include the linter name, so I have left them as-is.

Note: If RuboCop is enabled, RuboCop offences will display as:

[Rubocop] Layout/TrailingEmptyLines: Final newline missing.
In file: app/views/announcements/index.html.erb:2

(the cop name part was already there, but having the [RuboCop] prefix now makes it easier to distinguish the source of each offence).

andyw8 commented 10 months ago

As soon as I opened this, I spotted that @Earlopain already has a similar PR: https://github.com/Shopify/erb-lint/pull/328

The main differences are:

Earlopain commented 10 months ago

Your implementation is better, I've closed my PR. I do think it should be enabled by default though, same as RuboCop does it.

They print cop names if there is more than one cop enabled, so if you run with --only Lint/Abc the cop name will be omitted since it is unambiguous. Seems to be --enable-linters here, however I don't know how that interacts with the rubocop cops.

andyw8 commented 10 months ago

Thanks @Earlopain

My only concern about enabling it by default is that someone may have built tooling based on the current report format (although the JSON reporter would have been a better choice).

I'll wait for others to weigh in on whether to make this the default behaviour.

andyw8 commented 10 months ago

Note: If allowing this to be set, we should probably also add a ShowLinterNames option for the config file.

andyw8 commented 6 months ago

Rebased to resolve conflicts.