Skip to content

Commit 6652456

Browse files
feat(eslint): prevent anonymous default exports + storybook upgrade (#287)
* feat(eslint): prevent anonymous default exports + storybook upgrade * fix(accordion): fix storybook default export * refactor(storybook): upgrade to the latest version Co-authored-by: bethbertozzi <36094225+bethbertozzi@users.noreply.github.com>
1 parent 98e2416 commit 6652456

File tree

69 files changed

+546
-1010
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+546
-1010
lines changed

.eslintrc.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ module.exports = {
6565
],
6666
"@typescript-eslint/no-use-before-define": "off",
6767
"consistent-return": "off",
68+
"import/no-anonymous-default-export": 2,
6869
"import/no-extraneous-dependencies": [
6970
"error",
7071
{

package.json

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,18 @@
2020
"@mui/material": "^5.6.0",
2121
"@rollup/plugin-typescript": "^8.3.1",
2222
"@rollup/plugin-url": "^6.1.0",
23-
"@storybook/addon-a11y": "^6.4.22",
24-
"@storybook/addon-actions": "^6.5.9",
25-
"@storybook/addon-essentials": "^6.5.9",
26-
"@storybook/addon-interactions": "^6.5.9",
27-
"@storybook/addon-links": "^6.5.9",
23+
"@storybook/addon-a11y": "^6.5.13",
24+
"@storybook/addon-actions": "^6.5.13",
25+
"@storybook/addon-essentials": "^6.5.13",
26+
"@storybook/addon-interactions": "^6.5.13",
27+
"@storybook/addon-links": "^6.5.13",
2828
"@storybook/addons": "^6.5.13",
29-
"@storybook/builder-webpack4": "^6.5.9",
30-
"@storybook/manager-webpack4": "^6.5.9",
31-
"@storybook/react": "^6.5.9",
32-
"@storybook/test-runner": "^0.9.0",
29+
"@storybook/builder-webpack4": "^6.5.13",
30+
"@storybook/manager-webpack4": "^6.5.13",
31+
"@storybook/react": "^6.5.13",
32+
"@storybook/test-runner": "^0.9.1",
3333
"@storybook/testing-library": "^0.0.13",
34-
"@storybook/testing-react": "^1.2.4",
34+
"@storybook/testing-react": "^1.3.0",
3535
"@storybook/theming": "^6.5.13",
3636
"@svgr/rollup": "^5.5.0",
3737
"@svgr/webpack": "^5.5.0",
@@ -62,7 +62,7 @@
6262
"eslint-plugin-react": "^7.22.0",
6363
"eslint-plugin-react-hooks": "^4.2.0",
6464
"eslint-plugin-sonarjs": "^0.10.0",
65-
"eslint-plugin-storybook": "^0.5.11",
65+
"eslint-plugin-storybook": "^0.6.7",
6666
"husky": "^5.1.3",
6767
"jest": "^27.2.5",
6868
"lint-staged": "^10.5.4",

src/core/Accordion/index.stories.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Args, Story } from "@storybook/react";
1+
import { Args, Meta, Story } from "@storybook/react";
22
import React from "react";
33
import AccordionDetails from "./components/AccordionDetails";
44
import AccordionHeader from "./components/AccordionHeader";
@@ -38,7 +38,7 @@ export default {
3838
},
3939
component: Accordion,
4040
title: "Accordion",
41-
};
41+
} as Meta;
4242

4343
export const Default = Template.bind({});
4444

src/core/Accordion/index.test.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { generateSnapshots } from "@chanzuckerberg/story-utils";
2+
import { StoryFileExports } from "@chanzuckerberg/story-utils/build/getStories";
23
import { composeStory } from "@storybook/testing-react";
34
import { fireEvent, render, screen } from "@testing-library/react";
45
import React from "react";
@@ -9,7 +10,9 @@ import Meta, { Test as TestStory } from "./index.stories";
910
const Test = composeStory(TestStory, Meta);
1011

1112
describe("<Accordion />", () => {
12-
generateSnapshots(snapshotTestStoryFile);
13+
generateSnapshots<StoryFileExports<typeof Meta>, typeof Meta>(
14+
snapshotTestStoryFile
15+
);
1316

1417
it("renders accordion component", () => {
1518
render(<Test {...Test.args} />);

src/core/Alert/index.stories.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { CheckCircleOutline } from "@mui/icons-material";
22
import { Snackbar } from "@mui/material";
33
import { styled } from "@mui/material/styles";
4-
import { Args, Story } from "@storybook/react";
4+
import { Args, Meta, Story } from "@storybook/react";
55
import React from "react";
66
import Button from "../Button";
77
import { defaultTheme } from "../styles/common/defaultTheme";
@@ -37,7 +37,7 @@ export default {
3737
},
3838
component: Demo,
3939
title: "Alert - To Be Depreciated",
40-
};
40+
} as Meta;
4141

4242
const Template: Story = (args) => <Demo {...args} />;
4343

src/core/Banner/banner.test.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { generateSnapshots } from "@chanzuckerberg/story-utils";
2+
import { StoryFileExports } from "@chanzuckerberg/story-utils/build/getStories";
23
import { composeStory } from "@storybook/testing-react";
34
import { fireEvent, render, screen } from "@testing-library/react";
45
import React from "react";
@@ -9,7 +10,9 @@ import Meta, { Test as TestStory } from "./index.stories";
910
const Test = composeStory(TestStory, Meta);
1011

1112
describe("<Banner />", () => {
12-
generateSnapshots(snapshotTestStoryFile);
13+
generateSnapshots<StoryFileExports<typeof Meta>, typeof Meta>(
14+
snapshotTestStoryFile
15+
);
1316

1417
it("renders banner component", async () => {
1518
render(<Test {...Test.args} />);

src/core/Banner/index.stories.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { styled } from "@mui/material/styles";
2-
import { Args, Story } from "@storybook/react";
2+
import { Args, Meta, Story } from "@storybook/react";
33
import React from "react";
44
import Link from "../Link";
55
import Banner from "./index";
@@ -35,7 +35,7 @@ export default {
3535
},
3636
component: Demo,
3737
title: "Banner",
38-
};
38+
} as Meta<Args>;
3939

4040
const Template: Story = (args) => <Demo {...args} />;
4141

src/core/Button/index.stories.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { action } from "@storybook/addon-actions";
2-
import { Args, Story } from "@storybook/react";
2+
import { Args, Meta, Story } from "@storybook/react";
33
import React from "react";
44
import Icon from "../Icon";
55
import RawButton from "./index";
@@ -41,7 +41,7 @@ export default {
4141
},
4242
component: Button,
4343
title: "Button",
44-
};
44+
} as Meta;
4545

4646
const Template: Story = (props) => <Button {...props} />;
4747

src/core/Button/index.test.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { generateSnapshots } from "@chanzuckerberg/story-utils";
2+
import { StoryFileExports } from "@chanzuckerberg/story-utils/build/getStories";
23
import { composeStory } from "@storybook/testing-react";
34
import { render, screen } from "@testing-library/react";
45
import React from "react";
@@ -8,7 +9,9 @@ import Meta, { Test as TestStory } from "./index.stories";
89
const Test = composeStory(TestStory, Meta);
910

1011
describe("<button />", () => {
11-
generateSnapshots(snapshotTestStoryFile);
12+
generateSnapshots<StoryFileExports<typeof Meta>, typeof Meta>(
13+
snapshotTestStoryFile
14+
);
1215

1316
it("renders Button component", () => {
1417
render(<Test />);

src/core/ButtonDropdown/index.stories.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { action } from "@storybook/addon-actions";
2-
import { Args, Story } from "@storybook/react";
2+
import { Args, Meta, Story } from "@storybook/react";
33
import React from "react";
44
import Icon from "../Icon";
55
import ButtonDropdown from "./index";
@@ -17,7 +17,7 @@ const Demo = (props: Args): JSX.Element => {
1717
export default {
1818
component: Demo,
1919
title: "ButtonDropdown",
20-
};
20+
} as Meta;
2121

2222
const Template: Story = (args) => <Demo {...args} />;
2323

src/core/ButtonIcon/index.stories.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Args, Story } from "@storybook/react";
1+
import { Args, Meta, Story } from "@storybook/react";
22
import React from "react";
33
import Icon from "../Icon";
44
import { defaultAppTheme } from "../styles";
@@ -53,7 +53,7 @@ export default {
5353
},
5454
component: Demo,
5555
title: "ButtonIcon",
56-
};
56+
} as Meta;
5757

5858
const Template: Story = (args) => <Demo {...args} />;
5959

src/core/ButtonIcon/index.test.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { generateSnapshots } from "@chanzuckerberg/story-utils";
2+
import { StoryFileExports } from "@chanzuckerberg/story-utils/build/getStories";
23
import { composeStory } from "@storybook/testing-react";
34
import { render, screen } from "@testing-library/react";
45
import React from "react";
@@ -9,7 +10,9 @@ import Meta, { Test as TestStory } from "./index.stories";
910
const Test = composeStory(TestStory, Meta);
1011

1112
describe("<ButtonIcon />", () => {
12-
generateSnapshots(snapshotTestStoryFile);
13+
generateSnapshots<StoryFileExports<typeof Meta>, typeof Meta>(
14+
snapshotTestStoryFile
15+
);
1316

1417
it("renders ButtonIcon component", () => {
1518
render(<Test />);

src/core/Callout/index.stories.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { FormControlLabel, Switch } from "@mui/material";
22
import { action } from "@storybook/addon-actions";
3-
import { Args, Story } from "@storybook/react";
3+
import { Args, Meta, Story } from "@storybook/react";
44
import React from "react";
55
import Button from "../Button";
66
import CalloutTitle from "./components/CalloutTitle";
@@ -63,7 +63,7 @@ export default {
6363
},
6464
component: Demo,
6565
title: "Callout",
66-
};
66+
} as Meta;
6767

6868
const Template: Story = (args) => <Demo {...args} />;
6969

src/core/CellBasic/index.stories.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* eslint-disable no-use-before-define */
2-
import { Args, Story } from "@storybook/react";
2+
import { Args, Meta, Story } from "@storybook/react";
33
import * as React from "react";
44
import Icon from "../Icon";
55
import CellBasicRaw from "./index";
@@ -92,7 +92,7 @@ export default {
9292
},
9393
component: CellBasic,
9494
title: "Table/CellBasic",
95-
};
95+
} as Meta;
9696

9797
const Template: Story = (args) => <CellBasic {...args} />;
9898

src/core/CellBasic/index.test.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { generateSnapshots } from "@chanzuckerberg/story-utils";
2+
import { StoryFileExports } from "@chanzuckerberg/story-utils/build/getStories";
23
import { composeStory } from "@storybook/testing-react";
34
import { fireEvent, render, screen } from "@testing-library/react";
45
import React from "react";
@@ -9,7 +10,9 @@ import Meta, { Test as TestStory } from "./index.stories";
910
const Test = composeStory(TestStory, Meta);
1011

1112
describe("<CellBasic />", () => {
12-
generateSnapshots(snapshotTestStoryFile);
13+
generateSnapshots<StoryFileExports<typeof Meta>, typeof Meta>(
14+
snapshotTestStoryFile
15+
);
1316

1417
it("renders cell basic component", () => {
1518
render(<Test />);

src/core/CellComponent/index.stories.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { FormControlLabel, RadioGroup } from "@mui/material";
2-
import { Args, Story } from "@storybook/react";
2+
import { Args, Meta, Story } from "@storybook/react";
33
import * as React from "react";
44
import InputRadio from "../InputRadio";
55
import InputToggle from "../InputToggle";
@@ -50,7 +50,7 @@ export default {
5050
},
5151
component: CellComponent,
5252
title: "Table/CellComponent",
53-
};
53+
} as Meta;
5454

5555
const Template: Story = (props: Args) => {
5656
const { horizontalAlign, verticalAlign, fitCellToComponent } = props;

src/core/CellComponent/index.test.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { generateSnapshots } from "@chanzuckerberg/story-utils";
2+
import { StoryFileExports } from "@chanzuckerberg/story-utils/build/getStories";
23
import { composeStory } from "@storybook/testing-react";
34
import { render, screen } from "@testing-library/react";
45
import React from "react";
@@ -9,7 +10,9 @@ import Meta, { Test as TestStory } from "./index.stories";
910
const Test = composeStory(TestStory, Meta);
1011

1112
describe("<CellComponent />", () => {
12-
generateSnapshots(snapshotTestStoryFile);
13+
generateSnapshots<StoryFileExports<typeof Meta>, typeof Meta>(
14+
snapshotTestStoryFile
15+
);
1316

1417
it("renders cellComponent component", () => {
1518
render(<Test />);

src/core/CellHeader/index.stories.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* eslint-disable no-use-before-define */
2-
import { Args, Story } from "@storybook/react";
2+
import { Args, Meta, Story } from "@storybook/react";
33
import * as React from "react";
44
import CellHeaderRaw, { CellHeaderDirection } from "./index";
55

@@ -58,7 +58,7 @@ export default {
5858
},
5959
component: CellHeader,
6060
title: "Table/CellHeader",
61-
};
61+
} as Meta;
6262

6363
const Template: Story = (args) => <CellHeader {...args} />;
6464

src/core/CellHeader/index.test.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { generateSnapshots } from "@chanzuckerberg/story-utils";
2+
import { StoryFileExports } from "@chanzuckerberg/story-utils/build/getStories";
23
import { composeStory } from "@storybook/testing-react";
34
import { fireEvent, render, screen } from "@testing-library/react";
45
import React from "react";
@@ -9,7 +10,9 @@ import Meta, { Test as TestStory } from "./index.stories";
910
const Test = composeStory(TestStory, Meta);
1011

1112
describe("<CellHeader />", () => {
12-
generateSnapshots(snapshotTestStoryFile);
13+
generateSnapshots<StoryFileExports<typeof Meta>, typeof Meta>(
14+
snapshotTestStoryFile
15+
);
1316

1417
it("renders header cell component", () => {
1518
render(<Test />);

src/core/Chip/index.stories.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Args, Story } from "@storybook/react";
1+
import { Args, Meta, Story } from "@storybook/react";
22
import React from "react";
33
import Button from "../Button";
44
import Chip from "./index";
@@ -26,7 +26,7 @@ const Demo = (props: Args): JSX.Element => {
2626
export default {
2727
component: Demo,
2828
title: "Chip - To Be Depreciated",
29-
};
29+
} as Meta;
3030

3131
const Template: Story = (args) => <Demo {...args} />;
3232

src/core/ComplexFilter/index.stories.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Args, Story } from "@storybook/react";
1+
import { Args, Meta, Story } from "@storybook/react";
22
import React from "react";
33
import { noop } from "src/common/utils";
44
import ComplexFilter from "./index";
@@ -55,7 +55,7 @@ export default {
5555
},
5656
component: Demo,
5757
title: "ComplexFilter",
58-
};
58+
} as Meta;
5959

6060
const Template: Story = (args) => <Demo {...args} />;
6161

src/core/ComplexFilter/index.test.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { generateSnapshots } from "@chanzuckerberg/story-utils";
2+
import { StoryFileExports } from "@chanzuckerberg/story-utils/build/getStories";
23
import { composeStory } from "@storybook/testing-react";
34
import { render, screen } from "@testing-library/react";
45
import React from "react";
@@ -8,7 +9,9 @@ import Meta, { Test as TestStory } from "./index.stories";
89
const Test = composeStory(TestStory, Meta);
910

1011
describe("<ComplexFilter />", () => {
11-
generateSnapshots(snapshotTestStoryFile);
12+
generateSnapshots<StoryFileExports<typeof Meta>, typeof Meta>(
13+
snapshotTestStoryFile
14+
);
1215

1316
it("renders ComplexFilter component", () => {
1417
render(<Test {...Test.args} />);

src/core/Dropdown/index.stories.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Dialog, Paper, styled } from "@mui/material";
2-
import { Args, Story } from "@storybook/react";
2+
import { Args, Meta, Story } from "@storybook/react";
33
import React, { useState } from "react";
44
import { noop } from "src/common/utils";
55
import { DefaultDropdownMenuOption } from "../DropdownMenu";
@@ -93,7 +93,7 @@ export default {
9393
},
9494
component: Demo,
9595
title: "Dropdown",
96-
};
96+
} as Meta;
9797

9898
const Template: Story = (args) => <Demo {...args} />;
9999
const LABEL = "Click Target";

0 commit comments

Comments
 (0)