{"record":{"id":"f90ff87da8ba904d","repo":"oxc-project/oxc","slug":"expected-symbol-to-have-a-description","errorCode":null,"errorMessage":"Expected Symbol to have a description.","messagePattern":"Expected Symbol to have a description\\.","errorType":"validation","errorClass":"OxcDiagnostic","httpStatus":null,"severity":"warning","filePath":"crates/oxc_linter/src/rules/eslint/symbol_description.rs","lineNumber":12,"sourceCode":"use oxc_ast::AstKind;\nuse oxc_diagnostics::OxcDiagnostic;\nuse oxc_macros::declare_oxc_lint;\nuse oxc_span::Span;\n\nuse crate::{AstNode, context::LintContext, rule::Rule};\n\n#[derive(Debug, Default, Clone)]\npub struct SymbolDescription;\n\nfn symbol_description_diagnostic(span: Span) -> OxcDiagnostic {\n    OxcDiagnostic::warn(\"Expected Symbol to have a description.\")\n        .with_help(\"Pass a description argument to the Symbol()\")\n        .with_label(span)\n}\n\ndeclare_oxc_lint!(\n    /// ### What it does\n    ///\n    /// Require symbol descriptions.\n    ///\n    /// ### Why is this bad?\n    ///\n    /// The Symbol function may have an optional description.\n    ///\n    /// ```js\n    /// var foo = Symbol(\"some description\");\n    ///\n    /// var someString = \"some description\";\n    /// var bar = Symbol(someString);","sourceCodeStart":1,"sourceCodeEnd":30,"githubUrl":"https://github.com/oxc-project/oxc/blob/e1e7af627c8843ab64044ed466b128fcc21a035b/crates/oxc_linter/src/rules/eslint/symbol_description.rs#L1-L30","documentation":"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.","triggerScenarios":"`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).","commonSituations":"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.","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."],"exampleFix":"// before\nconst EVENT_FIRED = Symbol();\n\n// after\nconst EVENT_FIRED = Symbol('event.fired');","handlingStrategy":"validation","validationCode":"# flag description-less symbols\nrg -n --pcre2 '\\bnew\\s+Symbol\\(\\s*\\)|(?<!\\.)Symbol\\(\\s*\\)' src/","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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."],"tags":["eslint","oxlint","symbol","debugging","lint"],"backgroundTag":"symbol-description-missing","analyzedSha":"e1e7af627c8843ab64044ed466b128fcc21a035b","analyzedAt":"2026-08-20T07:01:07.079Z","contentChangedAt":"2026-08-20T07:01:07.079Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}