Skip to content

Commit 2957065

Browse files
committed
feeature. Add eslint workflow & fix all workflows
1 parent 7a9cb71 commit 2957065

File tree

10 files changed

+121
-67
lines changed

10 files changed

+121
-67
lines changed
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
2+
name: ESLint + Prettier
3+
4+
on: [pull_request]
5+
6+
jobs:
7+
lint-format:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: actions/checkout@v3
11+
12+
- name: Setup Node.js
13+
uses: actions/setup-node@v3
14+
with:
15+
node-version: '22'
16+
17+
- name: Install dependencies
18+
run: npm install
19+
20+
- name: Run ESLint with reviewdog
21+
id: eslint
22+
uses: reviewdog/action-eslint@v1
23+
continue-on-error: true
24+
with:
25+
github_token: ${{ secrets.FRONT_SECRET }}
26+
reporter: github-pr-review
27+
eslint_flags: './**/*.{js,jsx,ts,tsx}'
28+
fail_level: 'any'
29+
30+
- name: Run Prettier with reviewdog
31+
id: prettier
32+
uses: EPMatt/reviewdog-action-prettier@v1
33+
continue-on-error: true
34+
with:
35+
github_token: ${{ secrets.FRONT_SECRET }}
36+
reporter: github-pr-review
37+
level: warning
38+
prettier_flags: './**/*.{js,jsx,ts,tsx,json,css,scss,md}'
39+
40+
- name: Check overall result
41+
id: overall
42+
if: steps.eslint.outcome == 'failure' || steps.prettier.outcome == 'failure'
43+
run: exit 1

.github/workflows/github-pages.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,6 @@ jobs:
2020
- name: Deploy
2121
uses: peaceiris/actions-gh-pages@v3
2222
with:
23-
github_token: ${{ secrets.COMPONENT_SHOWCASE }}
23+
github_token: ${{ secrets.FRONT_SECRET }}
2424
publish_dir: ./storybook-static
25-
jekyll: true
25+
enable_jekyll: 'true'

.github/workflows/unit-test.yml

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,17 @@ jobs:
1111

1212
runs-on: ubuntu-latest
1313

14-
strategy:
15-
matrix:
16-
node-version:
17-
- 18.x
18-
1914
steps:
2015
- name: Checkout
2116
uses: actions/checkout@v3
22-
- name: Use Node.js ${{ matrix.node-version }}
17+
18+
- name: Setup Node.js
2319
uses: actions/setup-node@v3
2420
with:
25-
node-version: ${{ matrix.node-version }}
21+
node-version: '22'
22+
2623
- name: Install Dependencies
2724
run: npm install
25+
2826
- name: Execute all unit tests
2927
run: npx jest
Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
import {mergeConfig} from 'vite';
21
import path from 'path';
2+
import {mergeConfig} from 'vite';
33

4-
const resolve = (dir) => path.join(__dirname, '.', dir);
5-
6-
module.exports = {
4+
const config = {
75
stories: ['../stories/components/**/*.stories.tsx'],
86
framework: {
97
name: '@storybook/react-vite',
@@ -16,7 +14,7 @@ module.exports = {
1614
resolve: {
1715
alias: {
1816
'@': path.resolve('src'),
19-
'src': path.resolve('src'),
17+
src: path.resolve('src'),
2018
'~': path.resolve('src/components'),
2119
'~style': path.resolve('src/styles'),
2220
},
@@ -25,16 +23,15 @@ module.exports = {
2523
preprocessorOptions: {
2624
scss: {
2725
api: 'modern',
28-
includePaths: [
29-
path.resolve(__dirname, '../node_modules'),
30-
path.resolve(__dirname, '../')
31-
]
32-
}
33-
}
34-
}
26+
includePaths: [path.resolve(__dirname, '../node_modules'), path.resolve(__dirname, '../')],
27+
},
28+
},
29+
},
3530
});
3631
},
3732
docs: {
3833
autodocs: false,
3934
},
4035
};
36+
37+
export default config;

.storybook/preview.ts renamed to .storybook/preview.mts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1+
import type {Preview} from '@storybook/react';
2+
13
import '../src/styles/Entry.scss';
24
import './preview.scss';
35

4-
import {Preview} from '@storybook/react';
5-
6-
76
const preview: Preview = {
87
parameters: {
98
layout: 'fullscreen',

jest.config.js renamed to jest.config.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@ export default {
66
'^~/(.*)$': '<rootDir>/src/components/$1',
77
'\\.(css|less|scss)$': '<rootDir>/tests/styleMock.js',
88
},
9-
setupFiles: ['<rootDir>/jest.setup.js'],
9+
setupFiles: ['<rootDir>/jest.setup.mjs'],
1010
setupFilesAfterEnv: ['@testing-library/jest-dom/extend-expect'],
1111
};
File renamed without changes.

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@
4040
"@storybook/addon-essentials": "^8.2.4",
4141
"@storybook/addon-interactions": "^8.2.4",
4242
"@storybook/addon-links": "^8.2.4",
43-
"@storybook/preset-scss": "^1.0.3",
4443
"@storybook/react": "^8.2.4",
4544
"@storybook/react-vite": "^8.2.4",
4645
"@storybook/test": "^8.2.4",
@@ -100,7 +99,7 @@
10099
"react-tooltip": "^5.21.1"
101100
},
102101
"lint-staged": {
103-
"*.{js,jsx,ts,tsx}": [
102+
"*.{mjs,js,jsx,mts,ts,tsx}": [
104103
"prettier --write",
105104
"eslint --fix"
106105
]

tsconfig.node.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@
66
"moduleResolution": "bundler",
77
"allowSyntheticDefaultImports": true
88
},
9-
"include": ["vite.config.ts"]
9+
"include": ["vite.config.mts"]
1010
}
Lines changed: 57 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
import path from 'path';
2-
import {defineConfig, UserConfigExport, type PluginOption, loadEnv} from 'vite';
2+
import {defineConfig, type PluginOption, UserConfigExport} from 'vite';
33
import react from '@vitejs/plugin-react';
44
import {visualizer} from 'rollup-plugin-visualizer';
55

66
import compression from 'vite-plugin-compression2';
77

8-
const resolve = (dir) => path.join(__dirname, '.', dir);
9-
8+
const resolve = (dir: string) => path.join(__dirname, '.', dir);
109

1110
// region [Common Config]
1211

@@ -21,8 +20,8 @@ const commonConfig = () => ({
2120
resolve: {
2221
extensions: ['.tsx', '.ts', '.scss', '.js'],
2322
alias: {
24-
// IntelliJ doesn't recognize vite alias yet
25-
// Aliases should be set in tsconfig.json, main.ts as well
23+
// IntelliJ doesn't recognize vite alias, yet
24+
// Aliases should be set in tsconfig.json, main.mts as well
2625
// @See https://youtrack.jetbrains.com/issue/WEB-55332/Vite-aliases-in-vite.config-support
2726
'@': resolve('src'),
2827
'~': resolve('src/components'),
@@ -31,21 +30,45 @@ const commonConfig = () => ({
3130
},
3231
css: {
3332
preprocessorOptions: {
34-
scss: {
35-
},
33+
scss: {},
3634
},
3735
devSourcemap: true,
3836
},
3937
envDir: './dotenv',
4038
// @formatter:off
41-
envPrefix: ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P',
42-
'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'],
39+
envPrefix: [
40+
'A',
41+
'B',
42+
'C',
43+
'D',
44+
'E',
45+
'F',
46+
'G',
47+
'H',
48+
'I',
49+
'J',
50+
'K',
51+
'L',
52+
'M',
53+
'N',
54+
'O',
55+
'P',
56+
'Q',
57+
'R',
58+
'S',
59+
'T',
60+
'U',
61+
'V',
62+
'W',
63+
'X',
64+
'Y',
65+
'Z',
66+
],
4367
// @formatter:on
4468
});
4569

4670
// endregion
4771

48-
4972
// region [DevServer Config]
5073

5174
const devServerConfig = () => ({
@@ -68,7 +91,6 @@ const devServerConfig = () => ({
6891

6992
// endregion
7093

71-
7294
// region [Production Config]
7395

7496
const outputConfig = () => ({
@@ -79,38 +101,34 @@ const outputConfig = () => ({
79101

80102
// endregion
81103

82-
83104
/**
84105
* Vite Manual, Vite 매뉴얼
85106
* https://vitejs.dev/config/
86107
* https://vitejs-kr.github.io/
87108
*/
88-
export default defineConfig(
89-
({mode, command}) => {
90-
// dev (dev, serve), preview (prod, serve), build (prod, build)
91-
92-
let config: UserConfigExport = {...commonConfig()};
93-
94-
if (command === 'serve') {
95-
config = {...config, ...devServerConfig()};
96-
}
97-
if (mode === 'production') {
98-
config = {...config, ...outputConfig()};
99-
if (process.env.npm_lifecycle_event === 'analyze') {
100-
config.plugins = [
101-
...config.plugins,
102-
visualizer({
103-
// https://github.com/btd/rollup-plugin-visualizer
104-
title: 'TKS Bundle Report',
105-
filename: './dist/tks-bundle-report.html',
106-
open: true,
107-
gzipSize: true,
108-
}) as unknown as PluginOption,
109-
];
110-
}
109+
export default defineConfig(({mode, command}) => {
110+
// dev (dev, serve), preview (prod, serve), build (prod, build)
111+
112+
let config: UserConfigExport = {...commonConfig()};
113+
114+
if (command === 'serve') {
115+
config = {...config, ...devServerConfig()};
116+
}
117+
if (mode === 'production') {
118+
config = {...config, ...outputConfig()};
119+
if (process.env.npm_lifecycle_event === 'analyze') {
120+
config.plugins = [
121+
...config.plugins,
122+
visualizer({
123+
// https://github.com/btd/rollup-plugin-visualizer
124+
title: 'TKS Bundle Report',
125+
filename: './dist/tks-bundle-report.html',
126+
open: true,
127+
gzipSize: true,
128+
}) as unknown as PluginOption,
129+
];
111130
}
131+
}
112132

113-
return config;
114-
},
115-
);
116-
133+
return config;
134+
});

0 commit comments

Comments
 (0)