Description
It appears the loading custom linters from CLI doesn't work correctly. Following the README instructions is met with:
$ bundle exec erblint --enable-linters custom_linter --lint-all
custom_linter: not a valid linter name (rubocop, rubocop_text, parser_errors, space_around_erb_tag, space_in_html_tag, extra_newline, right_trim, erb_safety, trailing_whitespace, closing_erb_tag_indent, space_indentation, hard_coded_string, no_javascript_tag_helper, allowed_script_type, self_closing_tag, final_newline, deprecated_classes)
Taking a dive into this, it appears that options are loaded and validated before the custom linters are loaded.
Here the args are validated against known_linter_names
:
known_linter_names
expects that all the linters have already been loaded:
But in the LinterRegistry
we can see that custom linters are only explicitly loaded when load_custom_linters
is called:
load_custom_linters
is only called when the Runner is initialised, but that happens some 30 lines after the options have been validated:
Changing the known_linter_names
to be the following appears to fix the issue:
def known_linter_names
@known_linter_names ||= begin
ERBLint::LinterRegistry.load_custom_linters
ERBLint::LinterRegistry.linters
.map(&:simple_name)
.map(&:underscore)
end
end
(Note that Custom Linters still don't work at this point as the README is out of date #123)
Activity