Skip to content

Latest commit

 

History

History
39 lines (25 loc) · 1.57 KB

default-exports.md

File metadata and controls

39 lines (25 loc) · 1.57 KB

Stories file should have a default export (default-exports)

Included in these configurations:

  • csf
  • flat/csf
  • recommended
  • flat/recommended

Rule Details

In CSF, a story file should contain a default export that describes the component, and named exports that describe the stories. This rule enforces the definition of a default export in story files.

Examples of incorrect code for this rule:

// no default export
export const Primary = {}

Examples of correct code for this rule:

export default {
  title: 'Button',
  args: { primary: true },
  component: Button,
}
export const Primary = {}

When Not To Use It

This rule should only be applied in your .stories.* files. Please ensure you are defining the storybook rules only for story files. You can see more details here.

If you're using Storybook 6.5 and CSF in MDX, you should disable this rule for the stories that use CSF in MDX. You can see how to override the rule here.

Further Reading

More information about defining stories here: https://storybook.js.org/docs/react/writing-stories/introduction#defining-stories