From 6e5ffb3c77d3a3a3698fddf92a7af67e85432b66 Mon Sep 17 00:00:00 2001 From: Yangshun Tay Date: Wed, 5 Oct 2022 20:06:04 +0800 Subject: [PATCH] storybook: add lint command and lint files --- apps/storybook/.eslintrc.js | 4 +++ apps/storybook/package.json | 1 + apps/storybook/stories/alert.stories.tsx | 13 +++---- apps/storybook/stories/badge.stories.tsx | 11 +++--- apps/storybook/stories/button.stories.tsx | 34 +++++++++---------- apps/storybook/stories/dialog.stories.tsx | 8 ++--- .../stories/dropdown-menu.stories.tsx | 29 ++++++++-------- apps/storybook/stories/select.stories.tsx | 17 +++++----- apps/storybook/stories/slide-out.stories.tsx | 21 ++++++------ apps/storybook/stories/spinner.stories.tsx | 16 ++++----- apps/storybook/stories/tabs.stories.tsx | 10 +++--- apps/storybook/stories/text-input.stories.tsx | 12 +++---- .../ui/src/DropdownMenu/DropdownMenuItem.tsx | 1 - 13 files changed, 93 insertions(+), 84 deletions(-) diff --git a/apps/storybook/.eslintrc.js b/apps/storybook/.eslintrc.js index 97e05895..07b7f196 100644 --- a/apps/storybook/.eslintrc.js +++ b/apps/storybook/.eslintrc.js @@ -1,4 +1,8 @@ module.exports = { root: true, extends: ['tih'], + parserOptions: { + tsconfigRootDir: __dirname, + project: ['./tsconfig.json'], + }, }; diff --git a/apps/storybook/package.json b/apps/storybook/package.json index f4dffb22..df648014 100644 --- a/apps/storybook/package.json +++ b/apps/storybook/package.json @@ -7,6 +7,7 @@ "build": "build-storybook --docs", "preview-storybook": "serve storybook-static", "clean": "rm -rf .turbo && rm -rf node_modules", + "lint": "eslint stories/**/*.ts* --fix", "tsc": "tsc" }, "dependencies": { diff --git a/apps/storybook/stories/alert.stories.tsx b/apps/storybook/stories/alert.stories.tsx index d59de9bf..6cf0d425 100644 --- a/apps/storybook/stories/alert.stories.tsx +++ b/apps/storybook/stories/alert.stories.tsx @@ -1,6 +1,7 @@ -import { ComponentMeta } from '@storybook/react'; -import { Alert, AlertVariant } from '@tih/ui'; import React from 'react'; +import type { ComponentMeta } from '@storybook/react'; +import type { AlertVariant } from '@tih/ui'; +import { Alert } from '@tih/ui'; const alertVariants: ReadonlyArray = [ 'info', @@ -10,24 +11,24 @@ const alertVariants: ReadonlyArray = [ ]; export default { - title: 'Alert', - component: Alert, argTypes: { title: { control: 'text', }, variant: { - options: alertVariants, control: { type: 'select' }, + options: alertVariants, }, }, + component: Alert, + title: 'Alert', } as ComponentMeta; export const Basic = { args: { + children: 'This is something you should pay your full attention to.', title: 'Please pay attention', variant: 'info', - children: 'This is something you should pay your full attention to.', }, }; diff --git a/apps/storybook/stories/badge.stories.tsx b/apps/storybook/stories/badge.stories.tsx index 45c85639..9141d9e9 100644 --- a/apps/storybook/stories/badge.stories.tsx +++ b/apps/storybook/stories/badge.stories.tsx @@ -1,6 +1,7 @@ -import { ComponentMeta } from '@storybook/react'; -import { Badge, BadgeVariant } from '@tih/ui'; import React from 'react'; +import type { ComponentMeta } from '@storybook/react'; +import type { BadgeVariant } from '@tih/ui'; +import { Badge } from '@tih/ui'; const badgeVariants: ReadonlyArray = [ 'primary', @@ -11,14 +12,14 @@ const badgeVariants: ReadonlyArray = [ ]; export default { - title: 'Badge', - component: Badge, argTypes: { variant: { - options: badgeVariants, control: { type: 'select' }, + options: badgeVariants, }, }, + component: Badge, + title: 'Badge', } as ComponentMeta; export const Basic = { diff --git a/apps/storybook/stories/button.stories.tsx b/apps/storybook/stories/button.stories.tsx index 2aef9296..6aea4ee6 100644 --- a/apps/storybook/stories/button.stories.tsx +++ b/apps/storybook/stories/button.stories.tsx @@ -1,15 +1,15 @@ -import { ComponentMeta } from '@storybook/react'; - -import { - Button, +import React from 'react'; +import { EnvelopeIcon } from '@heroicons/react/24/solid'; +import type { ComponentMeta } from '@storybook/react'; +import type { ButtonAddOnPosition, ButtonDisplay, ButtonSize, ButtonType, - ButtonVariant, + ButtonVariant} from '@tih/ui'; +import { + Button } from '@tih/ui'; -import React from 'react'; -import { EnvelopeIcon } from '@heroicons/react/24/solid'; const buttonTypes: ReadonlyArray = ['button', 'reset', 'submit']; const buttonSizes: ReadonlyArray = ['sm', 'md', 'lg']; @@ -27,16 +27,14 @@ const buttonVariants: ReadonlyArray = [ ]; export default { - title: 'Button', - component: Button, argTypes: { addonPosition: { - options: buttonAddOnPositions, control: { type: 'select' }, + options: buttonAddOnPositions, }, display: { - options: buttonDisplays, control: { type: 'select' }, + options: buttonDisplays, }, isDisabled: { control: 'boolean', @@ -48,18 +46,20 @@ export default { control: 'text', }, size: { - options: buttonSizes, control: { type: 'select' }, + options: buttonSizes, }, type: { - options: buttonTypes, control: { type: 'select' }, + options: buttonTypes, }, variant: { - options: buttonVariants, control: { type: 'select' }, + options: buttonVariants, }, }, + component: Button, + title: 'Button', } as ComponentMeta; export const Basic = { @@ -111,8 +111,8 @@ export function Disabled() {
{buttonVariants.map((variant) => (