Oxlintrc can be deserialized from a JSON array (e.g., []), which should be rejected. Configuration files must be JSON objects.
// This unexpectedly succeeds - should fail
let config: Oxlintrc = serde_json::from_value(json!([])).unwrap();
Root Cause
This is due to a known serde_json behavior where arrays can deserialize into structs by treating array elements as positional struct fields. Combined with #[serde(default)] at the struct level, an empty array deserializes successfully with all default values.
See: serde-rs/json#1059
The serde_json maintainer has marked this as "wishlist for 2.0" but it hasn't been fixed yet.
Affected Code
crates/oxc_linter/src/config/oxlintrc.rs
Oxlintrccan be deserialized from a JSON array (e.g.,[]), which should be rejected. Configuration files must be JSON objects.Root Cause
This is due to a known serde_json behavior where arrays can deserialize into structs by treating array elements as positional struct fields. Combined with
#[serde(default)]at the struct level, an empty array deserializes successfully with all default values.See: serde-rs/json#1059
The serde_json maintainer has marked this as "wishlist for 2.0" but it hasn't been fixed yet.
Affected Code
crates/oxc_linter/src/config/oxlintrc.rs