ID: typescript-best-practices/no-var-requires
Language: TypeScript
Severity: Warning
Category: Best Practices
Description
Use ESM instead of CommonJS imports.
Non-Compliant Code Examples
var foo = require('foo');
const foo = require('foo');
let foo = require('foo');
let foo = trick(require('foo'));
var foo = require?.('foo');
const foo = require?.('foo');
let foo = require?.('foo');
let foo = trick(require?.('foo'));
let foo = trick?.(require('foo'));
const foo = require('./foo.json') as Foo;
const foo: Foo = require('./foo.json').default;
// const foo = <Foo>require('./foo.json');
// https://github.com/typescript-eslint/typescript-eslint/issues/3883
// const configValidator = new Validator(require('./a.json'));
// configValidator.addSchema(require('./a.json'));
Compliant Code Examples
import foo = require('foo');
require('foo');
require?.('foo');
Seamless integrations. Try Datadog Code Analysis