File tree Expand file tree Collapse file tree 1 file changed +10
-2
lines changed
crates/oxc_linter/src/rules/eslint Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ use oxc_ast::{
66use oxc_diagnostics:: OxcDiagnostic ;
77use oxc_macros:: declare_oxc_lint;
88use oxc_span:: { GetSpan , Span } ;
9+ use schemars:: JsonSchema ;
910
1011fn 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 ) ]
2325pub 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
6977impl Rule for NoUnneededTernary {
You can’t perform that action at this time.
0 commit comments