2 * @fileoverview Rule to disallow use of the new operator with the `Symbol` object
3 * @author Alberto RodrÃguez
8 //------------------------------------------------------------------------------
10 //------------------------------------------------------------------------------
17 description: "disallow `new` operators with the `Symbol` object",
18 category: "ECMAScript 6",
20 url: "https://eslint.org/docs/rules/no-new-symbol"
30 const globalScope = context.getScope();
31 const variable = globalScope.set.get("Symbol");
33 if (variable && variable.defs.length === 0) {
34 variable.references.forEach(ref => {
35 const node = ref.identifier;
37 if (node.parent && node.parent.type === "NewExpression") {
38 context.report({ node, message: "`Symbol` cannot be called as a constructor." });