init-declarations
Configuration
Rule Details
Require or disallow initialization in variable declarations. This is the
TypeScript-aware version of the ESLint init-declarations rule: bindings
introduced by declare (either on the declaration itself or on an enclosing
declare namespace / declare module 'm' / declare global) are skipped.
Examples of incorrect code for this rule:
Examples of correct code for this rule:
Options
mode
Type: "always" | "never" — Default: "always"
When set to "always", every variable declaration must include an initializer.
When set to "never", declarators that include an initializer are reported.
const, using, and await using bindings are exempt from "never" because
they require an initializer at parse time.
Examples of incorrect code with "never":
Examples of correct code with "never":
ignoreForLoopInit
Type: boolean — Default: false
Only meaningful when mode is "never". When true, declarators in the
initializer / left slot of for, for-in, and for-of statements are not
reported.
Examples of correct code with ["never", { "ignoreForLoopInit": true }]: