Storybook Configuration
Detailed guide for configuring ESLint for Storybook with JS Style Kit
Overview
JS Style Kit provides ESLint rules specifically for Storybook, making it easier to follow best practices when working with Storybook in your project. The Storybook configuration is disabled by default but can be easily enabled.
Enabling Storybook Support
To enable Storybook support in your ESLint configuration:
What’s Included
When Storybook support is enabled, JS Style Kit:
-
Applies Storybook-specific ESLint rules to files matching these patterns:
**/*.stories.@(ts|tsx|js|jsx|mjs|cjs)
**/*.story.@(ts|tsx|js|jsx|mjs|cjs)
-
Adds rules for Storybook configuration files in:
.storybook/main.@(js|cjs|mjs|ts)
-
Ensures the
.storybook
directory is not ignored by ESLint by adding a negation pattern (!.storybook
) to the ignores configuration.
Storybook Rules
The Storybook configuration includes several rules to help enforce best practices:
storybook/await-interactions
: Warns whenplay
functions don’t properly await interactionsstorybook/context-in-play-function
: Enforces proper context usage in play functionsstorybook/csf-component
: Ensures Component Story Format (CSF) has a component propertystorybook/default-exports
: Validates default exports in story filesstorybook/hierarchy-separator
: Warns about deprecated hierarchy separatorsstorybook/meta-inline-properties
: Encourages proper meta object structurestorybook/no-redundant-story-name
: Prevents story names that duplicate the component namestorybook/prefer-pascal-case
: Encourages PascalCase for story namesstorybook/story-exports
: Ensures proper story exportsstorybook/use-storybook-expect
: Encourages using Storybook’s expect instead of testing library assertionsstorybook/use-storybook-testing-library
: Encourages using Storybook’s test library
For Storybook configuration files, the following rule is applied:
storybook/no-uninstalled-addons
: Warns about addons referenced but not installed
Rule Overrides
When Storybook support is enabled, the following rules are disabled for Storybook files to avoid conflicts:
import/no-anonymous-default-export
: Disabled to allow Storybook’s default export patternreact-hooks/rules-of-hooks
: Disabled to allow using hooks in story files
Example Configuration
A complete example with Storybook and React support: