no-mixed-requires
eslint
No autofix
eslint.config.js
export default [
{
rules: {
"no-mixed-requires": "error",
},
},
];This rule is deprecated. Check its documentation for a replacement before enabling it.
Disallow require calls to be mixed with regular variable declarations
var fs = require('fs'),
i = 0;
var async = require('async'),
debug = require('diagnostics').someFunction('my-module'),
eslint = require('eslint');// invalid because of mixed types "core" and "module"
var fs = require('fs'),
async = require('async');
// invalid because of mixed types "file" and "unknown"
var foo = require('foo'),
bar = require(getBarModuleName());var async = require('async'),
debug = require('diagnostics').someFunction('my-module'), /* allowCall doesn't allow calling any function */
eslint = require('eslint');// only require declarations (grouping off)
var eventEmitter = require('events').EventEmitter,
myUtils = require('./utils'),
util = require('util'),
bar = require(getBarModuleName());
// only non-require declarations
var foo = 42,
bar = 'baz';
// always valid regardless of grouping because all declarations are of the same type
var foo = require('foo' + VERSION),
bar = require(getBarModuleName()),
baz = require();var async = require('async'),
debug = require('diagnostics')('my-module'),
eslint = require('eslint');Examples from the ESLint documentation.
no-mixed-requires
eslint
export default [
{
rules: {
"no-mixed-requires": "error",
},
},
];Oxlint does not have this rule.
Biome does not have this rule.
Disallow require calls to be mixed with regular variable declarations
Enforce consistent naming when capturing the current execution context
Disallow use of this in contexts where the value of this is undefined
Enforce a maximum depth that blocks can be nested
Enforce a maximum number of lines per file
Enforce a maximum number of parameters in function definitions