code/lib/eslint-plugin/docs/rules/no-stories-of.md
Included in these configurations: <ul><li>csf-strict</li><li>flat/csf-strict</li></ul>
<!-- RULE-CATEGORIES:END -->Starting with Storybook 5.2, the Component Story Format (CSF) was introduced as the preferred way to write stories. The storiesOf API is now removed and should be avoided in favor of CSF.
Examples of incorrect code for this rule:
import { storiesOf } from "@storybook/react";
import Button from "../components/Button";
storiesOf("Button", module).add("primary", () => <Button primary />);
Examples of correct code for this rule:
import Button from '../components/Button';
export default = {
component: Button
}
export const Primary = () => <Button primary />
import Button from '../components/Button';
export default = {
component: Button
}
export const Primary = {
args: {
primary: true
}
}
For more information about the change from storiesOf to CSF, read here: https://github.com/storybookjs/storybook/blob/master/lib/core/docs/storiesOf.md
To automatically migrate all of your codebase, run this codemod in the root folder of your project:
npx storybook@latest migrate storiesof-to-csf --glob="*/**/*.stories.@(tsx|jsx|ts|js)"