esformatter-onevar

    0.2.0-dev • Public • Published

    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 (= 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

    Install

    npm i esformatter-onevar

    DownloadsWeekly Downloads

    3

    Version

    0.2.0-dev

    License

    MIT

    Last publish

    Collaborators

    • avatar