{"record":{"id":"2c6d1ec8e2f3cd1b","repo":"oxc-project/oxc","slug":"the-value-of-the-member-member-name-should-be","errorCode":null,"errorMessage":"The value of the member {member_name:?} should be explicitly defined.","messagePattern":"The value of the member (.+?) should be explicitly defined\\.","errorType":"validation","errorClass":"OxcDiagnostic","httpStatus":null,"severity":"error","filePath":"crates/oxc_linter/src/rules/typescript/prefer_enum_initializers.rs","lineNumber":14,"sourceCode":"use oxc_ast::{AstKind, ast::TSEnumMemberName};\nuse oxc_diagnostics::OxcDiagnostic;\nuse oxc_macros::declare_oxc_lint;\nuse oxc_span::Span;\n\nuse crate::{\n    AstNode,\n    context::{ContextHost, LintContext},\n    fixer::RuleFixer,\n    rule::Rule,\n};\n\nfn prefer_enum_initializers_diagnostic(member_name: &str, span: Span) -> OxcDiagnostic {\n    OxcDiagnostic::warn(format!(\n        \"The value of the member {member_name:?} should be explicitly defined.\"\n    ))\n    .with_help(format!(\n        \"Using default numerical values for enum members can cause bugs later on if the enum is modified. Instead give {member_name:?} an explicit initializer (for example `= 0` or `= '{member_name}'`).\"\n    ))\n    .with_note(\n        \"TypeScript computes uninitialized enum members as numbers: the first one defaults \\\n         to `0`, and each following uninitialized member is the previous numeric value plus `1`.\",\n    )\n    .with_label(span)\n}\n\n#[derive(Debug, Default, Clone)]\npub struct PreferEnumInitializers;\n\ndeclare_oxc_lint!(\n    /// ### What it does\n    ///","sourceCodeStart":1,"sourceCodeEnd":32,"githubUrl":"https://github.com/oxc-project/oxc/blob/e1e7af627c8843ab64044ed466b128fcc21a035b/crates/oxc_linter/src/rules/typescript/prefer_enum_initializers.rs#L1-L32","documentation":"Raised by typescript/prefer_enum_initializers when a TS enum member has no explicit initializer (e.g. `enum E { A, B }`). At the throw site the member silently receives an auto-incremented number (previous member + 1, or 0 for the first), so inserting or reordering members later shifts all following values — a hazard for serialized/persisted enums. prefer_enum_initializers_diagnostic fires from run() for each member lacking an initializer, naming the member in the message.","triggerScenarios":"Thrown at crates/oxc_linter/src/rules/typescript/prefer_enum_initializers.rs:14 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Add an explicit initializer to every enum member (e.g. A = 0, B = 1 or string values)."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}