close

no-new-symbol

Configuration

rslint.config.ts
import { defineConfig, js } from '@rslint/core';

export default defineConfig([
  js.configs.recommended,
  {
    rules: {
      'no-new-symbol': 'error',
    },
  },
]);

Rule Details

Disallows new Symbol(). Symbol is not intended to be used with the new operator, but to be called as a function. Calling new Symbol() throws a TypeError at runtime because Symbol is not a constructor.

Examples of incorrect code for this rule:

var foo = new Symbol('foo');
new Symbol();

Examples of correct code for this rule:

var foo = Symbol('foo');

Original Documentation