oxc-project/oxc · warning · OxcDiagnostic
Expected Symbol to have a description.
Error message
Expected Symbol to have a description.
What it means
oxlint `eslint/symbol-description`: `Symbol()` was invoked without a description argument. `symbol_description_diagnostic` (symbol_description.rs:12) reports 'Expected Symbol to have a description.' with help 'Pass a description argument to the Symbol()'. Descriptions show up in `Symbol.prototype.toString`/`description` and are the only way to tell two otherwise-anonymous symbols apart while debugging.
Source
Thrown at crates/oxc_linter/src/rules/eslint/symbol_description.rs:12
use oxc_ast::AstKind;
use oxc_diagnostics::OxcDiagnostic;
use oxc_macros::declare_oxc_lint;
use oxc_span::Span;
use crate::{AstNode, context::LintContext, rule::Rule};
#[derive(Debug, Default, Clone)]
pub struct SymbolDescription;
fn symbol_description_diagnostic(span: Span) -> OxcDiagnostic {
OxcDiagnostic::warn("Expected Symbol to have a description.")
.with_help("Pass a description argument to the Symbol()")
.with_label(span)
}
declare_oxc_lint!(
/// ### What it does
///
/// Require symbol descriptions.
///
/// ### Why is this bad?
///
/// The Symbol function may have an optional description.
///
/// ```js
/// var foo = Symbol("some description");
///
/// var someString = "some description";
/// var bar = Symbol(someString);View on GitHub (pinned to e1e7af627c)
Solutions
- Pass a descriptive string: `Symbol()` becomes `Symbol('user.id')`.
- For well-known symbols (`Symbol.iterator` etc.) nothing is needed — the rule only flags constructor calls with no arguments.
- Keep descriptions stable and meaningful; they aid stack traces and `console.log` output but do not affect identity.
Example fix
// before
const EVENT_FIRED = Symbol();
// after
const EVENT_FIRED = Symbol('event.fired'); Defensive patterns
Strategy: validation
Validate before calling
# flag description-less symbols rg -n --pcre2 '\bnew\s+Symbol\(\s*\)|(?<!\.)Symbol\(\s*\)' src/
Prevention
- Always pass a short, namespaced description: `Symbol('feature.flag')`.
- Descriptions are free at runtime and show up in toString — make them meaningful for debugging.
- Enable symbol-description in shared configs so anonymous symbols never merge.
When it happens
Trigger: `const s = Symbol();` or `const s = new Symbol();` — a call to the global `Symbol` with an empty argument list (an explicit `undefined` argument defeats the purpose and is equally undescriptive).
Common situations: Registry/constant symbols created quickly without labels; tutorial code copied verbatim; symbols used as object keys where debugging later requires knowing which symbol is which.
Related errors
- Empty array binding pattern
- Empty object binding pattern
- `alert`, `confirm` and `prompt` functions are not allowed
- `debugger` statement is not allowed
- Redundant Boolean call
AI-assisted analysis of oxc-project/oxc@e1e7af627c (2026-08-20).
Data as JSON: /api/errors/f90ff87da8ba904d.
Report an issue: GitHub.