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?
To disable Prettier checks for a single file, we can add the path of the file we want Prettier to ignore into the . prettierignore file. We follow the . gitignore file syntax to add it.
Use . prettierignore to ignore (i.e. not reformat) certain files and folders completely. Use “prettier-ignore” comments to ignore parts of files.
Open up VSCode settings in UI mode by selecting File > Preferences > Settings or press Ctrl + ,. Input “formatter” in the search box. Once you see Editor: Default Formatter section, select . This setting allows you to define a default formatter which takes precedence over all other formatter settings.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With