haml-lint integrates with RuboCop to provide linting of Ruby code embedded in HAML templates. It infers which RuboCop configuration file to use based on the file path passed in. If passed a path to a temporary file, haml-lint will fall back to using the default RuboCop configuration file, rather than a project-specific config, which will not be the desired behaviour in many cases.
Maybe there's a case for haml-lint being moved into the ale-lint-file-linters category, and the behaviour changed accordingly? A similar decision was recently made for the AtomLinter HAML plugin: https://github.com/AtomLinter/linter-haml/pull/113.
Some linters search for the configuration file and specify it manually. That's one potential option. Otherwise you're right, there might be technical limitations for this one which prevent checking for problems while you type.
Just found this in the README:
You can also explicitly set which RuboCop configuration to use via the HAML_LINT_RUBOCOP_CONF environment variable. This is intended to be used by external tools which run the linter on files in temporary directories separate from the directory where the HAML template originally resided (and thus where the normal .rubocop.yml would be picked up).
Nice. Reminds me of what was done for another similar tool. I can't remember the specific tool, but one of them sets a rubocop configuration file in this way, with slightly different commands for Unix and Windows.
What about something like g:ale_haml_hamllint_rubocop_config_file='~/.rubocop.yml' which could be translated into HAML_LINT_RUBOCOP_CONF=~/.rubycop.yml html-lint some/tempfile ?
Easier than adding --rubocop-config to haml-lint itself.
Yeah, that's right. Have a look at ale_linters/slim/slimlint.vim. That was the one which does a similar thing.
Now the rubocop configuration file and the haml-lint configuration files will be used automatically, thanks to @thenoseman.
Awesome! Thanks @thenoseman and @w0rp for fixing this so quickly! :+1:
Most helpful comment
Now the rubocop configuration file and the haml-lint configuration files will be used automatically, thanks to @thenoseman.