Skip to content

deletes

Reports using the delete operator.

✅ This rule is included in the performance preset.

The delete operator in JavaScript modifies the shape of objects, which prevents modern JavaScript engines from optimizing their internal representations. When you delete a property, the engine can no longer use fast property access paths that were optimized for that object’s original shape.

These deoptimizations can significantly impact performance in performance-critical code paths, especially when objects are created and modified frequently.

const user = { name: "Alice", age: 30, email: "alice@example.com" };
delete user.email;
function clearCache(cache: Record<string, any>) {
for (const key in cache) {
delete cache[key];
}
}

This rule is not configurable.

If you are not concerned about performance in a particular code path, or if you need the precise semantics of the delete operator (such as affecting property enumeration or reflecting in hasOwnProperty), you may wish to disable this rule.

In some cases, the performance impact is negligible and code clarity may be more important than the optimization.

Made with ❤️‍🔥 in Boston by Josh Goldberg and contributors.