An open API service indexing awesome lists of open source software.

https://github.com/joshuakgoldberg/prettier-plugin-curly

Prettier plugin to enforce consistent brace style for all control statements. ๐ŸฅŒ
https://github.com/joshuakgoldberg/prettier-plugin-curly

curly formatting prettier prettier-plugin

Last synced: 5 months ago
JSON representation

Prettier plugin to enforce consistent brace style for all control statements. ๐ŸฅŒ

Awesome Lists containing this project

README

          

prettier-plugin-curly


Prettier plugin to enforce consistent brace style for all control statements.
๐ŸฅŒ




๐Ÿ‘ช All Contributors: 8


๐Ÿค Code of Conduct: Kept
๐Ÿงช Coverage
๐Ÿ“ License: MIT
๐Ÿ“ฆ npm version
๐Ÿ’ช TypeScript: Strict

## Usage

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

```shell
npm i prettier-plugin-curly -D
```

You'll then be able to list it as a [Prettier plugin](https://prettier.io/docs/en/plugins.html) in your [Prettier config](https://prettier.io/docs/en/configuration.html):

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

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

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

### But Why?

Prettier generally does not modify the structure of code: which includes [not enforcing curly brackets](https://github.com/prettier/prettier/issues/7659) to match [ESLint's `curly` rule](https://eslint.org/docs/latest/rules/curly).
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](https://eslint.org/docs/latest/rules/curly#all) at the Prettier level.

> See [The Blurry Line Between Formatting and Style](https://blog.joshuakgoldberg.com/the-blurry-line-between-formatting-and-style) for more details.

## Development

See [`.github/CONTRIBUTING.md`](./.github/CONTRIBUTING.md), then [`.github/DEVELOPMENT.md`](./.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 was templated with [`create-typescript-app`](https://github.com/JoshuaKGoldberg/create-typescript-app) using the [Bingo framework](https://create.bingo).