no-constant-condition
注意: 此规则是
recommended
规则集的一部分。在
deno.json
中启用完整规则集{ "lint": { "tags": ["recommended"] } }
使用 Deno CLI 启用完整规则集
deno lint --tags=recommended
禁止在条件测试中使用常量表达式。
在条件测试中使用常量表达式通常是错误,或者是在开发过程中引入的临时情况,尚未准备好用于生产环境。
无效
if (true) {}
if (2) {}
do {} while (x = 2); // infinite loop
有效
if (x) {}
if (x === 0) {}
do {} while (x === 2);