# esformatter-braces

> esformatter plugin: enforces braces around statements

Latest version **1.2.1** (published 2015-05-28) · MIT license · 0 weekly downloads

## Install

```sh
npm install esformatter-braces
pnpm add esformatter-braces
yarn add esformatter-braces
bun add esformatter-braces
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.2.1 |
| Published | 2015-05-28 |
| First published | 2014-07-02 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=0.10.0 |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 9 |
| Author | Gilad Peleg |
| Maintainers | pgilad |
| Keywords | esformatter, esformatter-plugin, string, braces, AST, rocambole, esprima, codestyle |

## Links

- npm: https://www.npmjs.com/package/esformatter-braces
- Repository: https://github.com/pgilad/esformatter-braces
- Homepage: https://github.com/pgilad/esformatter-braces#readme
- Issues: https://github.com/pgilad/esformatter-braces/issues
- npm.io page: https://npm.io/package/esformatter-braces

## Dependencies (1)

- [rocambole-token](https://npm.io/package/rocambole-token.md) ^1.2.1

## Alternatives

- [update-check](https://npm.io/package/update-check.md) — 4.0M weekly downloads
- [react-native-onesignal](https://npm.io/package/react-native-onesignal.md) — 134.5K weekly downloads
- [react-redux-toastr](https://npm.io/package/react-redux-toastr.md) — 33.7K weekly downloads
- [@nocobase/plugin-notification-manager](https://npm.io/package/@nocobase/plugin-notification-manager.md) — 2.0K weekly downloads
- [react-simple-toasts](https://npm.io/package/react-simple-toasts.md) — 1.9K weekly downloads

## Recent versions

- 1.2.1 (latest) — 2015-05-28
- 1.2.0 — 2015-05-14
- 1.1.0 — 2015-05-08
- 1.0.0 — 2014-10-27
- 0.4.1 — 2014-10-04
- 0.4.0 — 2014-10-01
- 0.3.0 — 2014-10-01
- 0.2.0 — 2014-09-19
- 0.1.7 — 2014-08-29
- 0.1.6 — 2014-08-11
- 0.1.5 — 2014-07-26
- 0.1.4 — 2014-07-15
- 0.1.3 — 2014-07-02
- 0.1.2 — 2014-07-02
- 0.1.1 — 2014-07-02

## README

# [esformatter](https://github.com/millermedeiros/esformatter)-braces

> esformatter plugin for enforcing braces around statements

[![NPM Version](http://img.shields.io/npm/v/esformatter-braces.svg?style=flat)](https://npmjs.org/package/esformatter-braces)
[![NPM Downloads](http://img.shields.io/npm/dm/esformatter-braces.svg?style=flat)](https://npmjs.org/package/esformatter-braces)
[![Build Status](http://img.shields.io/travis/pgilad/esformatter-braces.svg?style=flat)](https://travis-ci.org/pgilad/esformatter-braces)

**Esformatter-braces** is a plugin for [esformatter](https://github.com/millermedeiros/esformatter) meant for brace enforcement around statements. Recommended by Douglas Crockford in his [coding style guide](http://javascript.crockford.com/code.html).

Turn this:
```js
if (theSkyIsBlue)
    stareAtItForAWhile();
```

into:
```js
if (theSkyIsBlue) {
    stareAtItForAWhile();
}
```

For more information see:
- [Jetbrain's Idea](http://www.jetbrains.com/idea/webhelp10.5/wrapping-and-braces.html) and specifically the **Force brace always** section.
- The [jsHint](https://github.com/jshint/jshint/) option - [curly](http://www.jshint.com/docs/options/#curly)

Currently the following node statements are handled:
 **If conditionals**, **While**, **Do While**, **For loops**

*For any other formatting (such as braces placement, spacing and line wrapping) use esformatter or other plugins.*

## Goals

- Add similar options to IDEA's: **Do not force** and **Multiline**
- Possibly do the reverse: remove braces if possible (single line statements)

## Installation

```sh
$ npm install esformatter-braces --save-dev
```

## Config

Newest esformatter versions autoload plugins from your `node_modules` [See this](https://github.com/millermedeiros/esformatter#plugins)

Add to your esformatter config file:

```json
{
  "plugins": [
    "esformatter-braces"
  ]
}
```

Or you can manually register your plugin:
```js
// register plugin
esformatter.register(require('esformatter-braces'));
```

## Usage

```js
var fs = require('fs');
var esformatter = require('esformatter');
//register plugin manually
esformatter.register(require('esformatter-braces'));

var str = fs.readFileSync('someKewlFile.js').toString();
var output = esformatter.format(str);
//-> output will now contain the formatted string
```

See [esformatter](https://github.com/millermedeiros/esformatter) for more options and further usage.

## License

MIT @[Gilad Peleg](http://giladpeleg.com)

---
_Source: https://npm.io/package/esformatter-braces · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
