The Symbol
constructor is not intended to be used with the new
operator, but to be called as a function.
var foo = new Symbol("foo");
This throws a TypeError
exception.
This rule is aimed at preventing the accidental calling of Symbol
with the new
operator.
The following patterns are considered problems:
/*eslint no-new-symbol: "error"*/
/*eslint-env es6*/
var foo = new Symbol('foo');
The following patterns are not considered problems:
/*eslint no-new-symbol: "error"*/
/*eslint-env es6*/
var foo = Symbol('foo');
// Ignores shadowed Symbol.
function bar(Symbol) {
const baz = new Symbol("baz");
}
This rule should not be used in ES3/5 environments.