Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

prettier-plugin-curly

JoshuaKGoldberg124.9kMIT0.3.1TypeScript support: included

Prettier plugin to enforce consistent brace style for all control statements. 🥌

readme

prettier-plugin-curly

Prettier plugin to enforce consistent brace style for all control statements. 🥌

All Contributors: 8 👪 Codecov Test Coverage Contributor Covenant License: MIT Sponsor: On GitHub Style: Prettier TypeScript: Strict npm package version Contributor Covenant

Usage

First install this package as a dev dependency in your package manager of choice:

npm i prettier-plugin-curly -D

You'll then be able to list it as a Prettier plugin in your Prettier config:

{
    "plugins": ["prettier-plugin-curly"]
}

As a result, Prettier will add {} curly brackets to control flow statements such as for, if, and while:

- if (abc) def;
+ if (abc) {
+   def;
+ }

But Why?

Prettier generally does not modify the structure of code: which includes not enforcing curly brackets to match ESLint's curly rule. However, enforcing curly generally does not modify code runtime behavior, and is often desirable for code consistency and to avoid accidental bugs. This plugin enforces the equivalent of curly's all option at the Prettier level.

See The Blurry Line Between Formatting and Style for more details.

Development

See .github/CONTRIBUTING.md, then .github/DEVELOPMENT.md. Thanks! 💖

Contributors

Dan Vanderkam
Dan Vanderkam

🐛
Holger Jeromin
Holger Jeromin

🐛
Josh Goldberg
Josh Goldberg

🔧 🚧 💻 🚇 🤔 🐛
Navin Moorthy
Navin Moorthy

🐛
Robin Heidenis
Robin Heidenis

🔧
Stephen Zhou
Stephen Zhou

🐛
tawpie
tawpie

🐛
ʀᴀʏ
ʀᴀʏ

📖 💻 🐛

💙 This package is based on @JoshuaKGoldberg's create-typescript-app.

changelog

0.3.0 (2024-10-10)

Features

  • updated Babel dependencies and miscellaneous devDependencies (#591) (d31eaa4)

0.2.2 (2024-07-17)

Bug Fixes

  • support running inside a CommonJS module (09d4f1c)

0.2.1 (2024-03-16)

Bug Fixes

  • allow empty statement bodies (203a355)

0.2.0 (2024-03-16)

Bug Fixes

  • only print modified nodes (122c65f)

Features

  • fully reprint AST with @babel/generator (efb121c)

0.1.4 (2024-02-20)

Bug Fixes

  • correctly handle blockstatement (#86) (622c259)
  • empty commit to trigger release flow (6e12092)
  • handle non-block else statements (881f607)

Changelog