eslint-plugin-storybook icon indicating copy to clipboard operation
eslint-plugin-storybook copied to clipboard

Add rule to check exports against `includeStories`

Open aaronadamsCA opened this issue 3 years ago • 0 comments

Is your feature request related to a problem? Please describe. Some of our CSF3 stories export option arrays. These get imported by other stories, for example to loop through options in a composite story:

export const ALIGN: Array<TypographyProps["align"]> = [
  "left",
  "center",
  "right",
  "justify",
];

To ensure this doesn't gum up the Storybook UI, we define includeStories: /[a-z]/ in our default exports, so that our all-caps exports are excluded.

Describe the solution you'd like A new rule should check that all named exports matching includeStories are in fact stories. This way, if we forget to define includeStories, the rule will notice that we're exporting named non-stories and flag them.

Describe alternatives you've considered We could move the exports to other files, but this is exactly the reason includeStories exists. We'd prefer not to move Storybook-only utility constants into non-Storybook files.

aaronadamsCA avatar Feb 25 '22 12:02 aaronadamsCA