0.8.0 • Published 3 months ago

eslint-plugin-storybook v0.8.0

Weekly downloads
18
License
MIT
Repository
github
Last release
3 months ago

eslint-plugin-storybook

Best practice rules for Storybook

Installation

You'll first need to install ESLint:

npm install eslint --save-dev
# or
yarn add eslint --dev

Next, install eslint-plugin-storybook:

npm install eslint-plugin-storybook --save-dev
# or
yarn 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 this ESLint documentation.

Usage

Use .eslintrc.* file to configure rules. See also: https://eslint.org/docs/user-guide/configuring

Add plugin:storybook/recommended to the extends section of your .eslintrc configuration file. Note that we can omit the eslint-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 a overrides 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',
      }
    }
  ]
}

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-interactionsrecommended
storybook/context-in-play-functionPass a context when invoking play function of another storyrecommendedaddon-interactions
storybook/csf-componentThe component property should be setcsf
storybook/default-exportsStory files should have a default export🔧csfrecommended
storybook/hierarchy-separatorDeprecated hierarchy separator in title property🔧csfrecommended
storybook/no-redundant-story-nameA story should not have a redundant name property🔧csfrecommended
storybook/no-stories-ofstoriesOf is deprecated and should not be usedcsf-strict
storybook/no-title-property-in-metaDo not define a title in meta🔧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
storybook/prefer-pascal-caseStories should use PascalCase🔧recommended
storybook/story-exportsA story file must contain at least one story exportrecommendedcsf
storybook/use-storybook-expectUse expect from @storybook/jest🔧addon-interactionsrecommended
storybook/use-storybook-testing-libraryDo not use testing-library directly on stories🔧addon-interactionsrecommended

Contributors

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

License

MIT

@azul-tecnologia/eslint-config@unimed/z-components@infinitebrahmanuniverse/nolb-eslint-plugin-s@jarisinc/eslint-config-jaris@etchteam/eslinteslint-config-sandboxdse-labeldse-label-component@everything-registry/sub-chunk-1614@ventsislavnikolov/eslint-configgo-component-libraryhyperverge-intern-ui-library-2@acmuta-research/eslint-configeslint-config-lineeslint-config-enpitecheslint-config-epsvueeslint-config-eschadeslint-config-everywhereeslint-config-mysampletesteslint-config-nalgoo-typescripteslint-config-neoncitylightseslint-config-pcpeslint-config-pixiebrixeslint-config-niedzielnyanioleslint-config-nirtamir2eslint-config-galexeslint-config-nseslint-config-omletteeslint-config-onbrandeslint-config-onbrand-doelfkeeslint-config-moneyforwardeslint-config-harmonyeslint-config-hardcoreeslint-config-hazem-alabiadeslint-config-goodwayeslint-config-kworkeslint-config-lukemoraleseslint-config-cmdn-reacteslint-config-chirpyeslint-config-baseseslint-config-beslogiceslint-config-besteslint-config-brandingbrandeslint-config-codefixlabseslint-config-cs3marketingeslint-config-cortexeslint-config-current-thingeslint-config-cremaeslint-config-charlie-tangoeslint-config-carboneslint-config-easyrenteslint-config-7sne-eslinteslint-config-rocketeslint-config-symmetryseslint-config-tidaleslint-config-shinyeslint-config-sheriffeslint-config-refracteslint-config-waystoneeslint-plugin-cremaeslint-plugin-dwceslint-preset-waystoneeslint-plugin-smiledse-example-packageeslint-config-skylighteslint-config-steeleslint-config-websolutepackage-implementpixi-svelte@robinblomberg/eslint-config-robinblombergquibusdamquaesapientenobisrichie-educationanci-reactshainasvelte-component-lib@pega/configs@mstuercke/eslint-config@mullerstd/eslint-config@priver/eslint-config@niedzielnyaniol/eslint-config-niedzielnyaniol@poleski/eslint-config-custom@new-black/eva-frontend-config@nexusmods/eslint-config-nexusmods@nexusmods/eslint-plugin-nexusmods@pikas-ui/config@newhighsco/eslint-config@newlevelup/eslint-config@ptb/eslint-config@elliemae/pui-cli@energise/style-guide@fuf-stack/eslint-config-fuf@fullstacksjs/eslint-config@ruminat/eslint-config@runespoorstack/eslint-config@sabinmarcu/eslint-config@rainstormy/preset-eslint-storybook@rainstormy/presets-eslint-storybook@rambler-tech/eslint-config@nozomiishii/eslint-config
0.7.0

3 months ago

0.8.0

3 months ago

0.6.14

7 months ago

0.6.15

7 months ago

0.6.13

10 months ago

0.6.12

1 year ago

0.6.11

1 year ago

0.6.9

1 year ago

0.6.10

1 year ago

0.6.7

2 years ago

0.6.6

2 years ago

0.6.8

1 year ago

0.6.5

2 years ago

0.5.12

2 years ago

0.5.13

2 years ago

0.6.3

2 years ago

0.6.2

2 years ago

0.6.4

2 years ago

0.6.1

2 years ago

0.6.0

2 years ago

0.5.10

2 years ago

0.5.11

2 years ago

0.5.8

2 years ago

0.5.9

2 years ago

0.5.7

2 years ago

0.5.4

2 years ago

0.5.3

2 years ago

0.5.6

2 years ago

0.5.5

2 years ago

0.5.2

2 years ago

0.5.1

2 years ago

0.0.1-alpha.8

2 years ago

0.0.1-alpha.9

2 years ago

0.0.1-alpha.6

2 years ago

0.0.1-alpha.7

2 years ago

0.0.1-alpha.4

2 years ago

0.0.1-alpha.5

2 years ago

0.0.1-alpha.2

2 years ago

0.0.1-alpha.3

2 years ago

0.0.1-alpha.1

2 years ago

0.3.0

2 years ago

0.2.1

2 years ago

0.2.0

2 years ago

0.3.5

2 years ago

0.5.0

2 years ago

0.4.1

2 years ago

0.3.2

2 years ago

0.2.3

2 years ago

0.4.0

2 years ago

0.3.1

2 years ago

0.2.2

2 years ago

0.3.4

2 years ago

0.2.5

2 years ago

0.4.2

2 years ago

0.3.3

2 years ago

0.2.4

2 years ago

0.0.1-alpha.0

2 years ago

0.1.1

3 years ago

0.1.0

4 years ago