JS.BASE.NO.DELETE.VAR

Disallow deleting variables

The purpose of the delete operator is to remove a property from an object. Using the delete operator on a variable might lead to unexpected behavior.

Rule Details

This rule disallows the use of the delete operator on variables.

If ESLint parses code in strict mode, the parser (instead of this rule) reports the error.

Examples of incorrect code for this rule:

Copy
/*eslint no-delete-var: "error"*/

var x;
delete x;

The content on this page is adapted from the ESLint User Guide. Copyright © OpenJS Foundation and other contributors, www.openjsf.org. All rights reserved. https://eslint.org/docs/rules/