How to to run eslint on *.js.erb files?

1.2k views Asked by At

I'd like to lint the files in my rails project (ideally, in my editor while making edits) via eslint, but I am currently unable to lint files that are pre-processed with ERB.

How can I include *.js.erb files in the linting process?

1

There are 1 answers

1
Ilya Volodin On

You would need to run eslint with -ext js.erb flag. If your files contain more then just javascript, however, you will have to create your own plugin with processor, that would strip out everything but pure javascript and maintain source map, so that error messages can be changed to point to correct line numbers after linting. You can see more information about processors here: http://eslint.org/docs/developer-guide/working-with-plugins#processors-in-plugins