no-delete-var
What it does
Section titled “What it does”Reports delete applied to a plain variable name, also in parentheses (delete x, delete (x)). delete x.y and delete x[0] remove a property and are not reported.
Why it matters
Section titled “Why it matters”delete removes object properties, not variables. On a variable it does nothing in sloppy mode (the expression is false) and is a syntax error in strict mode and in modules, so the code either has no effect or does not run.
To fix, assign undefined to the variable or leave the scope, or delete the property of an object instead.
Example
Section titled “Example”...var x; delete x; delete x.y; delete (x);...Configuration
Section titled “Configuration”js: lint: rules: no-delete-var: error # off, warn, error (default)Enabled by the presets: js/eslint-recommended, js/oxlint.
Suppress one line with sudsy-disable-next-line no-delete-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-delete-var |
full |