Repository navigation
ESLint: Recognize storybook/test imports in await-interactions - #35460
valentinpalkovic merged 5 commits into
Conversation
…port The await-interactions rule only recognised userEvent/expect imported from @storybook/testing-library, @storybook/jest and @storybook/test. Storybook v10 exposes these from the bare storybook/test entry point, so play functions importing from there were never linted. Add storybook/test to both import checks and cover it with a test case.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughThe ChangesStorybook test import support
Estimated code review effort: 2 (Simple) | ~10 minutes Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@code/lib/eslint-plugin/src/rules/await-interactions.test.ts`:
- Around line 201-222: Add the expected suggestions arrays to both error entries
in the new storybook/test case within the await-interactions rule tests,
matching the suggestion structure and replacement text used by comparable cases
for toHaveBeenCalled and findByText.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: b605ab8d-d1fd-4946-b910-dda737490ca5
📒 Files selected for processing (2)
code/lib/eslint-plugin/src/rules/await-interactions.test.tscode/lib/eslint-plugin/src/rules/await-interactions.ts
|
This seems pretty straight-forward to me, @valentinpalkovic . Can we merge? |
|
Appreciate you jumping in here, hope valentinpalkovic gets a chance to take another look soon. |
There was a problem hiding this comment.
🤖 I am the Storybook contribution review bot. This message was posted automatically. A human maintainer makes the final decision on this PR.
Review phase: Runtime verification (stage 3 of 3)We are trying a three-stage automated review: architecture, code quality, and runtime verification. This message states which stages ran and which were skipped. Messages are posted automatically, and a human maintainer makes the final decision. Please tell us whether the feedback and evidence are useful.
Thanks for picking up #35456, @TemRevil! This review covers head f45880f. All three stages ran and passed, and none were skipped. There are no blocking findings.
- Architecture: passed.
- Code quality: passed. The type check passes, and the
await-interactionssuite passes 23/23. - Runtime verification: passed. We ran real ESLint 8.57.1 on a story file shaped like the repro in #35456 (
import { expect, userEvent, fn } from "storybook/test"). The base commit reports 0 errors. This head reports both un-awaited calls. Each changed check (userEventandexpectfromstorybook/test) fails on base and passes on head when tested alone. Imports from@storybook/test,@storybook/jestand@storybook/testing-librarybehave the same as before.
The inline comments are optional suggestions plus one note about older behavior. None of them blocks this PR.
One small request: please paste the terminal output from running the rule's tests on your branch, for example yarn vitest run src/rules/await-interactions.test.ts from code/lib/eslint-plugin. We ask every first-time contributor for this, and I've added verification:pending until it's here.
Thanks again for this fix, @TemRevil! After Requested change (blocking):
Both Stages: architecture (stage 1) carries forward, because the merge didn't change this PR's own patch. Code quality (stage 2) asks for the change above. Runtime verification (stage 3) has not run on this head yet; it will run again after the fix. My earlier optional suggestions still apply and don't block. |
|
Hi @TemRevil Thank you for your contribution so far! Would you like to resolve the mentioned |
…ait-interactions rule
|
Fixed in 455b50a. With the rule now recognising |
Package BenchmarksCommit: The following packages have significant changes to their size or dependencies:
|
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 62 | 68 | 🚨 +6 🚨 |
| Self size | 18.93 MB | 21.98 MB | 🚨 +3.04 MB 🚨 |
| Dependency size | 25.95 MB | 27.06 MB | 🚨 +1.11 MB 🚨 |
| Bundle Size Analyzer | Link | Link |
@storybook/svelte-vite
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 12 | 12 | 0 |
| Self size | 56 KB | 56 KB | 🎉 -443 B 🎉 |
| Dependency size | 30.75 MB | 30.73 MB | 🎉 -13 KB 🎉 |
| Bundle Size Analyzer | Link | Link |
@storybook/sveltekit
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 13 | 13 | 0 |
| Self size | 59 KB | 58 KB | 🎉 -1 KB 🎉 |
| Dependency size | 30.80 MB | 30.79 MB | 🎉 -14 KB 🎉 |
| Bundle Size Analyzer | Link | Link |
@storybook/vue3-vite
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 95 | 95 | 0 |
| Self size | 32 KB | 32 KB | 🎉 -34 B 🎉 |
| Dependency size | 18.76 MB | 18.78 MB | 🚨 +21 KB 🚨 |
| Bundle Size Analyzer | Link | Link |
@storybook/web-components-vite
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 14 | 6 | 🎉 -8 🎉 |
| Self size | 19 KB | 19 KB | 🚨 +12 B 🚨 |
| Dependency size | 25.50 MB | 531 KB | 🎉 -24.97 MB 🎉 |
| Bundle Size Analyzer | Link | Link |
@storybook/cli
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 174 | 174 | 0 |
| Self size | 891 KB | 883 KB | 🎉 -7 KB 🎉 |
| Dependency size | 81.25 MB | 83.25 MB | 🚨 +2.00 MB 🚨 |
| Bundle Size Analyzer | Link | Link |
@storybook/codemod
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 167 | 167 | 0 |
| Self size | 42 KB | 44 KB | 🚨 +3 KB 🚨 |
| Dependency size | 79.74 MB | 81.73 MB | 🚨 +1.99 MB 🚨 |
| Bundle Size Analyzer | Link | Link |
create-storybook
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 63 | 69 | 🚨 +6 🚨 |
| Self size | 1.07 MB | 1.07 MB | 🚨 +5 KB 🚨 |
| Dependency size | 44.88 MB | 49.04 MB | 🚨 +4.15 MB 🚨 |
| Bundle Size Analyzer | node | node |
@storybook/svelte
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 4 | 4 | 0 |
| Self size | 264 KB | 253 KB | 🎉 -11 KB 🎉 |
| Dependency size | 4.85 MB | 4.85 MB | 🎉 -10 B 🎉 |
| Bundle Size Analyzer | Link | Link |
@storybook/vue3
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 91 | 91 | 0 |
| Self size | 209 KB | 232 KB | 🚨 +23 KB 🚨 |
| Dependency size | 18.22 MB | 18.22 MB | 🎉 -10 B 🎉 |
| Bundle Size Analyzer | Link | Link |
@storybook/web-components
| Before | After | Difference | |
|---|---|---|---|
| Dependency count | 12 | 4 | 🎉 -8 🎉 |
| Self size | 192 KB | 196 KB | 🚨 +3 KB 🚨 |
| Dependency size | 25.10 MB | 126 KB | 🎉 -24.97 MB 🎉 |
| Bundle Size Analyzer | Link | Link |
Thanks for the quick fix, @TemRevil! The three
Not checked by us: the Chromatic The earlier request for your own test or terminal output still applies, so |
Closes #35456
What I did
eslint-plugin-storybook'sawait-interactionsrule only fired whenuserEvent/expectwere imported from@storybook/testing-library,@storybook/jest, or@storybook/test. Storybook v10 exposes these from the barestorybook/testentry point, so play functions importing fromstorybook/testwere never linted.Added
storybook/testto bothisUserEventFromStorybookImportedandisExpectFromStorybookImported, so v10 imports are treated exactly like@storybook/test, plus aninvalidtest case covering the new import path.Checklist for Contributors
Testing
The changes in this PR are covered in the following automated tests:
Manual testing
userEvent/expectfromstorybook/test(not@storybook/test) and callsuserEvent.click(...)orexpect(...).toHaveBeenCalled()withoutawait.await-interactionsrule against that file (e.g. via the rule's own RuleTester, oreslintconfigured withplugin:storybook/recommendedagainst a.storybookproject using v10'sstorybook/testimport).next(before this fix) the un-awaited call is not flagged. With this change it is flagged the same way an un-awaited@storybook/testimport already is.I verified the rule logic directly with ESLint's
LinterAPI: astorybook/testimport produces the two expectedinteractionShouldBeAwaitederrors,@storybook/teststill produces one, and an unrelatedchaiimport produces none. I couldn't run the eslint-plugin's ownvitestsuite in an isolated container (the monorepo's TS/build tooling doesn't install standalone), so CI's eslint-plugin test job is the authoritative check for the added test case.Documentation
MIGRATION.MD
Checklist for Maintainers
ci:normal,ci:mergedorci:dailyGH label to it to run a specific set of sandboxes.qa:neededorqa:skipbug/maintenance/dependencies/build/cleanup/documentation/feature request/BREAKING CHANGE/otherlabelsSummary by CodeRabbit
awaitusage forexpect,findByText, and related interactions.awaitwhere required.