Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Prevent Prettier from removing parentheses

I'm using Prettier in VS Code on a React Native project and it removes parentheses in mixed operators or when declaring a var with a parenthesis. How to prevent Prettier from doing that?

Example 1:

 const foo = (a && b) || c;

After:

const foo = a && b || c;

Example 2:

const c = (a.toString()).toUpperCase();

After:

const c = a.toString().toUpperCase();

I know that in most cases it doesn't change the logic but I want to disable this feature.

like image 379
cold programmmer Avatar asked Sep 09 '25 22:09

cold programmmer


1 Answers

You can use “prettier-ignore” comments to ignore parts of files. Like // prettier-ignore

Here you have a link to documentation: https://prettier.io/docs/en/ignore.html

like image 185
KeltoRino Avatar answered Sep 12 '25 12:09

KeltoRino