no-var
What it does
Section titled “What it does”Reports a var declaration (also declare var in TypeScript). let and const are not reported.
Why it matters
Section titled “Why it matters”A var belongs to the whole function, not to the block, and is hoisted: it can be read before its line (as undefined) and declared twice in one scope without an error. let and const are limited to their block, a second declaration is an error, and const states that the binding does not change.
To fix, use const where the variable is not assigned again, otherwise let.
Example
Section titled “Example”var a = 1;...let c = 3;c = 4;...Configuration
Section titled “Configuration”js: lint: rules: no-var: warn # off (default), warn, errorEnabled by the presets: js/typescript-eslint-recommended.
Suppress one line with sudsy-disable-next-line no-var in a comment of the file’s language.
Upstream equivalents
Section titled “Upstream equivalents”The same check in other tools; Sudsy reports what each upstream rule reports.
| Tool | Rule | Match |
|---|---|---|
| eslint | no-var |
full |