no-delete-var
NOTE: this rule is part of the
recommended rule set.Enable full set in
deno.json:{
"lint": {
"rules": {
"tags": ["recommended"]
}
}
}Enable full set using the Deno CLI:
deno lint --rules-tags=recommended
This rule can be explictly included to or excluded from the rules present in the current tag by adding it to the
include or exclude array in deno.json:{
"lint": {
"rules": {
"include": ["no-delete-var"],
"exclude": ["no-delete-var"]
}
}
}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