ban-unused-ignore
NOTE: this rule is part of the
推荐 rule set.Enable full set in
deno.json:{
"lint": {
"rules": {
"tags": ["推荐"]
}
}
}Enable full set using the Deno CLI:
deno lint --rules-tags=推荐
This rule can be explictly included to or excluded from the rules present in the current tag by adding it to the
include or exclude array in deno.json:{
"lint": {
"rules": {
"include": ["ban-unused-ignore"],
"exclude": ["ban-unused-ignore"]
}
}
}警告未使用的忽略指令。
我们有时出于某些原因不得不抑制和忽略 lint 错误,我们可以使用 忽略指令 来实现。
然而,在某些情况下,比如重构之后,我们可能会拥有不再必要的忽略指令。这些多余的忽略指令可能会让未来的代码阅读者困惑,更糟糕的是,可能无意中掩盖未来的 lint 错误。为了防止这种情况,此规则检测未使用的多余忽略指令。
无效:
// 实际上这行是有效的,因为 `export` 意味着“已使用”,
// 所以这个指令是多余的
// deno-lint-ignore no-unused-vars
export const foo = 42;
有效:
export const foo = 42;