Lint Rules

noNewSymbol (since v0.10.0)

This rule is recommended by Rome.

Disallow new operators with the Symbol object

Examples

Invalid

var foo = new Symbol('foo');
correctness/noNewSymbol.js:1:11 lint/correctness/noNewSymbol  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

   Symbol cannot be called as a constructor.
  
  > 1 │ var foo = new Symbol('foo');
             ^^^^^^^^^^^^^^^^^
    2 │ 
  
   Suggested fix: Remove new.
  
    1 │ var·foo·=·new·Symbol('foo');
            ----              

Valid

var bar = Symbol('bar');
function baz() {
    function Symbol() { }
    new Symbol();
}