How to to run eslint on *.js.erb files?
Asked Answered
S

2

8

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?

Snowber answered 10/6, 2015 at 5:16 Comment(0)
J
1

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

Jennine answered 4/7, 2015 at 1:6 Comment(1)
I am using eslint version 4.19.0 and the flag has to be --ext js.erb with two dashes.Mancilla
A
0

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.

Audryaudrye answered 12/10 at 15:55 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.