{"record":{"id":"3b50e3815a457ee9","repo":"oxc-project/oxc","slug":"do-not-nest-ternary-expressions","errorCode":null,"errorMessage":"Do not nest ternary expressions.","messagePattern":"Do not nest ternary expressions\\.","errorType":"validation","errorClass":"OxcDiagnostic","httpStatus":null,"severity":"error","filePath":"crates/oxc_linter/src/rules/eslint/no_nested_ternary.rs","lineNumber":10,"sourceCode":"use oxc_ast::AstKind;\nuse oxc_ast::ast::Expression;\nuse oxc_diagnostics::OxcDiagnostic;\nuse oxc_macros::declare_oxc_lint;\nuse oxc_span::Span;\n\nuse crate::{AstNode, context::LintContext, rule::Rule};\n\nfn no_nested_ternary_diagnostic(span: Span) -> OxcDiagnostic {\n    OxcDiagnostic::warn(\"Do not nest ternary expressions.\")\n        .with_help(\n            \"Refactor nested ternary expressions into if-else statements for better readability.\",\n        )\n        .with_label(span)\n}\n\n#[derive(Debug, Default, Clone)]\npub struct NoNestedTernary;\n\ndeclare_oxc_lint!(\n    /// ### What it does\n    ///\n    /// Disallow nested ternary expressions.\n    ///\n    /// ### Why is this bad?\n    ///\n    /// Nested ternary expressions make code harder to read and understand. Nesting of these expressions can lead\n    /// to complex logic that is difficult to understand.","sourceCodeStart":1,"sourceCodeEnd":28,"githubUrl":"https://github.com/oxc-project/oxc/blob/e1e7af627c8843ab64044ed466b128fcc21a035b/crates/oxc_linter/src/rules/eslint/no_nested_ternary.rs#L1-L28","documentation":"Lint diagnostic from eslint/no-nested-ternary: a ternary expression appears inside the consequent or alternate of another ternary. Nested conditionals are hard to parse visually and easy to get wrong when editing.","triggerScenarios":"Thrown at crates/oxc_linter/src/rules/eslint/no_nested_ternary.rs:10 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Refactor into if/else statements","Extract each level into a named variable or helper function","Use a lookup table or switch for multi-way selection"],"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-14T05:17:10.506Z"}