Skip to content

Commit 3182293

Browse files
fix: workflow for dev (#29)
* ci: lint, prettier and typo check * fix: eslint code changes * format: prettier format code * ci: peer dependency yarn error and rebuild yarn.lock
1 parent aee7d5b commit 3182293

Some content is hidden

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

62 files changed

+3132
-3110
lines changed

.github/workflows/check-code.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: Check Code
2+
3+
on:
4+
pull_request:
5+
6+
jobs:
7+
lint:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: actions/checkout@v4
11+
with:
12+
fetch-depth: 0
13+
persist-credentials: true
14+
15+
- name: Setup Node.js
16+
uses: actions/setup-node@v4
17+
with:
18+
node-version: "20"
19+
20+
- name: Install dependencies
21+
run: yarn install --immutable
22+
23+
- name: Run lint
24+
run: yarn lint
25+
26+
- name: Check formatting
27+
run: yarn format:check
28+
29+
- name: Run typecheck
30+
run: yarn typecheck
31+

.github/workflows/spellings.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
name: Spelling
2+
3+
on:
4+
pull_request:
5+
6+
jobs:
7+
spelling:
8+
name: Spell Check with Typos
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: Checkout Actions Repository
12+
uses: actions/checkout@v3
13+
- name: Spell Check Repo
14+
uses: crate-ci/typos@master
15+
with:
16+
config: typos.toml

eslint.config.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
const typescript = require('@typescript-eslint/eslint-plugin');
2+
const typescriptParser = require('@typescript-eslint/parser');
3+
const react = require('eslint-plugin-react');
4+
5+
module.exports = [
6+
{
7+
files: ['**/*.{js,jsx,ts,tsx}'],
8+
plugins: {
9+
'@typescript-eslint': typescript,
10+
'react': react,
11+
},
12+
languageOptions: {
13+
parser: typescriptParser,
14+
parserOptions: {
15+
ecmaFeatures: { jsx: true },
16+
},
17+
},
18+
rules: {
19+
...typescript.configs['recommended'].rules,
20+
...react.configs['recommended'].rules,
21+
'no-console': ['warn', { allow: ['warn', 'error'] }],
22+
},
23+
settings: {
24+
react: {
25+
version: 'detect',
26+
},
27+
},
28+
},
29+
];

package.json

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,12 @@
3939
"test": "jest",
4040
"prepublishOnly": "npm run build",
4141
"storybook": "storybook dev -p 6006",
42-
"build-storybook": "storybook build"
42+
"build-storybook": "storybook build",
43+
"lint": "eslint \"src/**/*.{ts,tsx,js,jsx}\"",
44+
"typecheck": "tsc --noEmit",
45+
"format:fix": "prettier --write \"src/**/*.{ts,tsx,js,jsx,json,css,md}\"",
46+
"format:check": "prettier --check \"src/**/*.{ts,tsx,js,jsx,json,css,md}\"",
47+
"check-code": "yarn lint && yarn typecheck"
4348
},
4449
"peerDependencies": {
4550
"react": "^17.0.0 || ^18.0.0",
@@ -61,15 +66,22 @@
6166
"@storybook/react": "^8.1.10",
6267
"@storybook/react-webpack5": "^8.1.10",
6368
"@storybook/test": "^8.1.10",
69+
"@testing-library/dom": "^10.4.0",
6470
"@testing-library/jest-dom": "^6.4.6",
6571
"@testing-library/react": "^16.0.0",
72+
"@types/eslint": "^9",
6673
"@types/react": "^18.3.3",
6774
"@types/react-dom": "^18.3.0",
75+
"@typescript-eslint/eslint-plugin": "^8.4.0",
76+
"@typescript-eslint/parser": "^8.4.0",
6877
"autoprefixer": "^10.4.19",
6978
"concurrently": "^8.2.2",
79+
"eslint": "^9.9.1",
80+
"eslint-plugin-react": "^7.35.2",
7081
"jest": "^29.7.0",
7182
"jest-environment-jsdom": "^29.7.0",
7283
"postcss": "^8.4.38",
84+
"prettier": "^3.3.3",
7385
"react": "^17.0.0 || ^18.0.0",
7486
"react-dom": "^17.0.0 || ^18.0.0",
7587
"semantic-release": "^24.0.0",
Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,33 @@
11
// src/components/Button/Button.stories.tsx
22

3-
import React from 'react';
4-
import { StoryFn, Meta } from '@storybook/react';
5-
import { Button, ButtonProps } from './Button';
3+
import React from "react";
4+
import { StoryFn, Meta } from "@storybook/react";
5+
import { Button, ButtonProps } from "./Button";
66

77
export default {
8-
title: 'Components/Button',
8+
title: "Components/Button",
99
component: Button,
1010
argTypes: {
1111
variant: {
12-
control: { type: 'select', options: ['primary', 'secondary'] }
12+
control: { type: "select", options: ["primary", "secondary"] },
1313
},
1414
disabled: {
15-
control: 'boolean'
15+
control: "boolean",
1616
},
17-
onClick: { action: 'clicked' }
17+
onClick: { action: "clicked" },
1818
},
1919
} as Meta;
2020

2121
const Template: StoryFn<ButtonProps> = (args) => <Button {...args} />;
2222

2323
export const Primary = Template.bind({});
2424
Primary.args = {
25-
label: 'Primary Button',
26-
variant: 'primary',
25+
label: "Primary Button",
26+
variant: "primary",
2727
};
2828

2929
export const Disabled = Template.bind({});
3030
Disabled.args = {
31-
label: 'Disabled Button',
31+
label: "Disabled Button",
3232
disabled: true,
33-
};
33+
};

src/components/button/Button.tsx

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,44 @@
11
// src/components/Button/Button.tsx
22

3-
import React from 'react';
4-
import '../../styles/tailwind.output.css';
3+
import React from "react";
4+
import "../../styles/tailwind.output.css";
55

66
export interface ButtonProps {
77
label: string;
88
onClick?: () => void;
9-
variant?: 'primary' | 'secondary';
10-
size?: 'small' | 'medium' | 'large';
9+
variant?: "primary" | "secondary";
10+
size?: "small" | "medium" | "large";
1111
disabled?: boolean;
1212
}
1313

1414
export const Button: React.FC<ButtonProps> = ({
1515
label,
1616
onClick,
17-
variant = 'primary',
18-
size = 'medium',
17+
variant = "primary",
18+
size = "medium",
1919
disabled = false,
2020
}) => {
21-
const baseStyles = 'font-bold py-2 px-4 rounded';
21+
const baseStyles = "font-bold py-2 px-4 rounded";
2222
const variantStyles = {
23-
primary: 'bg-blue-500 hover:bg-blue-700 text-white',
24-
secondary: 'bg-gray-300 hover:bg-gray-400 text-gray-800',
23+
primary: "bg-blue-500 hover:bg-blue-700 text-white",
24+
secondary: "bg-gray-300 hover:bg-gray-400 text-gray-800",
2525
};
2626
const sizeStyles = {
27-
small: 'text-sm',
28-
medium: 'text-base',
29-
large: 'text-lg',
27+
small: "text-sm",
28+
medium: "text-base",
29+
large: "text-lg",
3030
};
3131

3232
const className = `
3333
${baseStyles}
3434
${variantStyles[variant]}
3535
${sizeStyles[size]}
36-
${disabled ? 'opacity-50 cursor-not-allowed' : ''}
36+
${disabled ? "opacity-50 cursor-not-allowed" : ""}
3737
`.trim();
3838

3939
return (
40-
<button
41-
className={className}
42-
onClick={onClick}
43-
disabled={disabled}
44-
>
40+
<button className={className} onClick={onClick} disabled={disabled}>
4541
{label}
4642
</button>
4743
);
48-
};
44+
};

src/components/button/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export * from './Button';
1+
export * from "./Button";

src/components/carousel/Carousel.stories.tsx

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,30 +7,39 @@ import { ArrowLeft, ArrowRight } from "../../icons";
77
export default {
88
title: "Components/Carousel",
99
argTypes: {
10-
colorMode: { control: { type: "radio" }, options: ["light", "dark"], defaultValue: "light" }
11-
}
10+
colorMode: {
11+
control: { type: "radio" },
12+
options: ["light", "dark"],
13+
defaultValue: "light",
14+
},
15+
},
1216
} as Meta;
1317

1418
const PlaceholderCarouselItem = () => {
1519
return (
16-
<div className={`w-[300px] rounded-md p-2 border border-gray-200 shadow-sm`}>
17-
<h2 className="text-2xl font-bold mb-4 text-gray-600">
18-
Lorem ipsum dolor sit amet
19-
</h2>
20-
<p className="text-sm text-gray-800">
21-
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Dignissimos voluptatibus illum quae officia hic, provident aliquam? Quos nemo asperiores, consequuntur molestiae culpa rem ea corporis ratione voluptatibus pariatur tenetur perspiciatis.
22-
</p>
20+
<div
21+
className={`w-[300px] rounded-md p-2 border border-gray-200 shadow-sm`}
22+
>
23+
<h2 className="text-2xl font-bold mb-4 text-gray-600">
24+
Lorem ipsum dolor sit amet
25+
</h2>
26+
<p className="text-sm text-gray-800">
27+
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Dignissimos
28+
voluptatibus illum quae officia hic, provident aliquam? Quos nemo
29+
asperiores, consequuntur molestiae culpa rem ea corporis ratione
30+
voluptatibus pariatur tenetur perspiciatis.
31+
</p>
2332
</div>
24-
)
25-
}
33+
);
34+
};
2635

27-
export const CarouselSample = (args: any) => {
36+
export const CarouselSample = (args: { colorMode: "light" | "dark" }) => {
2837
const { colorMode } = args;
2938
const isDark = colorMode === "dark";
3039

3140
return (
3241
<div className={isDark ? "dark" : ""}>
33-
<Carousel config={{stepWidthInPercent: 40}}>
42+
<Carousel config={{ stepWidthInPercent: 40 }}>
3443
<Carousel.Container>
3544
<Carousel.Item>
3645
<PlaceholderCarouselItem />

0 commit comments

Comments
 (0)