简中文档

no-new-symbol

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

禁止使用 new 操作符与内置的 Symbol

Symbol 是通过作为函数调用来创建的,但我们有时会错误地使用 new 操作符进行调用。该规则检测此类错误使用 new 操作符的情况。

无效:

const foo = new Symbol("foo");

有效:

const foo = Symbol("foo");

function func(Symbol: typeof SomeClass) {
  // 这个 `Symbol` 不是内置的
  const bar = new Symbol();
}

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

编辑此页面
隐私政策