[英]How do I stop csslint and jshint from linting my EJS in Atom?
I'm editing EJS files in Atom.我正在 Atom 中编辑 EJS 文件。 I currently have linter-csslint and linter-jshint packages installed.
我目前安装了 linter-csslint 和 linter-jshint 包。 Both seem to be recognising the .ejs files as .html and linting it as HTML.
两者似乎都将 .ejs 文件识别为 .html 并将其检查为 HTML。
This is what I see这是我看到的
How do I get the linters to ignore .ejs files?如何让 linter 忽略 .ejs 文件? Or is there a EJS specific linter for Atom?
或者是否有针对 Atom 的 EJS 特定 linter?
You can ignore all .ejs
files with a .jshintignore
file ( https://jshint.com/docs/cli/#ignoring-files ).您可以使用
.jshintignore
文件 ( https://jshint.com/docs/cli/#ignoring-files ) 忽略所有.ejs
文件。 I've just added one myself to fix this same issue in Atom and it seems to have worked.我自己刚刚添加了一个来解决 Atom 中的同样问题,它似乎奏效了。
I created ~/.jshintignore
with the following content:我用以下内容创建了
~/.jshintignore
:
*.ejs
Worth noting that this affects anything else using jshint.值得注意的是,这会影响使用 jshint 的任何其他内容。
Based on that photo, it appears that you installed the language-ejs
package and it is taking precedence on identifying the language.根据那张照片,您似乎安装了
language-ejs
包,并且它优先于识别语言。 The problem here is not actually the linters, but rather the language-html
package.这里的问题实际上不是 linter,而是
language-html
包。
In the scopes for linter-csslint and linter-jshint , we see that both will lint on language-html
scopes.在linter-csslint和linter -jshint的作用域中,我们看到它们都将在
language-html
作用域上进行 lint。 However, your file is in the language-ejs
scope.但是,您的文件在
language-ejs
范围内。 What is happening here is that Atom should be locking the scope down to just language-ejs
, but is instead mixing between that and language-html
.这里发生的事情是 Atom 应该将范围锁定到仅
language-ejs
,而是在它和language-html
之间混合。 The reason that language-html
is also a scope here is seen here .之所以说
language-html
也是一个范围在这里被认为是在这里。
So fixing this for yourself is actually pretty easy.所以为自己解决这个问题实际上很容易。 You can open up the source code for the
language-html
package locally (should be in ~/.atom/packages/language-html/grammars/html.cson
) and remove the ejs
line that I showed above.您可以在本地打开
language-html
包的源代码(应该在~/.atom/packages/language-html/grammars/html.cson
)并删除我上面显示的ejs
行。 However, the better long term fix is to probably raise an issue on language-html
that you do not believe ejs
is within the grammar scope of html
.但是,更好的长期解决方案可能是在
language-html
上提出一个问题,您认为ejs
不在html
的语法范围内。 Also, Atom should probably not be identifying files as having multiple grammar scopes, but that is a more difficult issue to pursue.此外,Atom 可能不应该将文件识别为具有多个语法范围,但这是一个更难解决的问题。
您可以转到软件包并禁用该特定软件包。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.