简中文档

no-class-assign

NOTE: this rule is part of the recommended rule set.
Enable full set in deno.json:
{
  "lint": {
    "rules": {
      "tags": ["recommended"]
    }
  }
}
Enable full set using the Deno CLI:
deno lint --rules-tags=recommended
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-class-assign"],
      "exclude": ["no-class-assign"]
    }
  }
}

不允许修改类声明的变量。

声明一个类,例如 class A {},将创建一个变量 A。与任何变量一样,这个变量可以被修改或重新赋值。在大多数情况下,这是一种错误,并不是预期的结果。

无效:

class A {}
A = 0; // 重新赋值给类变量本身

有效:

class A {}
let c = new A();
c = 0; // 重新赋值给变量 `c`

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

编辑此页面
隐私政策