Skip to content

symbolDescriptions

Reports Symbol() calls without description arguments.

✅ This rule is included in the ts stylistic and stylisticStrict presets.

Creating symbols without descriptions makes debugging difficult, as the symbol’s purpose isn’t clear when inspecting it. While the description doesn’t affect the symbol’s uniqueness, it appears in the symbol’s string representation and can be accessed via Symbol.prototype.description. Providing meaningful descriptions helps developers understand the purpose of each symbol during debugging and logging.

const
const uniqueId: typeof uniqueId
uniqueId
=
var Symbol: SymbolConstructor
(description?: string | number) => symbol

Returns a new unique Symbol value.

@paramdescription Description of the new Symbol object.

Symbol
();
const
const privateKey: typeof privateKey
privateKey
=
var Symbol: SymbolConstructor
(description?: string | number) => symbol

Returns a new unique Symbol value.

@paramdescription Description of the new Symbol object.

Symbol
();
class
class MyClass
MyClass
{
[
var Symbol: SymbolConstructor
(description?: string | number) => symbol

Returns a new unique Symbol value.

@paramdescription Description of the new Symbol object.

Symbol
()]() {
return "method";
}
}

This rule is not configurable.

If you’re working in a codebase where symbol descriptions aren’t important for debugging purposes, or if you dynamically create many anonymous symbols, you might choose to disable this rule.

Made with ❤️‍🔥 around the world by the Flint team and contributors.