eslint-plugin-executable-stories-jest
v2.0.0
Published
ESLint rules for executable-stories-jest: step context, doc.story in test/it
Maintainers
Readme
eslint-plugin-executable-stories-jest
ESLint rules for executable-stories-jest. Use with Jest to catch common mistakes when writing story tests.
Install
pnpm add -D eslint-plugin-executable-stories-jestRequires ESLint 9+ (flat config).
Usage (flat config)
import jestExecutableStories from 'eslint-plugin-executable-stories-jest';
export default [
{
plugins: {
'executable-stories-jest': jestExecutableStories,
},
rules: {
...jestExecutableStories.configs.recommended[0].rules,
},
},
];Or spread the recommended config:
import jestExecutableStories from 'eslint-plugin-executable-stories-jest';
export default [...jestExecutableStories.configs.recommended];Rules
| Rule | Description | Config |
| ------------------------------------ | ----------------------------------------------------------------------------------------------------------- | ----------- |
| require-story-context-for-steps | Ensure given/when/then/and/but (and aliases) are called inside story(...) or doc.story(..., callback) | recommended |
| require-test-context-for-doc-story | Ensure doc.story(title) is called inside a test/it callback (framework-native tests) | recommended |
These rules apply only when the file uses legacy patterns (e.g. top-level steps or doc.story()). If you use describe/it + story.init() + story.given/story.when/story.then, the rules do not run; the current API has no top-level steps and no doc.story(), so no changes are required.
Configs
| Config | Description |
| ------------- | ----------------------- |
| recommended | Enables the rules above |
License
MIT
