Skip to content

typescript/no-var-requires Restriction ​

What it does ​

Disallow require statements except in import statements

Why is this bad? ​

In other words, the use of forms such as var foo = require("foo") are banned. Instead use ES6 style imports or import foo = require("foo") imports.

typescript
var foo = require("foo");
const foo = require("foo");
let foo = require("foo");

How to use ​

To enable this rule in the CLI or using the config file, you can use:

bash
oxlint --deny typescript/no-var-requires
json
{
  "rules": {
    "typescript/no-var-requires": "error"
  }
}

References ​

Released under the MIT License.