docs/src/rules/symbol-description.md
The Symbol function may have an optional description:
const foo = Symbol("some description");
const someString = "some description";
const bar = Symbol(someString);
Using description promotes easier debugging: when a symbol is logged the description is used:
const foo = Symbol("some description");
> console.log(foo);
// Symbol(some description)
It may facilitate identifying symbols when one is observed during debugging.
This rules requires a description when creating symbols.
Examples of incorrect code for this rule:
::: incorrect
/*eslint symbol-description: "error"*/
const foo = Symbol();
:::
Examples of correct code for this rule:
::: correct
/*eslint symbol-description: "error"*/
const foo = Symbol("some description");
const someString = "some description";
const bar = Symbol(someString);
:::
This rule has no options.
This rule should not be used in ES3/5 environments.
In addition, this rule can be safely turned off if you don't want to enforce presence of description when creating Symbols.