no-ex-assign
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": ["no-ex-assign"],
"exclude": ["no-ex-assign"]
}
}
}不允许重新赋值异常参数。
一般来说,没有好的理由去重新赋值异常参数。一旦重新赋值,从那时起代码就无法再访问错误。
无效:
try {
someFunc();
} catch (e) {
e = true;
// 无法再访问抛出的错误
}
有效:
try {
someFunc();
} catch (e) {
const anotherVar = true;
}