简体   繁体   English

如何在* .js.erb文件上运行eslint?

[英]How to to run eslint on *.js.erb files?

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. 我想通过eslint将我的rails项目中的文件(理想情况下,在我的编辑器中进行编辑) lint ,但我目前无法lint使用ERB预处理的文件。

How can I include *.js.erb files in the linting process? 如何在linting过程中包含* .js.erb文件?

You would need to run eslint with -ext js.erb flag. 您需要使用-ext js.erb标志运行eslint。 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. 但是,如果你的文件包含更多只是javascript,你将不得不用处理器创建你自己的插件,除了纯粹的javascript和维护源地图之外,它将删除所有内容,以便在linting之后可以更改错误消息以指向正确的行号。 You can see more information about processors here: http://eslint.org/docs/developer-guide/working-with-plugins#processors-in-plugins 您可以在此处查看有关处理器的更多信息: http//eslint.org/docs/developer-guide/working-with-plugins#processors-in-plugins

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM