new-cap-array

ESLint rule enforcing that the Array constructor is invoked with the new keyword.

Usage

var rule = require( '@stdlib/_tools/eslint/rules/new-cap-array' );

rule

ESLint rule enforcing that the Array constructor is invoked with the new keyword.

Bad:

var arr = Array( 101 );

Good:

var arr = new Array( 101 );

Examples

var Linter = require( 'eslint' ).Linter;
var rule = require( '@stdlib/_tools/eslint/rules/new-cap-array' );

var linter = new Linter();
var result;

var code = 'var arr = Array( 10 );';

linter.defineRule( 'new-cap-array', rule );

result = linter.verify( code, {
    'rules': {
        'new-cap-array': 'error'
    }
});
/* returns
    [
        {
            ruleId: 'new-cap-array',
            severity: 2,
            message: '`Array` constructor is invoked without the `new` keyword',
            line: 1,
            column: 11,
            nodeType: 'CallExpression',
            source: 'var arr = Array( 10 );',
            endLine: 1,
            endColumn: 41
        }
    ]
*/