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: about 1 year ago
JSON representation
Prettier plugin to enforce consistent brace style for all control statements. ๐ฅ
- Host: GitHub
- URL: https://github.com/joshuakgoldberg/prettier-plugin-curly
- Owner: JoshuaKGoldberg
- License: mit
- Created: 2023-06-11T13:52:48.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2025-05-06T14:54:06.000Z (about 1 year ago)
- Last Synced: 2025-05-07T07:19:24.147Z (about 1 year ago)
- Topics: curly, formatting, prettier, prettier-plugin
- Language: TypeScript
- Homepage:
- Size: 2.55 MB
- Stars: 58
- Watchers: 3
- Forks: 3
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: .github/CONTRIBUTING.md
- Funding: .github/FUNDING.yml
- License: LICENSE.md
- Code of conduct: .github/CODE_OF_CONDUCT.md
- Security: .github/SECURITY.md
Awesome Lists containing this project
README
prettier-plugin-curly
Prettier plugin to enforce consistent brace style for all control statements.
๐ฅ
## 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
๐

Holger Jeromin
๐

Josh Goldberg
๐ง ๐ง ๐ป ๐ ๐ค ๐ ๐ ๐ ๐

Navin Moorthy
๐

Robin Heidenis
๐ง ๐ป

Stephen Zhou
๐

tawpie
๐

สแดส
๐ ๐ป ๐
> ๐ This package was templated with [`create-typescript-app`](https://github.com/JoshuaKGoldberg/create-typescript-app) using the [Bingo framework](https://create.bingo).