Search code examples
htmlvisual-studio-codeejs

VS Code shows problem for some specific EJS code. How to fix this?


Even after checking a lot of EJS + VSCode related SO posts, I am unable to solve this problem. VSCode works fine with some EJS code but it shows problems with some others, I don't understand the reason behind this weird behavior.

In the image below VSCode seems to recognize the line const mbxToken = "<%= process.env.MAPBOX_TOKEN %>" but VSCode doesn't recognize the line below it i.e. const campground = <%- JSON.stringify(campground) %>.

How can I fix this problem OR stop VSCode from checking this particular file / line.

enter image description here


Solution

  • You will solve the problem in the following ways.

    1. In the Visual Studio Code Menu, select 'File > Preferences > Settings'.
    2. Enter 'validate' in Search settings.
    3. Disables the following settings: 'HTML › Validate: Scripts' enter image description here

    This would have solved the problem.

    source link: https://github.com/microsoft/vscode/issues/51118