Prettier disable on certain languages not working

Viewed 3452

On VS Code, I installed the prettier extensions, and since it doesn't support EJS, I added"prettier.disableLanguages": [ "ejs", ".ejs" ] to the setting.json file. This also shows up in the regular settings under Prettier: Disable Languages. Despite this, prettier keeps on re-formatting my EJS, which is super frustrating. How do I stop prettier from modifying a certain language besides this method?

2 Answers

Since Prettier knows nothing about EJS, it doesn't understand what you wrote in prettier.disableLanguages. Also VS Code considers .ejs files HTML. This not exactly accurate conclusion is passed to the Prettier extension, which in turn passes it to Prettier, so Prettier tries to format your files as pure HTML.

Try adding *.ejs to the .prettierignore file. You can read more about it here: https://prettier.io/docs/en/ignore.html

Your can add this "[html]": { "editor.formatOnSave": false }, in your settings.json file in VSCode it will prevent auto formating html files, prettier still not have any ignore for .ejs files. As .ejs files are still taken as html files by prettier.

Related