How do I stop csslint and jshint from linting my EJS in Atom?

863 views Asked by At

I'm editing EJS files in Atom. I currently have linter-csslint and linter-jshint packages installed. Both seem to be recognising the .ejs files as .html and linting it as HTML.

This is what I see

enter image description here

How do I get the linters to ignore .ejs files? Or is there a EJS specific linter for Atom?

3

There are 3 answers

0
Ross On BEST ANSWER

You can ignore all .ejs files with a .jshintignore file (https://jshint.com/docs/cli/#ignoring-files). I've just added one myself to fix this same issue in Atom and it seems to have worked.

I created ~/.jshintignore with the following content:

*.ejs

Worth noting that this affects anything else using jshint.

2
Matthew Schuchard On

Based on that photo, it appears that you installed the language-ejs package and it is taking precedence on identifying the language. The problem here is not actually the linters, but rather the language-html package.

In the scopes for linter-csslint and linter-jshint, we see that both will lint on language-html scopes. However, your file is in the language-ejs scope. 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. The reason that language-html is also a scope here is seen here.

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. 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. Also, Atom should probably not be identifying files as having multiple grammar scopes, but that is a more difficult issue to pursue.

PR to fix this permanently is here.

0
Joe On

You could just go to the packages and disable that particular package.