Skip to main content

no-unused-expressions

Disallow unused expressions.


此规则扩展了基本 eslint/no-unused-expressions 规则。 它添加了对可选调用表达式 x?.() 和模块声明中的指令的支持。

英:This rule extends the base eslint/no-unused-expressions rule. It adds support for optional call expressions x?.(), and directive in module declarations.

如何使用

.eslintrc.cjs
module.exports = {
"rules": {
// Note: you must disable the base rule as it can report incorrect errors
"no-unused-expressions": "off",
"@typescript-eslint/no-unused-expressions": "error"
}
};
在线运行试试这个规则 ↗

选项

参见 eslint/no-unused-expressions 选项

资源

摘自 ❤️ ESLint 内核