website/src/pages/lint/rules/noDelete.md
This rule is recommended by Rome.
Disallow the use of the delete operator.
The delete operator enables the removal of a property from an object.
The delete operator should be avoided because it can prevent some optimizations of JavaScript engines.
Moreover, it can lead to unexpected results.
For instance, deleting an array element does not change the length of the array.
The only legitimate use of delete is on an object that behaves like a map.
To allow this pattern, this rule does not report delete on computed properties that are not literal values.
Consider using Map instead of an object.
const arr = [1, 2, 3];
delete arr[0];
const obj = {a: {b: {c: 123}}};
delete obj.a.b.c;
const foo = new Set([1,2,3]);
foo.delete(1);
const map = Object.create(null);
const key = "key"
map[key] = "value"
delete map[key];
let x = 5;
delete f(); // uncovered by this rule.