Skip to content

sosoba/prettier-plugin-expressions

Repository files navigation

@sosoba/prettier-plugin-expressions

npm version

This is a prettier plugin which improves the readability of expressions by surrounding them with bracket even if they are not necessary for calculating machines.

🆘 raw Prettier style ✅ with this plugin Discusion
1 + 2 * 3 + 4 / 2 1 + (2 * 3) + (4 / 2) prettier/prettier#187
condA && condB ? 1 : 0 (condA && condB) ? 1 : 0 prettier/prettier#3805

Installation

Prerequisites: Prettier (^3).

Add plugin as develompment-only dependency:

npm install --save-dev @sosoba/prettier-plugin-expressions # or yarn, pnpm etc.

Configuration

Add plugin in a manner appropriate to the configuration method chosen in the project and enable desired options. Ex.:

.prettierrc.yaml:

plugins:
  - '@sosoba/prettier-plugin-expressions'
parenthesesInExpressionsWithMixedOperators: true
parenthesesAroundConditionalInTernaryExpression: true

.prettierrc.json:

{
  "plugins": ["@sosoba/prettier-plugin-expressions"],
  "parenthesesInExpressionsWithMixedOperators": true,
  "parenthesesAroundConditionalInTernaryExpression": true
}

About

Prettier plugin which which improves the readability of expressions by surrounding them with brackets

Resources

Stars

Watchers

Forks

Packages

No packages published