no-nested-require

ESLint rule enforcing that one does not use nested property access for require() expressions.

Usage

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

rule

ESLint rule enforcing that one does not use nested property access for require() expressions.

Bad:

var special = require( '@stdlib' ).math.base.special;

Good:

var special = require( '@stdlib/math/base' ).special;

special = require( '@stdlib/math/base/special' );

Examples

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

var linter = new Linter();
var result;
var code;

code = 'var special = require( \'@stdlib/math\' ).base.special;';

linter.defineRule( 'no-nested-require', rule );

result = linter.verify( code, {
    'rules': {
        'no-nested-require': 'error'
    }
});
/* =>
    [
        {
            ruleId: 'no-nested-require',
            severity: 2,
            message: 'do not use nested property access for require() expressions',
            line: 2,
            column: 15,
            nodeType: 'CallExpression',
            source: 'var special = require( \'@stdlib/math\' ).base.special;',
            endLine: 2,
            endColumn: 29
        }
    ]
*/