Reputation: 838
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?
Upvotes: 8
Views: 1325
Reputation: 1015
I've written a zero-dependency ESLint Preprocessor that allows you to lint .js.erb
files here. Browse through the source code here. With this, you can configure ESLint such that it will also lint your .js.erb
files, see the Readme.
Upvotes: 0
Reputation: 11266
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
Upvotes: 1