Skip to content

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

Merged
camc314 merged 22 commits intooxc-project:mainfrom
Afsoon:prefer-called-exactly-once-with
Mar 27, 2026
Merged

feat(linter): implement eslint-plugin-vitest/prefer-called-exactly-once-with#17562
camc314 merged 22 commits intooxc-project:mainfrom
Afsoon:prefer-called-exactly-once-with

Conversation

@Afsoon
Copy link
Copy Markdown
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
Copy Markdown

codspeed-hq bot commented Jan 1, 2026

Merging this PR will not alter performance

✅ 4 untouched benchmarks
⏩ 52 skipped benchmarks1


Comparing Afsoon:prefer-called-exactly-once-with (6628bcc) with main (e80c0bf)

Open in CodSpeed

Footnotes

  1. 52 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
Copy Markdown
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
Copy Markdown
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
@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
Afsoon added 13 commits March 27, 2026 08:45
…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.
@Afsoon Afsoon force-pushed the prefer-called-exactly-once-with branch from 03b5c85 to babcab3 Compare March 27, 2026 07:45
@Afsoon
Copy link
Copy Markdown
Contributor Author

Afsoon commented Mar 27, 2026

gentle ping @camc314, rebased with the last changes in main

Copy link
Copy Markdown
Contributor

@camc314 camc314 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank yuo!

@camc314 camc314 merged commit ca6e5bc into oxc-project:main Mar 27, 2026
25 checks passed
graphite-app bot pushed a commit that referenced this pull request Mar 30, 2026
# Oxlint
### 💥 BREAKING CHANGES

- c0ebbce linter: [**BREAKING**] Report error on unknown builtin rule (#20464) (camc314)

### 🚀 Features

- 04f85e5 linter/no-unused-vars: Add safe-fix option for import fixes (#20839) (Marcell Toth)
- 32a3706 linter/eslint-vitest-plugin: Implements `require-test-timeout` rule (#20806) (Said Atrahouch)
- ae03653 linter: Implement suggestion for `eslint/no-useless-computed-key` rule (#20805) (Mikhail Baev)
- 6624513 linter/prefer-string-starts-ends-with: Move rule from nursery to style (#20797) (camc314)
- 58941f8 linter/prefer-readonly: Move rule from nursery to style (#20796) (camc314)
- 8837ffd linter/prefer-regexp-exec: Move rule from nursery to style (#20795) (camc314)
- 7e88871 linter/prefer-find: Move rule out of nursery (#20794) (camc314)
- ca6e5bc linter/vitest: Implement prefer-called-exactly-once-with (#17562) (Said Atrahouch)
- e80c0bf linter/eslint-plugin-vitest: Implement `require-mock-type-parameters` (#20785) (Said Atrahouch)
- cec8b8f linter/vitest: Implement require-awaited-expect-poll rule (#20702) (Said Atrahouch)
- d8e9d01 linter/eslint-plugin-vitest: Set `prefer-to-have-been-called-times` compatible with jest (#20703) (Said Atrahouch)
- caf8231 linter: Enhance import plugin diagnostics with help messages (#20766) (离谱)
- f44adfa linter: Improve the oxlint config generated by `--init`. (#20632) (connorshea)
- 43f4827 linter: Add help text to jest and promise diagnostics (#20640) (kszongic)
- 16516de linter: Enhance types for `DummyRule` (#20751) (camc314)
- 27374e8 linter: Add hint about node version when ts config fail to import (#20570) (camc314)
- 8e34150 linter/eslint-plugin-vitest: Sync rule with JS implementation (#20679) (Said Atrahouch)

### 🐛 Bug Fixes

- df057d5 linter/no-noninteractive-tabindex: Add missing composite widget … (#20860) (bab)
- bb34073 linter: Mark vitest/valid-title as a compatible jest rules (#20463) (Nicolas Le Cam)
- bd2c76b linter: Handle shadowed locals in no-restricted-globals (#20811) (Ulrich Stark)
- 62e39be linter: Sort nested object keys in fix of `eslint/sort-keys` in one pass (#20838) (Ulrich Stark)
- 3ef37da oxlint/lsp: Error on unknown command (#20841) (Sysix)
- ab1070d oxlint/cli: Skip parsing base config again for nested config search (#20809) (Sysix)
- 2be3728 oxlint/lsp: Skip parsing base config again for nested config search (#20808) (Sysix)
- 6171217 oxlint: Respect `NO_COLOR` env for `format=stylish` (#20804) (Sysix)
- d89ae8f linter/plugins: Patch `WeakMap` to emulate `WeakMap`s keyed by `sourceCode` (#20799) (overlookmotel)
- c610666 linter/no-shadow: Respect env settings when builtinGlobals is enabled (#20429) (vvnikita74)
- 6bb502f linter/no-invalid-void-type: Allow void generic args in heritage clauses (#20780) (camc314)
- 365bb7d linter: Skip typed nested literals in explicit-module-boundary-types (#20776) (camc314)
- 0aa1ff0 linter/plugins: Ensure `after` hook is always called in ESLint compat mode (#20721) (overlookmotel)
- 31145a9 linter/plugins: Fire `after` hook after CFG events in ESLint compat (#20720) (overlookmotel)
- c09a5ab diagnostics: Skip minified fallback for single-line reporters (#20716) (camc314)
- e4dc9a1 linter: Isolate `--init` config writes from parallel tests (#20717) (camc314)
- 7e394ec linter: Clarify empty replacement fixer help text (#20698) (camc314)
- d15a99c linter/jsx-curly-brace-presence: Flag empty string literals (#20690) (camc314)

### 📚 Documentation

- c722495 linter: Update JS Plugins + LS references (#20843) (camc314)
- e1f9748 linter/jsdoc/require-property: Fix typo (#20792) (Benjaming61001)
- be3dcc1 linter: Add note about node version + custom TS plugin (#19381) (camc314)
# Oxfmt
### 🚀 Features

- 6ef440a oxfmt: Support bool for object style options (#20853) (leaysgur)
- 23050fa oxfmt: Support markdown-in-js substitution (#20683) (leaysgur)
- 4087295 oxfmt: Support angular-in-js substitution (#20676) (leaysgur)
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