Index

no-delete-var

不允许删除变量

Recommended

配置文件 中使用来自 @eslint/jsrecommended 配置可以启用此规则

delete 运算符的目的是从对象中移除一个属性。在变量上使用 delete 运算符可能会导致意外的行为。

🌐 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

此规则禁止在变量上使用 delete 运算符。

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

如果 ESLint 在严格模式下解析代码,解析器(而不是这个规则)会报告错误。

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

此规则的错误代码示例:

🌐 Examples of incorrect code for this rule:

在线运行
/*eslint no-delete-var: "error"*/

let x;
delete x;

选项

🌐 Options

此规则没有选项。

🌐 This rule has no options.

版本

此规则是在 ESLint v0.0.9 中引入。

资源