unassignedVariables
Reports variables that are declared but never assigned a value.
✅ This rule is included in the ts javascript presets.
Variables declared without an initializer and never assigned a value will always be undefined.
This is often a mistake, such as forgetting to initialize a variable or assign to it before use.
Examples
Section titled “Examples”44AE3F53con44AEfuncdede344AE3F53assig61B0processVOptions
Section titled “Options”This rule is not configurable.
When Not To Use It
Section titled “When Not To Use It”If you intentionally want to work with unassigned variables that default to undefined, you might want to disable this rule.
However, it’s generally better to explicitly assign undefined to make the intent clear.
Further Reading
Section titled “Further Reading”Equivalents in Other Linters
Section titled “Equivalents in Other Linters”- Biome:
noUnassignedVariables - ESLint:
no-unassigned-vars - Oxlint:
eslint/no-unassigned-vars
