Skip to content

Commit 65f8344

Browse files
committed
Update to use DefaultRuleConfig for configuration parsing
1 parent 28d356a commit 65f8344

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

crates/oxc_linter/src/rules/react/jsx_fragments.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use schemars::JsonSchema;
66
use serde::{Deserialize, Serialize};
77
use serde_json::Value;
88

9-
use crate::{AstNode, context::LintContext, rule::Rule, utils::is_jsx_fragment};
9+
use crate::{AstNode, context::LintContext, rule::{DefaultRuleConfig, Rule}, utils::is_jsx_fragment};
1010

1111
fn jsx_fragments_diagnostic(span: Span, mode: FragmentMode) -> OxcDiagnostic {
1212
let msg = if mode == FragmentMode::Element {
@@ -102,13 +102,9 @@ impl Rule for JsxFragments {
102102
// Generally we should prefer the string-only syntax for compatibility with the original ESLint rule,
103103
// but we originally implemented the rule with only the object syntax, so we support both now.
104104
fn from_configuration(value: Value) -> Self {
105-
// We expect configuration to be an array with a single argument like ["syntax"] or [{"mode":"element"}]
106-
// Take the first element and deserialize that into our helper enum which supports both forms.
107-
value
108-
.get(0)
109-
.cloned()
110-
.and_then(|v| serde_json::from_value::<JsxFragments>(v).ok())
105+
serde_json::from_value::<DefaultRuleConfig<JsxFragments>>(value)
111106
.unwrap_or_default()
107+
.into_inner()
112108
}
113109

114110
fn run<'a>(&self, node: &AstNode<'a>, ctx: &LintContext<'a>) {

0 commit comments

Comments
 (0)