esformatter plugin for automagically wrap line when they are over a configurable length.
- Wrap lines that are too long
- Unwrap lines that fit under the configured length
- Respects your original esformatter whitespace settings
- Different wrapping strategy for different type of expressions
install it:
npm install esformatter-auto-wrap
and something like this to your esformatter config file:
{
"plugins": [
"esformatter-auto-wrap"
]
}
The following is the default configuration for the plugin, which can be reproduced and modified in your .esformatter config:
{
"autoWrap": {
"maxLineLength": 120,
"eclipseCompatible": true
}
}
The maximum lenght a line is allowed to be before being wrapped onto the next line.
Eclipse's JSDT formatter has some funky rules for formatting Javascript code. With this setting active, autoWrap attempts to be compatible with Eclipse's rules (avoiding merge conflicts and such).
Register the plugin and call esformatter like so:
// register plugin
esformatter.register(require('esformatter-auto-wrap'));
// pass options as second argument
var output = esformatter.format(str, options);
Released under the MIT License.