Skip to content

feat(linter): implement eslint-plugin-vitest/prefer-called-exactly-once-with#17562

Open
Afsoon wants to merge 21 commits intooxc-project:mainfrom
Afsoon:prefer-called-exactly-once-with
Open

feat(linter): implement eslint-plugin-vitest/prefer-called-exactly-once-with#17562
Afsoon wants to merge 21 commits intooxc-project:mainfrom
Afsoon:prefer-called-exactly-once-with

Conversation

@Afsoon
Copy link
Contributor

@Afsoon Afsoon commented Jan 1, 2026

Related to #4656

Summary

The PR implement prefer-called-exactly-once-with which is a missing recommended vitest rules. The decisions that I took are:

  • Instead of do as Eslint, multiple iterations over arrays, I'm doing everything in a single pass.
  • 2 diagnostics per target detected that pass our requirements:
    - 1 diagnostic for the substitution
    - 1 diagnostic for the deletion of the second expect.
  • The fix is set as dangerous, because one fix means delete the second statement.

Questions

  • Should do we add a should_run to run this rule only on test files or not? Only if it's possible.

@Afsoon Afsoon requested a review from camc314 as a code owner January 1, 2026 16:17
@github-actions github-actions bot added A-linter Area - Linter C-enhancement Category - New feature or request labels Jan 1, 2026
@codspeed-hq
Copy link

codspeed-hq bot commented Jan 1, 2026

Merging this PR will not alter performance

✅ 47 untouched benchmarks
⏩ 3 skipped benchmarks1


Comparing Afsoon:prefer-called-exactly-once-with (03b5c85) with main (6db0811)

Open in CodSpeed

Footnotes

  1. 3 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@camc314 camc314 changed the title feat(linter/eslint-plugin-vitest): Implement prefer-called-exactly-once-with feat(linter/eslint-plugin-vitest): implement prefer-called-exactly-once-with Jan 1, 2026
@camc314 camc314 self-assigned this Jan 2, 2026
@Afsoon Afsoon force-pushed the prefer-called-exactly-once-with branch from a381eae to d392f84 Compare January 6, 2026 12:53
@Afsoon
Copy link
Contributor Author

Afsoon commented Jan 6, 2026

Conflicts resolved

@Afsoon Afsoon force-pushed the prefer-called-exactly-once-with branch 3 times, most recently from bdcf7a7 to f609d86 Compare January 13, 2026 06:35
@Afsoon Afsoon force-pushed the prefer-called-exactly-once-with branch 2 times, most recently from 144c32f to 6d7e89d Compare January 21, 2026 11:39
@Afsoon
Copy link
Contributor Author

Afsoon commented Jan 21, 2026

gentle ping @camc314 rebase the branch to sync with the changes in #18076

@Afsoon Afsoon force-pushed the prefer-called-exactly-once-with branch from 6d7e89d to a4aad15 Compare February 6, 2026 07:31
Afsoon and others added 15 commits February 19, 2026 17:23
…sts. Missing nested block statements of test and related methods
…heck to outer and deleted the duplication of logic
…cs, one stating the replacing value and the other one the deletion. The fixes are isolated per diagnostic. Using the default help text
…ostics and method to extract matcher and identefier name.
@camc314 camc314 force-pushed the prefer-called-exactly-once-with branch from a4aad15 to e12cee6 Compare February 19, 2026 17:23
@camc314 camc314 changed the title feat(linter/eslint-plugin-vitest): implement prefer-called-exactly-once-with feat(linter): implement eslint-plugin-vitest/prefer-called-exactly-once-with Feb 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-linter Area - Linter C-enhancement Category - New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants