typescript-eslint.io
Open in
urlscan Pro
18.192.94.96
Public Scan
URL:
https://typescript-eslint.io/rules/no-var-requires/
Submission: On October 08 via api from US — Scanned from DE
Submission: On October 08 via api from US — Scanned from DE
Form analysis
0 forms found in the DOMText Content
Skip to main content typescript-eslintDocsRulesBlog v6.7.4 Playground SearchK * Overview * TypeScript Rules * adjacent-overload-signatures * array-type * await-thenable * ban-ts-comment * ban-tslint-comment * ban-types * class-literal-property-style * consistent-generic-constructors * consistent-indexed-object-style * consistent-type-assertions * consistent-type-definitions * consistent-type-exports * consistent-type-imports * explicit-function-return-type * explicit-member-accessibility * explicit-module-boundary-types * member-ordering * method-signature-style * naming-convention * no-base-to-string * no-confusing-non-null-assertion * no-confusing-void-expression * no-duplicate-enum-values * no-duplicate-type-constituents * no-dynamic-delete * no-empty-interface * no-explicit-any * no-extra-non-null-assertion * no-extraneous-class * no-floating-promises * no-for-in-array * no-import-type-side-effects * no-inferrable-types * no-invalid-void-type * no-meaningless-void-operator * no-misused-new * no-misused-promises * no-mixed-enums * no-namespace * no-non-null-asserted-nullish-coalescing * no-non-null-asserted-optional-chain * no-non-null-assertion * no-redundant-type-constituents * no-require-imports * no-this-alias * no-unnecessary-boolean-literal-compare * no-unnecessary-condition * no-unnecessary-qualifier * no-unnecessary-type-arguments * no-unnecessary-type-assertion * no-unnecessary-type-constraint * no-unsafe-argument * no-unsafe-assignment * no-unsafe-call * no-unsafe-declaration-merging * no-unsafe-enum-comparison * no-unsafe-member-access * no-unsafe-return * no-useless-empty-export * no-var-requires * non-nullable-type-assertion-style * parameter-properties * prefer-as-const * prefer-enum-initializers * prefer-for-of * prefer-function-type * prefer-includes * prefer-literal-enum-member * prefer-namespace-keyword * prefer-nullish-coalescing * prefer-optional-chain * prefer-readonly * prefer-readonly-parameter-types * prefer-reduce-type-parameter * prefer-regexp-exec * prefer-return-this-type * prefer-string-starts-ends-with * prefer-ts-expect-error * promise-function-async * require-array-sort-compare * restrict-plus-operands * restrict-template-expressions * sort-type-constituents * strict-boolean-expressions * switch-exhaustiveness-check * triple-slash-reference * typedef * unbound-method * unified-signatures * Extension Rules * class-methods-use-this * default-param-last * dot-notation * init-declarations * no-array-constructor * no-dupe-class-members * no-empty-function * no-extra-semi * no-implied-eval * no-invalid-this * no-loop-func * no-loss-of-precision * no-magic-numbers * no-redeclare * no-restricted-imports * no-shadow * no-throw-literal * no-unused-expressions * no-unused-vars * no-use-before-define * no-useless-constructor * require-await * return-await * Formatting Rules * Deprecated Rules On this page NO-VAR-REQUIRES > Disallow require statements except in import statements. ✅ Extending "plugin:@typescript-eslint/recommended" in an ESLint configuration enables this rule. 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. .eslintrc.cjs module.exports = { "rules": { "@typescript-eslint/no-var-requires": "error" } }; Try this rule in the playground ↗ EXAMPLES * ❌ Incorrect * ✅ Correct var foo = require('foo'); const foo = require('foo'); let foo = require('foo'); import foo = require('foo'); require('foo'); import foo from 'foo'; OPTIONS This rule is not configurable. WHEN NOT TO USE IT If you don't care about using newer module syntax, then you will not need this rule. RELATED TO * no-require-imports RESOURCES * Rule source * Test source Edit this page Previous no-useless-empty-export Next non-nullable-type-assertion-style * Examples * Options * When Not To Use It * Related To * Resources Community * Discord * Mastodon * Stack Overflow * Twitter More * GitHub * Report issue Copyright © 2023 typescript-eslint, Inc. Built with Docusaurus.