Skip to content
Branch: master
Go to file
Code

Latest commit

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 

README.md

NO PRODUCTION PLUGIN: IT'S STILL UNDER DEVELOPMENT

esformatter-onevar

esformatter plugin for enforcing one var statement per function scope

Esformatter-onevar is a plugin for esformatter meant for onevar enforcement in function scope. Recommended by Douglas Crockford in his coding style guide.

Turn this:

var foo = 'foo',
    bar = 'bar';

var hello = true,
    world = false;
    
for (var i = 0, l = 10; i < l; i++) {
	var chain = chain + ' ' + i;
}

into:

var foo = 'foo',
    bar = 'bar',
    hello,
    world,
    i,
    l,
    chain;

hello = true;
world = false;
    
for (i = 0, l = 10; i < l; i++) {
	chain = chain + ' ' + i;
}

For more information see:

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

Installation

$ npm install esformatter-onevar --save-dev

Config

Newest esformatter versions autoload plugins from your node_modules See this

Add to your esformatter config file:

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

Or you can manually register your plugin:

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

Usage

var fs = require('fs');
var esformatter = require('esformatter');
//register plugin manually
esformatter.register(require('esformatter-onevar'));

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 ©2014 Evan Vosberg

About

[DRAFT] - Esformatter plugin to enforcing one var statement per function scope

Resources

License

Releases

No releases published
You can’t perform that action at this time.