WebStorm can't resolve lodash template delimiter

257 views Asked by At

WebStorm shows inspection errors on lodash template delimiter in js files. I tried adding the EJS plugin as described in this issue, but it still can't resolve the interpolate tag <%= ... %>.

enter image description here

How to configure WebStorm to resolve lodash templates ?

NB: I'm using WS 2020.2.1

1

There are 1 answers

0
lena On BEST ANSWER

Enabling EJS plugin is not enough, as it's not about template syntax support (that is provided for .ejs files), it's about supporting EJS templates embedded in javascript. You can see parser errors because this is not a valid JavaScript. Unfortunately there is no way to tell the parser to skip arbitrary parts of code to avoid errors when building a syntax tree.

I can suggest the following:

  • associate the .js files with embedded "tags" syntax with EJS file type (in Settings | Editor | File Types) by adding <file_name>.js as a pattern there
  • when associating, choose JavaScript as template data language for these files

If it doesn't make things any better, the only solution is turning syntax highlighting off for such files... Highlighting level can be configured by clicking the icon in the editor upper right corner. Please see https://blog.jetbrains.com/idea/2020/05/intellij-idea-2020-2-early-access-program-is-starting/#inspections_widget for details