esformatter-braces
esformatter plugin for enforcing braces around statements
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 ;
into:
if theSkyIsBlue ;
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:
Or you can manually register your plugin:
// register pluginesformatter;
Usage
var fs = ;var esformatter = ;//register plugin manuallyesformatter; var str = fs;var output = esformatter;//-> output will now contain the formatted string
See esformatter for more options and further usage.
License
MIT @Gilad Peleg