# no-mixed-requires

Rule `node/no-mixed-requires`. Disallow `require` calls to be mixed with regular variable declarations

- Source: node
- Technologies: Node.js
- Kind: style
- Needs type information: no
- Autofix: no
- Reach: 2.5M weekly downloads of presets that enable it
- Trend: +97.4% last quarter
- Rank: #1485 by reach, #270 by growth

## Linters

| Linter | Rule name | Recommended | Autofix | Details | Docs |
| --- | --- | --- | --- | --- | --- |
| ESLint | `n/no-mixed-requires` | no | no | package `eslint-plugin-n` | [docs](https://github.com/eslint-community/eslint-plugin-n/blob/HEAD/docs/rules/no-mixed-requires.md) |
| Oxlint | `node/no-mixed-requires` | no | no | plugin `node`, category style | [docs](https://oxc.rs/docs/guide/usage/linter/rules/node/no-mixed-requires.html) |

## Code examples

### Incorrect: the rule reports this

```js
var fs = require('fs'),
    i = 0;

var async = require('async'),
    debug = require('diagnostics').someFunction('my-module'),
    eslint = require('eslint');
```

```js
// 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());
```

```js
var async = require('async'),
    debug = require('diagnostics').someFunction('my-module'), /* allowCall doesn't allow calling any function */
    eslint = require('eslint');
```

### Correct: the rule accepts this

```js
// 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();
```

```js
var async = require('async'),
    debug = require('diagnostics')('my-module'),
    eslint = require('eslint');
```

Examples from the ESLint documentation.

## Enable it

### ESLint: `eslint.config.js`

```js
import n from "eslint-plugin-n";

export default [
  {
    plugins: { n },
    rules: {
      "n/no-mixed-requires": "error",
    },
  },
];
```

### Oxlint: `.oxlintrc.json`

```json
{
  "plugins": [
    "node"
  ],
  "rules": {
    "node/no-mixed-requires": "error"
  }
}
```

## Presets that enable it

| Preset | Linter | Package | Rules | Weekly downloads | Trend |
| --- | --- | --- | --- | --- | --- |
| [Ultracite for Oxlint](https://lintradar.dev/presets/ultracite-oxlint.md) | Oxlint | `ultracite` | 475 | 2.1M | +151.7% |
| [XO](https://lintradar.dev/presets/xo.md) | ESLint | `eslint-config-xo` | 618 | 413K | −5.0% |

## Related rules

- [eslint/no-mixed-requires](https://lintradar.dev/rules/eslint/no-mixed-requires.md): Disallow `require` calls to be mixed with regular variable declarations
- [node/global-require](https://lintradar.dev/rules/node/global-require.md): Require `require()` calls to be placed at top-level module scope
- [node/callback-return](https://lintradar.dev/rules/node/callback-return.md): Require `return` statements after callbacks
- [node/exports-style](https://lintradar.dev/rules/node/exports-style.md): Enforce either `module.exports` or `exports`
- [node/no-callback-literal](https://lintradar.dev/rules/node/no-callback-literal.md): Enforce Node.js-style error-first callback pattern is followed
- [node/file-extension-in-import](https://lintradar.dev/rules/node/file-extension-in-import.md): Enforce the style of file extensions in `import` declarations

---

Web page: https://lintradar.dev/rules/node/no-mixed-requires. Data from npm and the linters' documentation, collected Dec 4, 2026. Site guide for agents: https://lintradar.dev/llms.txt
