Make Prettier ignore JavaScript formatting

1.7k views Asked by At

In VSCode I have Prettier and ESLint installed. I have added the ESLint configuration to my user preferences settings, so the ESLint is the same on all projects.

I want Prettier to use ESLint as the formatter instead of its own, which I can do using:

"prettier.eslintIntegration": true

However, this does not actually use my ESLint configuration, which I wrote here:

"eslint.options": {
    "rules": [
        ...
    ]
}

I have enabled editor.formatOnSave, which should use the Prettier as the formatter (it might not, but I'm not sure).

How do I force ESLint to be the one and only formatter for JavaScript, but still have Prettier to format my CSS?

Alternatively: I think that when I have editor.formatOnSave enabled, it also formats my JavaScript. How do I disable that? It would appear the Prettier is only for JavaScript, TypeScript, and CSS.

1

There are 1 answers

0
MortenMoulder On

Okay, so I figured it out:

"javascript.format.enable": false

This forces editor.formatOnSave to not format, but if I then do:

"eslint.autoFixOnSave": true

It now formats my JavaScript by my ESLint configuration, while it uses the built-in HTML and CSS formatter for HTML and CSS. Exactly how I want it.