Commit 005ec25
## 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] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: camc314 <18101008+camc314@users.noreply.github.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Cameron <cameron.clark@hey.com>
1 parent fd03131 commit 005ec25
File tree
4 files changed
+68
-27
lines changed- crates/oxc_linter/src
- config
- snapshots
- npm/oxlint
- tasks/website_linter/src/snapshots
4 files changed
+68
-27
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
68 | 68 | | |
69 | 69 | | |
70 | 70 | | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
71 | 74 | | |
72 | 75 | | |
73 | 76 | | |
| |||
221 | 224 | | |
222 | 225 | | |
223 | 226 | | |
224 | | - | |
225 | | - | |
226 | | - | |
227 | | - | |
228 | | - | |
229 | | - | |
230 | | - | |
231 | | - | |
232 | | - | |
233 | | - | |
234 | | - | |
235 | | - | |
236 | | - | |
237 | | - | |
238 | | - | |
239 | | - | |
240 | | - | |
241 | 227 | | |
242 | 228 | | |
243 | 229 | | |
| |||
327 | 313 | | |
328 | 314 | | |
329 | 315 | | |
| 316 | + | |
| 317 | + | |
330 | 318 | | |
| 319 | + | |
331 | 320 | | |
332 | 321 | | |
333 | 322 | | |
| |||
481 | 470 | | |
482 | 471 | | |
483 | 472 | | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
484 | 511 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
11 | 19 | | |
12 | 20 | | |
13 | 21 | | |
| |||
136 | 144 | | |
137 | 145 | | |
138 | 146 | | |
139 | | - | |
140 | | - | |
141 | | - | |
142 | | - | |
143 | | - | |
144 | 147 | | |
145 | 148 | | |
146 | 149 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
7 | 15 | | |
8 | 16 | | |
9 | 17 | | |
| |||
132 | 140 | | |
133 | 141 | | |
134 | 142 | | |
135 | | - | |
136 | | - | |
137 | | - | |
138 | | - | |
139 | | - | |
140 | 143 | | |
141 | 144 | | |
142 | 145 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
62 | 62 | | |
63 | 63 | | |
64 | 64 | | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
65 | 73 | | |
66 | 74 | | |
67 | 75 | | |
| |||
0 commit comments