eslint-plugin-executable-stories-vitest
v2.0.0
Published
ESLint rules for executable-stories-vitest: step context, doc.story in test/it, require task for doc.story(title)
Maintainers
Readme
eslint-plugin-executable-stories-vitest
ESLint rules for executable-stories-vitest. Use with Vitest to catch common mistakes: steps outside story context, doc.story(title) outside a test callback, or doc.story("Title") without the required task argument.
Install
pnpm add -D eslint-plugin-executable-stories-vitestRequires ESLint 9+ (flat config).
Usage (flat config)
import vitestExecutableStories from 'eslint-plugin-executable-stories-vitest';
export default [
{
plugins: {
'executable-stories-vitest': vitestExecutableStories,
},
rules: {
...vitestExecutableStories.configs.recommended[0].rules,
},
},
];Or spread the recommended config:
import vitestExecutableStories from 'eslint-plugin-executable-stories-vitest';
export default [...vitestExecutableStories.configs.recommended];Rules
| Rule | Description | Config |
| ------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------- | ----------- |
| require-story-context-for-steps | Step functions (given, when, then, etc.) must be called inside a story() or doc.story() callback. | recommended |
| require-test-context-for-doc-story | doc.story(title) must be called inside a test/it callback when using the native pattern (without a story callback). | recommended |
| require-task-for-doc-story | In Vitest, doc.story(title, task) requires the task argument. Use it('...', ({ task }) => { doc.story('Title', task); ... }). | recommended |
Configs
| Config | Description |
| ------------- | ----------------------- |
| recommended | Enables all three rules |
License
MIT
