Repository navigation
test(linter): make chained Tester::expect_fix calls add fix cases - #29308
Open
ashokram-si wants to merge 5 commits into
Open
ashokram-si wants to merge 5 commits into
ashokram-si wants to merge 5 commits into
Conversation
…of replacing them Chained `.expect_fix(...)` calls kept only the last list, so the fix cases of the earlier calls never ran: jest and vitest `prefer-expect-assertions` (five and three lists), `jsx-a11y/interactive-supports-focus` (`fix_tabbable`) and `typescript/consistent-type-definitions` (`fix`). They all pass now that every call's cases run. Fixes oxc-project#29155
AGENTS.md now asks for cases in a crate's existing test harness rather than new standalone unit tests. The rule tests that chain `expect_fix` (jest and vitest prefer-expect-assertions, jsx-a11y interactive-supports-focus, typescript consistent-type-definitions) already cover the change: with it, a wrong case in an earlier list fails the rule's test; without it, that list never runs.
It replaced the stored fix cases with an empty list, so calling it after `expect_fix` dropped them, the same bug `expect_fix` had.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #29155
Tester::expect_fixreplaced the stored fix cases, so a test that chains several.expect_fix(...)calls only ran the last list. Four tests chain it:prefer-expect-assertions(five lists)prefer-expect-assertions(three lists)jsx-a11y/interactive-supports-focus(fix_tabbablenever ran)typescript/consistent-type-definitions(fixnever ran, including the cases fix(linter/typescript/consistent-type-definitions): add a semicolon when code follows on the same line #29634 added)expect_fixnow adds to the cases already given (the issue's first option), so these tests keep their grouping and every list runs. All of them pass. The doc comment says a second call adds.intentionally_allow_no_fix_testshad the same replace-not-add bug (called afterexpect_fix, it dropped the cases), so it now keeps them too.Tests: no new test. The four rule tests above are the regression tests, in the linter's existing harness (AGENTS.md asks for that rather than standalone tests). The earlier version's
mod testsintester.rsis gone. Checked by hand: with a wrong expectation ininteractive-supports-focus's first list (fix_tabbable), the rule's test fails on this branch and passes with main'stester.rs, where that list never runs.At 7cdf892 (current main merged):
cargo test -p oxc_linter --lib: 1339 passed.cargo fmt --checkandcargo clippy -p oxc_linter --all-targets -- -D warningsare clean.No Example or playground link: this changes the linter's test harness (
Tester::expect_fix), not what a rule reports or fixes.AI disclosure: written with Claude Code (model: Claude Opus 5.5,
claude-opus-5-5; the reasoning effort level was not recorded); I reviewed the change and ran the tests.