symbolDescriptions
Reports Symbol() calls without description arguments.
✅ This rule is included in the ts stylistic
preset.
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.
Examples
Section titled “Examples”const uniqueId = Symbol();const privateKey = Symbol();
class MyClass { [Symbol()]() { return "method"; }}
const uniqueId = Symbol("uniqueId");const privateKey = Symbol("privateKey");
class MyClass { [Symbol("customMethod")]() { return "method"; }}
// Well-known symbols don't need descriptionsconst iterator = Symbol.iterator;
// Symbol.for() creates global symbols with identifiersconst globalSymbol = Symbol.for("app.config");
Options
Section titled “Options”This rule is not configurable.
When Not To Use It
Section titled “When Not To Use It”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.
Further Reading
Section titled “Further Reading”Equivalents in Other Linters
Section titled “Equivalents in Other Linters”- Biome:
useSymbolDescription
- ESLint:
symbol-description
- Oxlint:
eslint/symbol-description
Made with ❤️🔥 in Boston by
Josh Goldberg and contributors.