Question

I was curious if there was a way to make Rubocop lint/stylecop html.erb files? I realize that the html would make it hard to style cop the embedded Ruby. Has anyone been able to get Rubocop to do this? If not, is there an equivalent tool for this purpose? I have used rails_best_practices and it doesn't quite work as desired.

Was it helpful?

Solution

There is a linting gem called ERB lint which includes RuboCop.

Previous version of answer

In May 2014, there was a feature request asking for this functionality in RuboCop, and it was rejected by the head of the project.

Request:

Right now when I try to run rubocop on an erb template it does not parse out the ruby code. It would be nice to run rubocop on every file that has ruby code in it.

Reply:

That's beyond the scope of the core RuboCop project. Someone has to create a project similar to haml-lint, which uses RuboCop internally.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top