{"record":{"id":"4ba0a291efdf309d","repo":"oxc-project/oxc","slug":"unexpected-nested-ternary-expression-without-paren","errorCode":null,"errorMessage":"Unexpected nested ternary expression without parentheses.","messagePattern":"Unexpected nested ternary expression without parentheses\\.","errorType":"validation","errorClass":"OxcDiagnostic","httpStatus":null,"severity":"error","filePath":"crates/oxc_linter/src/rules/unicorn/no_nested_ternary.rs","lineNumber":9,"sourceCode":"use oxc_ast::{AstKind, 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 unparenthesized_nested_ternary(span: Span) -> OxcDiagnostic {\n    OxcDiagnostic::warn(\"Unexpected nested ternary expression without parentheses.\")\n        .with_help(\"Add parentheses around the nested ternary expression.\")\n        .with_label(span)\n}\n\nfn deeply_nested_ternary(span: Span) -> OxcDiagnostic {\n    OxcDiagnostic::warn(\"Unexpected deeply nested ternary expression.\")\n        .with_help(\"Avoid nesting ternary expressions for more than one level.\")\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 deeply nested ternary expressions.\n    ///","sourceCodeStart":1,"sourceCodeEnd":27,"githubUrl":"https://github.com/oxc-project/oxc/blob/e1e7af627c8843ab64044ed466b128fcc21a035b/crates/oxc_linter/src/rules/unicorn/no_nested_ternary.rs#L1-L27","documentation":"Raised by unicorn/no-nested-ternary (with its default parens mode) when a ternary appears nested inside another ternary without enclosing parentheses, hurting readability and parse intent. The faulting input is the unparenthesized nested conditional at the labeled span.","triggerScenarios":"Thrown at crates/oxc_linter/src/rules/unicorn/no_nested_ternary.rs:9 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Add parentheses around the nested ternary to make grouping explicit","Refactor the chain into if/else statements or a lookup map for clarity"],"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"}