Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 20 additions & 2 deletions crates/oxc_linter/src/config/oxlintrc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ use super::{
/// }
/// ```
#[derive(Debug, Default, Clone, Deserialize, Serialize, JsonSchema)]
#[serde(default)]
#[serde(default, deny_unknown_fields)]
#[non_exhaustive]
pub struct Oxlintrc {
/// Enabled built-in plugins for Oxlint.
Expand Down Expand Up @@ -214,8 +214,26 @@ impl Oxlintrc {
.extensions
.insert("allowTrailingCommas".to_string(), serde_json::Value::Bool(true));

// Inject markdownDescription fields for better editor support (e.g., VS Code)
let mut json = serde_json::to_value(&schema).unwrap();

// inject "$schema" at the root for editor support without changing the struct
if let serde_json::Value::Object(map) = &mut json {
let props = map
.entry("properties")
.or_insert_with(|| serde_json::Value::Object(serde_json::Map::new()));
if let serde_json::Value::Object(props) = props {
props.insert(
"$schema".to_string(),
serde_json::json!({
"type": "string",
"description": "Schema URI for editor tooling",
"markdownDescription": "Schema URI for editor tooling"
}),
);
}
}

// Inject markdown descriptions for better editor support
Self::inject_markdown_descriptions(&mut json);

serde_json::to_string_pretty(&json).unwrap()
Expand Down
6 changes: 6 additions & 0 deletions crates/oxc_linter/src/snapshots/schema_json.snap
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,14 @@ expression: json
"$ref": "#/definitions/OxlintSettings"
}
]
},
"$schema": {
"type": "string",
"description": "Schema URI for editor tooling",
"markdownDescription": "Schema URI for editor tooling"
}
},
"additionalProperties": false,
"allowComments": true,
"allowTrailingCommas": true,
"definitions": {
Expand Down
6 changes: 6 additions & 0 deletions npm/oxlint/configuration_schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,14 @@
"$ref": "#/definitions/OxlintSettings"
}
]
},
"$schema": {
"type": "string",
"description": "Schema URI for editor tooling",
"markdownDescription": "Schema URI for editor tooling"
}
},
"additionalProperties": false,
"allowComments": true,
"allowTrailingCommas": true,
"definitions": {
Expand Down
Loading