Socket
Socket
Sign inDemoInstall

esformatter-braces

Package Overview
Dependencies
1
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    esformatter-braces

esformatter plugin: enforces braces around statements


Version published
Weekly downloads
445
increased by30.12%
Maintainers
1
Install size
18.3 kB
Created
Weekly downloads
 

Readme

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:

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

FAQs

Last updated on 28 May 2015

Did you know?

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc