From 66af09bc37c1460cded087ce99871e767c3c34b1 Mon Sep 17 00:00:00 2001 From: NgocNhi123 Date: Mon, 1 Jul 2024 13:18:01 +0700 Subject: [PATCH] fix lint --- core/src/date-input/date-input.tsx | 16 +----- docs/src/color/sample/sample.tsx | 4 +- docs/src/color/static/table.tsx | 6 +- docs/src/components/radio-group.stories.tsx | 1 + docs/src/components/select.stories.tsx | 1 + docs/src/components/switcher.stories.tsx | 1 + docs/src/components/tab.stories.tsx | 1 + docs/src/components/table.stories.tsx | 2 + docs/src/components/toast.stories.tsx | 1 + docs/src/utils/arg.ts | 2 + docs/src/utils/page/component.tsx | 62 +++++++++++---------- 11 files changed, 46 insertions(+), 51 deletions(-) diff --git a/core/src/date-input/date-input.tsx b/core/src/date-input/date-input.tsx index 7b409543..9fcaa711 100644 --- a/core/src/date-input/date-input.tsx +++ b/core/src/date-input/date-input.tsx @@ -1,4 +1,4 @@ -import { ReactNode, useState } from "react"; +import { useState } from "react"; import { DayPicker, Matcher } from "react-day-picker"; import "react-day-picker/dist/style.css"; import { Input, InputProps } from "../input/input"; @@ -57,18 +57,6 @@ interface Props { icon?: InputProps["icon"]; } -interface DayPickerOverlayProps { - children: ReactNode; - selectedDay: Date; - month: Date; - input: null; - classNames: { - container: string; // input - overlay: string; - overlayWrapper: string; - }; -} - const getValue = (props: Props): Date | undefined => { console.log("get", props.value); @@ -86,7 +74,7 @@ const getValue = (props: Props): Date | undefined => { const getDisabledDays = (props: Props): Matcher | Matcher[] => { const { minDate: min, maxDate: max } = props; - let days: Matcher[] = []; + const days: Matcher[] = []; if (max) days.push({ after: max }); if (min) days.push({ before: min }); return days; diff --git a/docs/src/color/sample/sample.tsx b/docs/src/color/sample/sample.tsx index 0a9ef3a0..f8415180 100644 --- a/docs/src/color/sample/sample.tsx +++ b/docs/src/color/sample/sample.tsx @@ -1,7 +1,7 @@ import Color from "color"; import { useEffect, useRef, useState } from "react"; import { HiCheckCircle } from "react-icons/hi"; -import { CategoryColor, categoryColors, Icon, Tag } from "../../../../core/src"; +import { CategoryColor, Icon, Tag, categoryColors } from "../../../../core/src"; import s from "./sample.module.css"; export type ColorSampleUsage = "text" | "icon" | "both"; @@ -50,7 +50,7 @@ export const ColorSample = (props: Props): JSX.Element => { if (fore === null) throw Error("foreElm is null"); setContrast(getContrast(props, back, fore)); }, 0); // Wait for all styles are applied - }, [setContrast]); + }, [setContrast, props]); return (
(row: number): JSX.Element => ( - // eslint-disable-next-line react/prop-types ); const Name = (props: Props) => - (row: number): JSX.Element => ( - // eslint-disable-next-line react/prop-types - - ); + (row: number): JSX.Element => ; export const ColorStaticTable = (props: Props): JSX.Element => (
diff --git a/docs/src/components/radio-group.stories.tsx b/docs/src/components/radio-group.stories.tsx index 2df7a255..783bfc36 100644 --- a/docs/src/components/radio-group.stories.tsx +++ b/docs/src/components/radio-group.stories.tsx @@ -8,6 +8,7 @@ import { RadioOptionComponent } from "./radio-group-fake"; const meta: Meta = { title: "Components/Radio Group", component: RadioGroup, + // eslint-disable-next-line @typescript-eslint/no-explicit-any subcomponents: { RadioOption: RadioOptionComponent as any }, argTypes: { row: Utils.arg("boolean"), diff --git a/docs/src/components/select.stories.tsx b/docs/src/components/select.stories.tsx index 96bec8cf..bb1f7237 100644 --- a/docs/src/components/select.stories.tsx +++ b/docs/src/components/select.stories.tsx @@ -8,6 +8,7 @@ import { SelectOptionComponent } from "./select-fake"; const meta: Meta = { title: "Components/Select", component: Select, + // eslint-disable-next-line @typescript-eslint/no-explicit-any subcomponents: { SelectOption: SelectOptionComponent as any }, argTypes: { style: Utils.arg(Select.styles, "Visual"), diff --git a/docs/src/components/switcher.stories.tsx b/docs/src/components/switcher.stories.tsx index 19d2722c..aa1ab0a5 100644 --- a/docs/src/components/switcher.stories.tsx +++ b/docs/src/components/switcher.stories.tsx @@ -8,6 +8,7 @@ import { SwitcherOptionComponent } from "./switcher-fake"; const meta: Meta = { title: "Components/Switcher", component: Switcher, + // eslint-disable-next-line @typescript-eslint/no-explicit-any subcomponents: { SwitcherOption: SwitcherOptionComponent as any }, argTypes: { style: Utils.arg(Switcher.styles), diff --git a/docs/src/components/tab.stories.tsx b/docs/src/components/tab.stories.tsx index 16d81ad7..6aeb1dc3 100644 --- a/docs/src/components/tab.stories.tsx +++ b/docs/src/components/tab.stories.tsx @@ -8,6 +8,7 @@ import { TabComponent } from "./tab-fake"; const meta: Meta = { title: "Components/Tabs", component: Tabs, + // eslint-disable-next-line @typescript-eslint/no-explicit-any subcomponents: { Tab: TabComponent as any }, argTypes: { noPadding: Utils.arg("boolean", "Visual"), diff --git a/docs/src/components/table.stories.tsx b/docs/src/components/table.stories.tsx index 9fd42e41..7ffd8d19 100644 --- a/docs/src/components/table.stories.tsx +++ b/docs/src/components/table.stories.tsx @@ -10,7 +10,9 @@ const meta: Meta = { title: "Components/Table", component: Table, subcomponents: { + // eslint-disable-next-line @typescript-eslint/no-explicit-any TableColumn: TableColumnComponent as any, + // eslint-disable-next-line @typescript-eslint/no-explicit-any TableExpandable: TableExpandableComponent as any, }, argTypes: { diff --git a/docs/src/components/toast.stories.tsx b/docs/src/components/toast.stories.tsx index 1d9c698b..7d266467 100644 --- a/docs/src/components/toast.stories.tsx +++ b/docs/src/components/toast.stories.tsx @@ -8,6 +8,7 @@ import { ToastFunction } from "./toast-fake"; const meta: Meta = { title: "Components/Toast", component: ToastPane, + // eslint-disable-next-line @typescript-eslint/no-explicit-any subcomponents: { "toast function": ToastFunction as any }, }; diff --git a/docs/src/utils/arg.ts b/docs/src/utils/arg.ts index dad11493..27a6aaaf 100644 --- a/docs/src/utils/arg.ts +++ b/docs/src/utils/arg.ts @@ -9,6 +9,7 @@ const argOptions = (target: unknown): string[] | undefined => { } if (typeof target === "object") { + // eslint-disable-next-line @typescript-eslint/no-explicit-any return Object.keys(target as any); } }; @@ -36,6 +37,7 @@ export const utilsArg = ( category?: string, ): Partial> => { const table = category ? { category } : undefined; + // eslint-disable-next-line @typescript-eslint/no-explicit-any const control = argControl(target) as any; const options = argOptions(target); return { options, control, table }; diff --git a/docs/src/utils/page/component.tsx b/docs/src/utils/page/component.tsx index 8b3a24e9..3337b02c 100644 --- a/docs/src/utils/page/component.tsx +++ b/docs/src/utils/page/component.tsx @@ -15,37 +15,39 @@ interface Props { primary: "sticky" | "none" | "default"; } -const ComponentPage = (props: Props): JSX.Element => ( -
- - <Description /> - {props.shots.length > 0 && ( - <> - <h3 id="props" className="sbdocs sbdocs-h3"> - Gallery - </h3> - <div className={s.shots}>{props.shots}</div> - </> - )} - <Stories includePrimary={false} /> - <div> - <h3 id="props" className="sbdocs sbdocs-h3"> - All Props - </h3> - {props.primary !== "none" && ( - <div className={[s.primary, background.strong].join(" ")}> - <Primary /> - </div> - )} - <div className={s.table}> - <Controls /> - </div> - </div> - </div> -); - export const utilsPageComponent = (meta: Meta, props: Props): void => { meta.parameters ??= {}; meta.parameters.docs ??= {}; - meta.parameters.docs.page = () => <ComponentPage {...props} />; + meta.parameters.docs.page = () => { + return ( + <div className={props.primary === "sticky" ? s.sticky : ""}> + <Title /> + <Description /> + {props.shots.length > 0 && ( + <> + <h3 id="props" className="sbdocs sbdocs-h3"> + Gallery + </h3> + <div className={s.shots}>{props.shots}</div> + </> + )} + <Stories includePrimary={false} /> + <div> + <h3 id="props" className="sbdocs sbdocs-h3"> + All Props + </h3> + {props.primary !== "none" && ( + <div + className={[s.primary, background.strong].join(" ")} + > + <Primary /> + </div> + )} + <div className={s.table}> + <Controls /> + </div> + </div> + </div> + ); + }; };