このページは日本語には対応しておりません。随時翻訳に取り組んでいます。
翻訳に関してご質問やご意見ございましたら、
お気軽にご連絡ください。
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