test(linter): Add more tests for deserializing globals in Oxlintrc.#16858
test(linter): Add more tests for deserializing globals in Oxlintrc.#16858graphite-app[bot] merged 1 commit intomainfrom
Conversation
There was a problem hiding this comment.
The tests generally improve coverage of globals deserialization, but one assertion is incorrect: test_deserialize_legacy_spelling currently expects "off" to be enabled. Also, globals.rs tests directly access globals.0, coupling tests to internal representation; prefer a public accessor (consistent with mod.rs). Finally, the new test_deserialize_globals could better align with the PR intent by asserting is_enabled for an off entry.
Additional notes (1)
- Maintainability |
crates/oxc_linter/src/config/mod.rs:111-136
This new test validates variant mapping but doesn't assert the enabled/disabled behavior for entries like"baz": "off". Given the PR intent (and the existing tests inglobals.rs), it's worth also assertingis_enabledfor at least oneoffentry to ensure behavior and representation stay aligned.
Summary of changes
What changed
✅ Expanded coverage for globals deserialization
- Added assertions in
crates/oxc_linter/src/config/globals.rstests to verify string/boolean inputs map to the correctGlobalValueenum variants (e.g.,"readonly" -> Readonly,true -> Writable,"off" -> Off). - Added a new
test_deserialize_globalsincrates/oxc_linter/src/config/mod.rsto ensureOxlintrcconfig parsing correctly deserializes multipleglobalsvalues (including legacy spellings and booleans) into the expected enum variants.
🔎 Stronger guarantees
- Tests now validate both behavior (
is_enabled) and the underlying stored representation (get(...)/ direct map access).
There was a problem hiding this comment.
Pull request overview
This PR adds comprehensive test coverage for deserializing global variable configurations in Oxlintrc. It verifies that all supported string aliases (readable, writeable, readonly, writable, off) and boolean values (true, false) correctly map to their corresponding GlobalValue enum variants (Readonly, Writable, Off).
- Adds a new comprehensive test
test_deserialize_globalsin the main config module that tests all supported global value formats - Enhances existing tests in
globals.rsto verify the correct enum variant mapping, not just enabled/disabled state
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| crates/oxc_linter/src/config/mod.rs | Adds new comprehensive test for global deserialization covering all aliases and boolean values, plus additional assertion to existing test |
| crates/oxc_linter/src/config/globals.rs | Enhances three existing tests with assertions that verify the correct GlobalValue enum variant is assigned |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
CodSpeed Performance ReportMerging #16858 will not alter performanceComparing Summary
Footnotes
|
Merge activity
|
…16858) Just ensuring they work correctly by checking that they get mapped to the correct enum variants. - `readonly`/`readable`/`false` should map to Readonly - `writable`/`writeable`/`true` should map to Writable - `off` should map to Off
3325dd7 to
08f4014
Compare
Just ensuring they work correctly by checking that they get mapped to the correct enum variants.
readonly/readable/falseshould map to Readonlywritable/writeable/trueshould map to Writableoffshould map to Off