4

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?

htshame
  • 6,599
  • 5
  • 36
  • 56
Ben Morgan
  • 45
  • 1
  • 1
  • 7

3 Answers3

3

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.

Ross
  • 2,701
  • 16
  • 25
1

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.

Matthew Schuchard
  • 25,172
  • 3
  • 47
  • 67
  • Thanks Matt, that makes sense. But language-html is a core package, I can't seem to get to it locally without going into Atom dev mode. Is there something I'm missing? – Ben Morgan Oct 25 '18 at 14:23
  • @BenMorgan No, you stated it correctly. The fix for just yourself is not a long term fix. I double checked and it does seem `ejs` should not be in the html scope. However, there does seem to be quite a bit of support in Atom for treating EJS like html. It looks like they treated EJS as html instead of using the `html.ejs`. I will PR. – Matthew Schuchard Oct 25 '18 at 14:37
0

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

Joe
  • 26
  • 3