简中文档

no-self-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-self-assign"],
      "exclude": ["no-self-assign"]
    }
  }
}

禁止自我赋值。

自我赋值像 a = a; 根本没有任何效果。如果代码中存在自我赋值,大多数情况下意味着作者仍在重构过程中,还有剩余的工作需要完成。

无效:

a = a;
[a] = [a];
[a, b] = [a, b];
[a, b] = [a, c];
[a, ...b] = [a, ...b];
a.b = a.b;

有效:

let a = a;
a += a;
a = [a];
[a, b] = [b, a];
a.b = a.c;

你找到了你需要的东西吗?

编辑此页面
隐私政策