]>
git.proxmox.com Git - pve-eslint.git/blob - eslint/lib/rules/no-new-symbol.js
aeb509c0d9c1424396f4a5a684fd62fb14cb75da
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"
26 noNewSymbol
: "`Symbol` cannot be called as a constructor."
34 const globalScope
= context
.getScope();
35 const variable
= globalScope
.set.get("Symbol");
37 if (variable
&& variable
.defs
.length
=== 0) {
38 variable
.references
.forEach(ref
=> {
39 const node
= ref
.identifier
;
40 const parent
= node
.parent
;
42 if (parent
&& parent
.type
=== "NewExpression" && parent
.callee
=== node
) {
45 messageId
: "noNewSymbol"