不允许在computed key表达式上使用“delete”运算符。
该规则仅支持对.js/.ts文件进行检查。
const container: Record<string, number> = {
/* ... */
};
// Constant runtime lookups by string index
delete container.aaa;
// Constants that must be accessed by []
delete container['7'];
// '-Infinity' is number.
delete container['-Infinity']; const container: Record<string, number> = {
/* ... */
};
// Can be replaced with the constant equivalents, such as container.aaa
delete container['aaa'];
// 'Infinity' may be a string constant
delete container['Infinity'];
// Dynamic, difficult-to-reason-about lookups
const name = 'name';
delete container[name];
delete container[name.toUpperCase()]; plugin:@typescript-eslint/recommended plugin:@typescript-eslint/all
Code Linter代码检查规则的配置指导请参考Code Linter代码检查。