Skip to content

feat(linter/eslint-plugin-vitest): Add require-hook as vitest compatible jest rule#288

Merged
camc314 merged 1 commit intooxc-project:mainfrom
Afsoon:12-15-vitest-comptible-jest-rule-require-hook
Dec 15, 2025
Merged

feat(linter/eslint-plugin-vitest): Add require-hook as vitest compatible jest rule#288
camc314 merged 1 commit intooxc-project:mainfrom
Afsoon:12-15-vitest-comptible-jest-rule-require-hook

Conversation

@Afsoon
Copy link
Contributor

@Afsoon Afsoon commented Dec 15, 2025

No description provided.

@Afsoon Afsoon changed the title feat(linter/eslint-plugin-vitest): Add require-hook as vitest compati… feat(linter/eslint-plugin-vitest): Add require-hook as vitest compatible jest rule Dec 15, 2025
camc314 pushed a commit to oxc-project/oxc that referenced this pull request Dec 15, 2025
…ble jest rule (#16880)

Related to #4656

# Sumarry
Add `require hook` as a vitest compatible rule.

Oxlint-migrate PR:
oxc-project/oxlint-migrate#288

# Changes made
I had to sligthy modify the implementation to be compatible with both
frameworks. The modifications were for 2 specific tests:

```javascripts
("describe.for([])('%s', (value) => {})", None),
(
  "describe('scoped', () => {
      test.scoped({ example: 'value' });
   });",
  None,
 ),
```

Both test cases must pass. The first test case failed because
`describe.for` [only exists in
vitest](https://vitest.dev/api/#describe-for) and this exact part of
`parse_jest_fn.rs` failed in the jest branch.


https://github.com/oxc-project/oxc/blob/eba07e6fd945069e7694e3880b36e4f0f8f78d6d/crates/oxc_linter/src/utils/jest/parse_jest_fn.rs#L109C1-L115C10

Second test failed because `test.scoped` doesn't exist neither
frameworks, `scoped` is a custom property made by a user. Reviewing the
Jest and Vitest eslint code they are only interested in the beginning,
not in the full chain.
@camc314 camc314 self-assigned this Dec 15, 2025
@camc314 camc314 merged commit ce97fd3 into oxc-project:main Dec 15, 2025
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants