no-internal-require

ESLint rule disallowing require() calls into internals of another stdlib package.

Usage

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

rule

ESLint rule disallowing require() calls into internals of another stdlib package.

Bad:

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

Good:

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

Examples

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

var linter = new Linter();
var result;

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

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

result = linter.verify( code, {
    'rules': {
        'no-internal-require': 'error'
    }
});
/* returns
    [
        {
            ruleId: 'no-internal-require',
            severity: 2,
            message: 'require() call contains a path which loads a module internal to a stdlib package, and, thus, should be considered private',
            line: 1,
            column: 15,
            nodeType: 'CallExpression',
            source: 'var betainc = require( \'@stdlib/math/base/special/betainc/lib/betainc.js\' )',
            endLine: 1,
            endColumn: 76
        }
    ]
*/