no-new-symbol
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
Disallows the use of new operators with built-in Symbols.
Symbols are created by being called as a function, but we sometimes call it
with the new operator by mistake. This rule detects such wrong usage of the
new operator.
Invalid:
const foo = new Symbol("foo");
Valid:
const foo = Symbol("foo");
function func(Symbol: typeof SomeClass) {
// This `Symbol` is not built-in one
const bar = new Symbol();
}