fix: handle expect.any separately from Chai any flag#925
Merged
Conversation
chasset
added a commit
to univ-lehavre/atlas
that referenced
this pull request
Jul 6, 2026
…-expect) (#559) ## Contexte La PR Dependabot #555 (`all-minor-patch`, 23 bumps) échoue au job **Lint** à cause d'un seul bump : `@vitest/eslint-plugin` **1.6.20 → 1.6.21**. La 1.6.21 (« Support Chai-style expect chains ») confond le matcher asymétrique `expect.any(...)` avec le flag Chai `any`. La règle `vitest/valid-expect` le signale alors à tort **« unknown modifier »** sur le motif canonique : ```ts expect(tls.connect).toHaveBeenCalledWith( expect.objectContaining({ ... }), expect.any(Function), ); ``` Constaté sur [packages/net/src/diagnostics.spec.ts](packages/net/src/diagnostics.spec.ts) (3 assertions **correctes**). ## Amont - Bug ouvert : vitest-dev/eslint-plugin-vitest#924 (« `valid-expect` forbids `expect.any(type)` »). - Correctif proposé : vitest-dev/eslint-plugin-vitest#925 — **non mergé, non publié** (1.6.21 reste la dernière version). ## Correctif Override scopé dans `pnpm-workspace.yaml` plafonnant le plugin à `<1.6.21` : ```yaml "@vitest/eslint-plugin@>=1.6.21": "1.6.20" ``` On préfère épingler un outil de lint dev-only régressé plutôt que tordre des tests corrects. **À lever** dès qu'une version corrigée (1.6.22+) sort. Effet sur le lock : purge des `@typescript-eslint/*@8.61.0` orphelines (tirées uniquement par le plugin en 1.6.21). ## Suite Cette PR débloque #555 : une fois mergée, rebaser #555 sur `main` — le bump vitest-plugin y devient inopérant (l'override le ramène à 1.6.20) et le job Lint passera. ## Validation locale - `pnpm lint` : 64/64 packages OK - `pnpm install --frozen-lockfile` : lock cohérent - `prettier --check` : OK
veritem
approved these changes
Jul 6, 2026
|
@veritem could this please be released as a fix straight away? This regression is rather painful. |
|
Confirming this fixes a real-world regression we hit in |
|
please release 1.6.22.. it is such a pain |
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 #924
Summary
This fixes a
valid-expectregression introduced after Chai-style expect chain support in #920.expect.any(...)was accidentally classified as Chai's.anyflag becauseanyis also a Chai chain property. As a result,valid-expectreportedExpect has an unknown modifier.This PR restores the pre-#920 behavior for called
expect.any(...), while keeping uncalled.anyin Chai chains working:A broader parser change to distinguish asymmetric matcher factories from assertion matcher calls can be handled separately if needed.