chore(linter): Ensure that no unknown fields are allowed in OxlintOverride struct.#16870
chore(linter): Ensure that no unknown fields are allowed in OxlintOverride struct.#16870graphite-app[bot] merged 1 commit intomainfrom
Conversation
There was a problem hiding this comment.
OxlintOverride now rejects unknown fields at both deserialization and schema-validation time, which is good for catching typos but can be behavior-breaking for any configs relying on ignored extra keys. The main risk is user experience: ensure there’s a regression test verifying the failure mode and that the surfaced error is actionable (field name + override index/path). Consider adding a brief schema/doc note clarifying that unknown keys are not permitted in overrides.
Additional notes (1)
- Readability |
npm/oxlint/configuration_schema.json:505-510
WithadditionalProperties: falseadded, schema consumers will now hard-fail on unknown keys. That’s desirable, but it often triggers churn if the schema is used by editors/validators that might add metadata (or if oxlint plans to add new override keys in the future). Consider whether you want to explicitly document this stricter behavior in the schema’s top-levelmarkdownDescription(or relevant docs) so users know unknown keys are rejected rather than ignored.
Summary of changes
What changed
- Disallowed unknown fields in override configs by adding
#[serde(deny_unknown_fields)]toOxlintOverrideincrates/oxc_linter/src/config/overrides.rs. - Updated the generated JSON Schema for
OxlintOverrideto include"additionalProperties": false.- Reflected in both the Rust snapshot
crates/oxc_linter/src/snapshots/schema_json.snapand the published schemanpm/oxlint/configuration_schema.json.
- Reflected in both the Rust snapshot
Result
Override objects now fail validation/deserialization when users provide extra/typoed keys, making configuration errors more visible and explicit.
There was a problem hiding this comment.
Pull request overview
This PR enhances configuration validation by ensuring that the OxlintOverride struct rejects unknown/invalid fields during deserialization. This helps users catch typos or invalid configuration options early by providing clear error messages.
Key Changes
- Added
#[serde(deny_unknown_fields)]attribute to theOxlintOverridestruct in Rust - Added
"additionalProperties": falseto the corresponding JSON schema definition - Updated the schema snapshot to reflect the JSON schema change
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| crates/oxc_linter/src/config/overrides.rs | Added #[serde(deny_unknown_fields)] to enforce strict field validation during deserialization |
| npm/oxlint/configuration_schema.json | Added "additionalProperties": false to the OxlintOverride schema for JSON validation |
| crates/oxc_linter/src/snapshots/schema_json.snap | Updated snapshot to match the JSON schema changes |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
CodSpeed Performance ReportMerging #16870 will not alter performanceComparing Summary
Footnotes
|
Merge activity
|
b2273d7 to
7510414
Compare
Ensure that extra fields are not allowed inside overrides, to make it clear to users when they have added an invalid field.
Pulled out of #16822 since I think it's worth including regardless of that PR.