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
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"] } } }
Disallows the use of new
operators with built-in Symbol
s.
Symbol
s 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();
}