Removal of ignore notation in storybook eslint and transition to actions function (#489)

* fix: desprecated .storybook/main.ts and actions-addons

* remove: ignore notation in storybook eslint and transition to actions function

* remove: unnecessary eslint ignore code
This commit is contained in:
kame
2023-11-05 00:53:26 +09:00
committed by GitHub
parent de1915e1c2
commit 4c84b795a0
8 changed files with 32 additions and 38 deletions

View File

@@ -1,10 +1,10 @@
// .storybook/main.ts // .storybook/main.ts
import type { StorybookViteConfig } from "@storybook/builder-vite"; import type { StorybookConfig } from "@storybook/react-vite";
import path from "path"; const config: StorybookConfig = {
const config: StorybookViteConfig = {
stories: ["../src/**/*.stories.mdx", "../src/**/*.stories.@(js|jsx|ts|tsx)"], stories: ["../src/**/*.stories.mdx", "../src/**/*.stories.@(js|jsx|ts|tsx)"],
addons: [ addons: [
"@storybook/addon-actions",
"@storybook/addon-links", "@storybook/addon-links",
"@storybook/addon-essentials", "@storybook/addon-essentials",
"@storybook/addon-styling", "@storybook/addon-styling",

View File

@@ -1,5 +1,4 @@
/* eslint-disable no-console */ import { Meta, StoryObj } from "@storybook/react";
import { Meta } from "@storybook/react";
import Button from "./Button"; import Button from "./Button";
const meta = { const meta = {
@@ -13,7 +12,7 @@ const meta = {
export default meta; export default meta;
export const Default = { export const Default: StoryObj<typeof Button> = {
args: { args: {
children: ( children: (
<> <>
@@ -21,8 +20,8 @@ export const Default = {
<span>Update</span> <span>Update</span>
</> </>
), ),
onClick: () => { },
console.log("click"); argTypes: {
}, onClick: { action: "clicked" },
}, },
}; };

View File

@@ -1,5 +1,4 @@
/* eslint-disable no-console */ import { Meta, StoryObj } from "@storybook/react";
import { StoryFn, Meta } from "@storybook/react";
import ClustersList from "./ClustersList"; import ClustersList from "./ClustersList";
const meta = { const meta = {
@@ -14,17 +13,14 @@ const meta = {
export default meta; export default meta;
//👇 We create a “template” of how args map to rendering //👇 We create a “template” of how args map to rendering
const Template: StoryFn<typeof ClustersList> = () => ( export const Default: StoryObj<typeof ClustersList> = {
<ClustersList args: {
filteredNamespaces={[""]} filteredNamespaces: [""],
installedReleases={[]} installedReleases: [],
onClusterChange={() => { selectedCluster: "",
console.log("onClusterChange called"); },
}}
selectedCluster={""}
/>
);
export const Default = { argTypes: {
render: Template, onClusterChange: { actions: "onClusterChange called" },
},
}; };

View File

@@ -1,4 +1,3 @@
/* eslint-disable no-console */
/** /**
* @file SelectMenu.stories.tsx * @file SelectMenu.stories.tsx
* @description This file contains the SelectMenu * @description This file contains the SelectMenu
@@ -7,7 +6,8 @@
* The default story renders the component with the default props. * The default story renders the component with the default props.
*/ */
import { Meta } from "@storybook/react"; import { Meta, StoryObj } from "@storybook/react";
import { action } from "@storybook/addon-actions";
import SelectMenu, { SelectMenuItem } from "./SelectMenu"; import SelectMenu, { SelectMenuItem } from "./SelectMenu";
const meta = { const meta = {
@@ -21,7 +21,7 @@ const meta = {
export default meta; export default meta;
export const Default = { export const Default: StoryObj<typeof SelectMenu> = {
args: { args: {
header: "Header", header: "Header",
children: [ children: [
@@ -30,6 +30,6 @@ export const Default = {
<SelectMenuItem label="Item 3" id={3} key="item3" />, <SelectMenuItem label="Item 3" id={3} key="item3" />,
], ],
selected: 1, selected: 1,
onSelect: (id: number) => console.log(id), onSelect: (id: number) => action("onSelect")(id),
}, },
}; };

View File

@@ -1,4 +1,5 @@
import { Meta } from "@storybook/react"; import { Meta } from "@storybook/react";
import { action } from "@storybook/addon-actions";
import DropDown from "./DropDown"; import DropDown from "./DropDown";
import { BsSlack, BsGithub } from "react-icons/bs"; import { BsSlack, BsGithub } from "react-icons/bs";
@@ -14,8 +15,7 @@ const meta = {
export default meta; export default meta;
const onClick = () => { const onClick = () => {
// eslint-disable-next-line no-console action("onClick")("drop down clicked");
console.log("drop down clicked");
}; };
export const Default = { export const Default = {

View File

@@ -1,4 +1,4 @@
/* eslint-disable no-console */ import { action } from "@storybook/addon-actions";
import { Meta } from "@storybook/react"; import { Meta } from "@storybook/react";
import ErrorModal from "./ErrorModal"; import ErrorModal from "./ErrorModal";
@@ -16,7 +16,7 @@ export default meta;
export const Default = { export const Default = {
args: { args: {
onClose: () => { onClose: () => {
console.log("on Close clicked"); action("onClose")("on Close clicked");
}, },
titleText: "Failed to get list of charts", titleText: "Failed to get list of charts",
contentText: contentText:

View File

@@ -1,4 +1,4 @@
/* eslint-disable no-console */ import { action } from "@storybook/addon-actions";
import { StoryObj, StoryFn, Meta } from "@storybook/react"; import { StoryObj, StoryFn, Meta } from "@storybook/react";
import Modal, { ModalAction, ModalButtonStyle } from "./Modal"; import Modal, { ModalAction, ModalButtonStyle } from "./Modal";
@@ -23,14 +23,14 @@ const confirmModalActions: ModalAction[] = [
id: "1", id: "1",
text: "Cancel", text: "Cancel",
callback: () => { callback: () => {
console.log("confirmModal: clicked Cancel"); action("cancelCallback")("confirmModal: clicked Cancel");
}, },
}, },
{ {
id: "2", id: "2",
text: "Confirm", text: "Confirm",
callback: () => { callback: () => {
console.log("confirmModal: clicked Confirm"); action("confirmCallback")("confirmModal: clicked Confirm");
}, },
variant: ModalButtonStyle.info, variant: ModalButtonStyle.info,
}, },
@@ -53,14 +53,14 @@ const customModalActions: ModalAction[] = [
className: className:
"text-white bg-green-700 hover:bg-green-800 focus:ring-4 focus:outline-none focus:ring-green-300 font-medium rounded-lg text-sm px-5 py-2.5 text-center dark:bg-green-600 dark:hover:bg-green-700 dark:focus:ring-green-800", "text-white bg-green-700 hover:bg-green-800 focus:ring-4 focus:outline-none focus:ring-green-300 font-medium rounded-lg text-sm px-5 py-2.5 text-center dark:bg-green-600 dark:hover:bg-green-700 dark:focus:ring-green-800",
callback: () => { callback: () => {
console.log("confirmModal: clicked custom button 1"); action("clickCustomButton")("confirmModal: clicked custom button 1");
}, },
}, },
{ {
id: "2", id: "2",
text: "custom button 2", text: "custom button 2",
callback: () => { callback: () => {
console.log("confirmModal: clicked custom button 2"); action("clickCustomButton")("confirmModal: clicked custom button 2");
}, },
variant: ModalButtonStyle.error, variant: ModalButtonStyle.error,
}, },
@@ -76,7 +76,7 @@ export const CustomModal: StoryObj<typeof Modal> = {
<button <button
className="bg-cyan-500 p-2" className="bg-cyan-500 p-2"
type="button" type="button"
onClick={() => console.log("just a button")} onClick={() => action("onClick")("just a button")}
> >
Just a button Just a button
</button> </button>

View File

@@ -150,7 +150,6 @@ const Modal = ({
</div> </div>
)} )}
</>, </>,
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
document.getElementById("portal")! document.getElementById("portal")!
); );
}; };