Skip to main content

no-require-imports

Disallow invocation of require().

Prefer the newer ES6-style imports over require().

Attributes

  • Included in configs
    • ✅ Recommended
    • 🔒 Strict
  • Fixable
    • 🔧 Automated Fixer
    • 💡 Suggestion Fixer
  • 💭 Requires type information

Rule Details

Examples of code for this rule:

var lib = require('lib');
let lib2 = require('lib2');
var lib5 = require('lib5'),
lib6 = require('lib6');
import lib8 = require('lib8');

Options

// .eslintrc.json
{
"rules": {
"@typescript-eslint/no-require-imports": "warn"
}
}

This rule is not configurable.

When Not To Use It

If you don't care about TypeScript module syntax, then you will not need this rule.