You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
## Fix: Allow `$schema` in .oxlintrc.json while maintaining
deny_unknown_fields
### Problem
- The `Oxlintrc` struct has `#[serde(deny_unknown_fields)]` which
rejects all unknown fields
- Users commonly use `$schema` in their `.oxlintrc.json` files for IDE
support (as shown in documentation examples)
- This causes deserialization to fail
### Solution
Added a `schema` field to the `Oxlintrc` struct that:
- Is properly named `$schema` via `#[serde(rename = "$schema")]`
- Is optional (`Option<String>`) and skips serialization when `None`
- Maintains `deny_unknown_fields` for other unknown properties
- Follows the same merge behavior as other optional fields (self takes
priority)
### Changes
1. **Added `schema` field to `Oxlintrc` struct** with appropriate serde
attributes
2. **Removed manual `$schema` injection** from `generate_schema_json()`
- now auto-generated
3. **Updated `merge()` function** to handle the new field correctly
4. **Added comprehensive tests** for deserialization, serialization, and
merge behavior
5. **Updated schema JSON** - `$schema` now appears first and has correct
type `["string", "null"]`
6. **Fixed CI failures**:
- Resolved clippy warning about unnecessary raw string hashes
- Updated website_linter snapshot to include `$schema` field
### Testing
✅ Config files with `$schema` are now accepted
✅ Config files without `$schema` still work
✅ Unknown fields are still properly rejected
✅ Merge behavior gives priority to self over other
✅ All existing tests pass (878 tests)
✅ Schema generation produces correct output
✅ Clippy checks pass
✅ Website linter tests pass
<!-- START COPILOT ORIGINAL PROMPT -->
<details>
<summary>Original prompt</summary>
>
> ----
>
> *This section details on the original issue you should resolve*
>
> <issue_title>linter: `$schema` in .oxlintrc.json causes failure to
deserailize</issue_title>
> <issue_description>cc @connorshea
>
>
https://github.com/oxc-project/oxc-ecosystem-ci/actions/runs/20336440475/job/58424680576</issue_description>
>
> <agent_instructions>This broke in
d446c43, we should keep deny unknonw
fields, but allow $schema</agent_instructions>
>
> ## Comments on the Issue (you are @copilot in this section)
>
> <comments>
> </comments>
>
</details>
<!-- START COPILOT CODING AGENT SUFFIX -->
- Fixes#17059
<!-- START COPILOT CODING AGENT TIPS -->
---
💬 We'd love your input! Share your thoughts on Copilot coding agent in
our [2 minute survey](https://gh.io/copilot-coding-agent-survey).
---------
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: camc314 <[email protected]>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Cameron <[email protected]>
0 commit comments