You're Invited: Meet the Socket team at BSidesSF and RSAC - April 27 - May 1.RSVP
Socket
Sign inDemoInstall
Socket

esformatter-braces

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

esformatter-braces

esformatter plugin: enforces braces around statements

1.2.1
latest
Source
npm
Version published
Maintainers
1
Created
Source

esformatter-braces

esformatter plugin for enforcing braces around statements

NPM Version NPM Downloads Build Status

Esformatter-braces is a plugin for esformatter meant for brace enforcement around statements. Recommended by Douglas Crockford in his coding style guide.

Turn this:

if (theSkyIsBlue)
    stareAtItForAWhile();

into:

if (theSkyIsBlue) {
    stareAtItForAWhile();
}

For more information see:

  • Jetbrain's Idea and specifically the Force brace always section.
  • The jsHint option - 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

$ npm install esformatter-braces --save-dev

Config

Newest esformatter versions autoload plugins from your node_modules See this

Add to your esformatter config file:

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

Or you can manually register your plugin:

// register plugin
esformatter.register(require('esformatter-braces'));

Usage

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 for more options and further usage.

License

MIT @Gilad Peleg

Keywords

esformatter

FAQs

Package last updated on 28 May 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts