Skip to content

Commit 75e01fc

Browse files
committed
docs(linter): Add configuration option docs for eslint/no-unneeded-ternary rule.
1 parent b27c5b9 commit 75e01fc

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

crates/oxc_linter/src/rules/eslint/no_unneeded_ternary.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ use oxc_ast::{
66
use oxc_diagnostics::OxcDiagnostic;
77
use oxc_macros::declare_oxc_lint;
88
use oxc_span::{GetSpan, Span};
9+
use schemars::JsonSchema;
910

1011
fn no_unneeded_ternary_diagnostic(span: Span) -> OxcDiagnostic {
1112
OxcDiagnostic::warn("Unnecessary use of boolean literals in conditional expression")
@@ -19,8 +20,14 @@ fn no_unneeded_ternary_conditional_expression_diagnostic(span: Span) -> OxcDiagn
1920
.with_label(span)
2021
}
2122

22-
#[derive(Debug, Clone)]
23+
#[derive(Debug, Clone, JsonSchema)]
24+
#[serde(rename_all = "camelCase", default)]
2325
pub struct NoUnneededTernary {
26+
/// Whether to allow the default assignment pattern `x ? x : y`.
27+
///
28+
/// When set to `false`, the rule also flags cases like `x ? x : y` and suggests using
29+
/// the logical OR form `x || y` instead. When `true` (default), such default assignments
30+
/// are allowed and not reported.
2431
default_assignment: bool,
2532
}
2633

@@ -63,7 +70,8 @@ declare_oxc_lint!(
6370
NoUnneededTernary,
6471
eslint,
6572
suspicious,
66-
fix_dangerous
73+
fix_dangerous,
74+
config = NoUnneededTernary,
6775
);
6876

6977
impl Rule for NoUnneededTernary {

0 commit comments

Comments
 (0)