no-redeclare

ESLint rule disallowing variable redeclarations.

Usage

var rule = require( '@stdlib/_tools/eslint/rules/no-redeclare' );

rule

ESLint rule disallowing variable redeclarations.

Bad:

var a = 'beep';

// ...

var a = 'boop';

Good:

var a = 'beep';

// ...

a = 'boop';

Examples

var Linter = require( 'eslint' ).Linter;
var rule = require( '@stdlib/_tools/eslint/rules/no-redeclare' );

var linter = new Linter();
var result;

var code = 'var Object = 0';

linter.defineRule( 'no-redeclare', rule );

result = linter.verify( code, {
    'rules': {
        'no-redeclare': [ 'error', {
            'builtinGlobals': true
        }]
    }
});
/* returns
    [
        {
            ruleId: 'no-redeclare',
            severity: 2,
            message: 'Object is already defined',
            line: 1,
            column: 5,
            nodeType: 'Identifier',
            source: 'var Object = 0',
            endLine: 1,
            endColumn: 11
        }
    ]
*/