no-delete-var
NOTE: this rule is part of the
recommended
rule set.Enable full set in
deno.json
:{ "lint": { "tags": ["recommended"] } }
Enable full set using the Deno CLI:
deno lint --tags=recommended
Disallows the deletion of variables.
delete
is used to remove a property from an object. Variables declared via
var
, let
and const
cannot be deleted (delete
will return false
).
Setting strict
mode on will raise a syntax error when attempting to delete a
variable.
Invalid:
const a = 1;
let b = 2;
let c = 3;
delete a; // would return false
delete b; // would return false
delete c; // would return false
Valid:
let obj = {
a: 1,
};
delete obj.a; // return true