Little Monkey
Little Monkey

Reputation: 6157

Intellij "reformat code" command doesn't follow prettier rules

I created a Vue project via Quasar, picking Prettier as ESLint preset.

When I try the "reformat code" command, it doesn't follow completely the prettier rules. In the specific, I found problems when it has to ignore stuff.

For example:

Having these prettier rules (.prettierrc file):

{
  "singleQuote": true,
  "semi": false
}

when I try "reformat code" with this code

//prettier-ignore
  name: "App"

it will convert double quotes to single quotes.

If I use "reformat with prettier" everything works fine, but is there a way to override the reformat code behavior?

I'm asking this also because in the commit changes dialog there is the "reformat code" option that I would like to use. I don't know if it's maybe possible to add a "reformat code with prettier" option there

Upvotes: 2

Views: 3740

Answers (1)

lena
lena

Reputation: 93868

The IDEA code formatter is not supposed to respect //prettier-ignore comments. But you can set up Prettier as the default formatter per instructions in https://www.jetbrains.com/help/idea/2021.1/prettier.html#ws_prettier_default_formatter to be used on Code > Reformat Code

Upvotes: 3

Related Questions