Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Nov 7, 2025. It is now read-only.

🎗Official ESLint plugin for Storybook

License

NotificationsYou must be signed in to change notification settings

storybookjs/eslint-plugin-storybook

Repository files navigation

This package has moved and is now part of theStorybook monorepo since version 9. Please update your dependencies. This repository is no longer maintained. If there are issues or requests, please report them in theStorybook monorepo.

eslint-plugin-storybook

Best practice rules for Storybook

Installation

You'll first need to installESLint:

npm install eslint --save-dev# oryarn add eslint --dev

Next, installeslint-plugin-storybook:

npm install eslint-plugin-storybook --save-dev# oryarn add eslint-plugin-storybook --dev

And finally, add this to your.eslintignore file:

// Inside your .eslintignore file!.storybook

This allows for this plugin to also lint your configuration files inside the .storybook folder, so that you always have a correct configuration and don't face any issues regarding mistyped addon names, for instance.

For more info on why this line is required in the .eslintignore file, check thisESLint documentation.

If you are usingflat config style, add this to your configuration file:

exportdefault[// ...{// Inside your .eslintignore fileignores:['!.storybook'],},]

ESLint compatibility

Use the following table to use the correct version of this package, based on the version of ESLint you're using:

ESLint versionStorybook plugin version
^9.0.0^0.10.0
^8.57.0^0.10.0
^7.0.0~0.9.0

Usage

Configuration (.eslintrc)

Use.eslintrc.* file to configure rules in ESLint < v9. See also:https://eslint.org/docs/latest/use/configure/.

Addplugin:storybook/recommended to the extends section of your.eslintrc configuration file. Note that we can omit theeslint-plugin- prefix:

{// extend plugin:storybook/<configuration>, such as:"extends":["plugin:storybook/recommended"]}

This plugin will only be applied to files following the*.stories.* (we recommend this) or*.story.* pattern. This is an automatic configuration, so you don't have to do anything.

Overriding/disabling rules

Optionally, you can override, add or disable rules settings. You likely don't want these settings to be applied in every file, so make sure that you add aoverrides section in your.eslintrc.* file that applies the overrides only to your stories files.

{"overrides":[{// or whatever matches stories specified in .storybook/main.js"files":['**/*.stories.@(ts|tsx|js|jsx|mjs|cjs)'],"rules":{// example of overriding a rule'storybook/hierarchy-separator':'error',// example of disabling a rule'storybook/default-exports':'off',}}]}

Configuration (eslint.config.[c|m]?js)

Useeslint.config.[c|m]?js file to configure rules using theflat config style. This is the default in ESLint v9, but can be used starting from ESLint v8.57.0. See also:https://eslint.org/docs/latest/use/configure/configuration-files-new.

importstorybookfrom'eslint-plugin-storybook'exportdefault[// add more generic rulesets here, such as:// js.configs.recommended,  ...storybook.configs['flat/recommended'],// something ...]

In case you are using utility functions from tools liketseslint, you might need to set the plugin a little differently:

importstorybookfrom"eslint-plugin-storybook";importsomePluginfrom'some-plugin';importtseslintfrom'typescript-eslint';exportdefaulttseslint.config(somePlugin,storybook.configs["flat/recommended"]// notice that it is not destructured);"

Overriding/disabling rules

Optionally, you can override, add or disable rules settings. You likely don't want these settings to be applied in every file, so make sure that you add a flat config section in youreslint.config.[m|c]?js file that applies the overrides only to your stories files.

importstorybookfrom'eslint-plugin-storybook'exportdefault[// ...  ...storybook.configs['flat/recommended'],{files:['**/*.stories.@(ts|tsx|js|jsx|mjs|cjs)'],rules:{// example of overriding a rule'storybook/hierarchy-separator':'error',// example of disabling a rule'storybook/default-exports':'off',},},// something ...]

MDX Support

This plugin does not support MDX files.

Supported Rules and configurations

Key: 🔧 = fixable

Configurations: csf, csf-strict, addon-interactions, recommended

NameDescription🔧Included in configurations
storybook/await-interactionsInteractions should be awaited🔧
  • addon-interactions
  • flat/addon-interactions
  • recommended
  • flat/recommended
storybook/context-in-play-functionPass a context when invoking play function of another story
  • recommended
  • flat/recommended
  • addon-interactions
  • flat/addon-interactions
storybook/csf-componentThe component property should be set
  • csf
  • flat/csf
  • csf-strict
  • flat/csf-strict
storybook/default-exportsStory files should have a default export🔧
  • csf
  • flat/csf
  • recommended
  • flat/recommended
  • csf-strict
  • flat/csf-strict
storybook/hierarchy-separatorDeprecated hierarchy separator in title property🔧
  • csf
  • flat/csf
  • recommended
  • flat/recommended
  • csf-strict
  • flat/csf-strict
storybook/meta-inline-propertiesMeta should only have inline propertiesN/A
storybook/meta-satisfies-typeMeta should usesatisfies Meta🔧N/A
storybook/no-redundant-story-nameA story should not have a redundant name property🔧
  • csf
  • flat/csf
  • recommended
  • flat/recommended
  • csf-strict
  • flat/csf-strict
storybook/no-stories-ofstoriesOf is deprecated and should not be used
  • csf-strict
  • flat/csf-strict
storybook/no-title-property-in-metaDo not define a title in meta🔧
  • csf-strict
  • flat/csf-strict
storybook/no-uninstalled-addonsThis rule identifies storybook addons that are invalid because they are either not installed or contain a typo in their name.
  • recommended
  • flat/recommended
storybook/prefer-pascal-caseStories should use PascalCase🔧
  • recommended
  • flat/recommended
storybook/story-exportsA story file must contain at least one story export
  • recommended
  • flat/recommended
  • csf
  • flat/csf
  • csf-strict
  • flat/csf-strict
storybook/use-storybook-expectUse expect from@storybook/test,storybook/test or@storybook/jest🔧
  • addon-interactions
  • flat/addon-interactions
  • recommended
  • flat/recommended
storybook/use-storybook-testing-libraryDo not use testing-library directly on stories🔧
  • addon-interactions
  • flat/addon-interactions
  • recommended
  • flat/recommended

Contributors

Looking into improving this plugin? That would be awesome!Please refer tothe contributing guidelines for steps to contributing.

License

MIT

About

🎗Official ESLint plugin for Storybook

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Packages

No packages published

Contributors33

Languages


[8]ページ先頭

©2009-2025 Movatter.jp