]>
git.proxmox.com Git - pve-eslint.git/blob - eslint/lib/rules/no-new-symbol.js
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",
19 url
: "https://eslint.org/docs/rules/no-new-symbol"
25 noNewSymbol
: "`Symbol` cannot be called as a constructor."
33 const globalScope
= context
.getScope();
34 const variable
= globalScope
.set.get("Symbol");
36 if (variable
&& variable
.defs
.length
=== 0) {
37 variable
.references
.forEach(ref
=> {
38 const node
= ref
.identifier
;
39 const parent
= node
.parent
;
41 if (parent
&& parent
.type
=== "NewExpression" && parent
.callee
=== node
) {
44 messageId
: "noNewSymbol"