Search code examples
intellij-ideawebstormcode-inspection

IntelliJ IDEA and backticks (`)


In our environment, we write template Javascript which has areas where server pre-processing inserts values into the code.

An example would look like this:

    var myVarValue = "`serverProcessedVarValue()`";

In the above, the server runs the function demarcated by the backticks and writes the result between the quotes, then ships that javascript off to the browser.

We use IntelliJ IDEA. It (and Webstorm, I'm assuming) highlights these backticks as a coding error. I can't find a setting to change that behavior. Is there one?

Thanks!


Solution

  • There is no such setting. IntelliJ IDEA builds a complete syntax tree for the file you're editing, and all of its features rely on having the complete syntax tree. Because of that, it's not possible to tell it to ignore certain characters - it would not know how to parse the remaining code and how to validate the resulting syntax tree.

    What you can do is either write a plugin to parse your specific flavor of JavaScript with templates, or change the syntax you're using to match one of the template languages already supported by IntelliJ IDEA.