no-immediate-require

ESLint rule enforcing that require() expressions are not immediately invoked.

Usage

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

rule

ESLint rule enforcing that require() expressions are not immediately invoked.

Bad:

var debug = require( 'debug' )( 'stdlib' );

Good:

var logger = require( 'debug' );

var debug = logger( 'stdlib' );

Examples

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

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

code = 'var pdf = require( \'@stdlib/math/base/dists/normal/pdf\' ).factory( 0.0, 1.0 );';

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

result = linter.verify( code, {
    'rules': {
        'no-immediate-require': 'error'
    }
});
/* returns
    [
        {
            ruleId: 'no-immediate-require',
            severity: 2,
            message: 'require() calls should only use string literals',
            line: 2,
            column: 15,
            nodeType: 'CallExpression',
            source: 'var pdf = require( \'@stdlib/math/base/dists/normal/pdf\' ).factory( 0.0, 1.0 );',
            endLine: 2,
            endColumn: 29
        }
    ]
*/