Skip to content

Commit 2663885

Browse files
committed
feat(playground): Allow specifying a JSON string as the linter config
1 parent 9415920 commit 2663885

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

crates/oxc_linter/src/config/oxlintrc.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,9 @@ impl Oxlintrc {
149149
Ok(config)
150150
}
151151

152+
/// # Errors
153+
///
154+
/// * Parse Failure
152155
pub fn from_string(json_string: &str) -> Result<Self, OxcDiagnostic> {
153156
let json = serde_json::from_str::<serde_json::Value>(json_string)
154157
.unwrap_or(serde_json::Value::Null);

napi/playground/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -288,10 +288,10 @@ impl Oxc {
288288
let semantic = Rc::new(semantic_ret.semantic);
289289
let lint_config = if linter_options.config.is_some() {
290290
let oxlintrc =
291-
Oxlintrc::from_string(&linter_options.config.clone().unwrap().to_string())
291+
Oxlintrc::from_string(&linter_options.config.as_ref().unwrap().to_string())
292292
.unwrap_or_default();
293293
let config_builder =
294-
ConfigStoreBuilder::from_oxlintrc(false, oxlintrc.clone()).unwrap_or_default();
294+
ConfigStoreBuilder::from_oxlintrc(false, oxlintrc).unwrap_or_default();
295295
config_builder.build()
296296
} else {
297297
ConfigStoreBuilder::default().build()

0 commit comments

Comments
 (0)