eslint-plugin-misc

ESLint plugin

This project is maintained by iliubinskii

prefer-const-require

ESLint plugin / prefer-const-require

Requires “require()” to be assigned to variable.

module.exports = {
  plugins: ["misc"],
  rules: {
    "misc/prefer-const-require": "error"
  }
};

Examples of incorrect code

function f() { return require("node:path"); }

Examples of correct code

const path = require("node:path");