Skip to content

Commit d72a1f6

Browse files
authored
♻️ Refactor error handling and code readability across modules (#70)
1 parent b691e74 commit d72a1f6

17 files changed

Lines changed: 1456 additions & 1868 deletions

File tree

.eslintrc.cjs

Lines changed: 0 additions & 91 deletions
This file was deleted.

.husky/pre-commit

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1 @@
1-
#!/usr/bin/env sh
2-
. "$(dirname -- "$0")/_/husky.sh"
3-
41
pnpx lint-staged

eslint.config.js

Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
import js from '@eslint/js';
2+
import globals from 'globals';
3+
import tseslint from 'typescript-eslint';
4+
import reactPlugin from 'eslint-plugin-react';
5+
import reactHooksPlugin from 'eslint-plugin-react-hooks';
6+
import reactRefreshPlugin from 'eslint-plugin-react-refresh';
7+
import importPlugin from 'eslint-plugin-import-x';
8+
import tanstackQueryPlugin from '@tanstack/eslint-plugin-query';
9+
import prettierRecommended from 'eslint-plugin-prettier/recommended';
10+
import { fixupConfigRules } from '@eslint/compat';
11+
12+
export default tseslint.config(
13+
// 1. ignores
14+
{ ignores: ['dist/', 'build/', 'dev-dist/', 'eslint.config.js'] },
15+
// 2. 기본 + TS 추천 설정
16+
js.configs.recommended,
17+
tseslint.configs.recommended,
18+
// 3. 플러그인 flat config
19+
tanstackQueryPlugin.configs['flat/recommended'],
20+
// ✅ 구형 API를 호출하는 React 플러그인 설정들을 최신 버전에 맞게 자동으로 패치(호환)
21+
...fixupConfigRules([
22+
reactPlugin.configs.flat.recommended,
23+
reactPlugin.configs.flat['jsx-runtime'],
24+
]),
25+
// 4. import flat config
26+
importPlugin.flatConfigs.recommended,
27+
importPlugin.flatConfigs.typescript,
28+
// 5. 메인 커스텀 설정 블록
29+
{
30+
files: ['**/*.{js,jsx,ts,tsx}'],
31+
languageOptions: {
32+
ecmaVersion: 'latest',
33+
sourceType: 'module',
34+
globals: { ...globals.browser },
35+
parser: tseslint.parser,
36+
},
37+
settings: {
38+
react: { version: 'detect' },
39+
'import-x/resolver': { typescript: true, node: true },
40+
},
41+
plugins: {
42+
'react-hooks': reactHooksPlugin,
43+
'react-refresh': reactRefreshPlugin,
44+
},
45+
rules: {
46+
// 플러그인 기본 설정 주입
47+
...reactHooksPlugin.configs['recommended'].rules,
48+
49+
// --- 커스텀 Rules 시작 ---
50+
'react-refresh/only-export-components': [
51+
'warn',
52+
{ allowConstantExport: true }, // 상수 내보내기 허용
53+
],
54+
'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
55+
'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
56+
'no-param-reassign': ['error', { props: false }],
57+
'prefer-const': 'warn',
58+
'no-plusplus': 'off',
59+
'vars-on-top': 'off',
60+
'no-underscore-dangle': 'off', // var _foo;
61+
'comma-dangle': 'off',
62+
'func-names': 'off', // setTimeout(function () {}, 0);
63+
'prefer-arrow-callback': 'off', // setTimeout(function () {}, 0);
64+
'prefer-template': 'off',
65+
'no-nested-ternary': 'off',
66+
'max-classes-per-file': 'off',
67+
'no-restricted-syntax': ['off', 'ForOfStatement'],
68+
'consistent-return': 'warn',
69+
'react/prop-types': 'off',
70+
'no-unused-expressions': 'warn',
71+
'no-unused-vars': 'off',
72+
'@typescript-eslint/no-unused-vars': [
73+
'warn',
74+
{
75+
argsIgnorePattern: '^_', // _로 시작하는 인자 무시
76+
varsIgnorePattern: '^_', // _로 시작하는 변수 무시
77+
},
78+
],
79+
80+
/** import 정렬 관련 설정 */
81+
'import-x/no-unresolved': 'error',
82+
'import-x/order': [
83+
'warn',
84+
{
85+
// 그룹 순서 지정
86+
groups: [
87+
'builtin', // Built-in imports go first
88+
'external', // External imports
89+
'internal', // Absolute imports
90+
['parent', 'sibling'], // Relative imports from siblings and parents can mix
91+
'index', // index imports
92+
'object',
93+
'type',
94+
],
95+
'newlines-between': 'always',
96+
// 패턴으로 세부적인 순서 지정
97+
pathGroups: [
98+
{
99+
pattern: '{react,react-dom,react-dom/*}',
100+
group: 'external',
101+
position: 'before',
102+
},
103+
],
104+
// 리액트 패키지는 external 그룹에서 알파벳 순이 아닌 상단에 위치시키기 위해 예외 처리
105+
pathGroupsExcludedImportTypes: ['react'],
106+
alphabetize: { order: 'asc', caseInsensitive: true },
107+
},
108+
],
109+
},
110+
},
111+
112+
// 6. Node.js 전역변수 — 서버/설정 파일 전용 ✅
113+
{
114+
files: ['vite.config.*', 'vitest.config.*', 'scripts/**/*.{js,ts}'],
115+
languageOptions: {
116+
globals: { ...globals.node },
117+
},
118+
},
119+
120+
// 7. Prettier — 반드시 마지막 (다른 포맷 규칙 override)
121+
prettierRecommended,
122+
{
123+
rules: {
124+
// Prettier 포맷 관련 내용은 'warn' 으로 취급(ESLint/Prettier 충돌 방지) ▼
125+
// { endOfLine: 'auto' } 엔드라인 시퀀스 자동 변경 ▼
126+
'prettier/prettier': ['warn', { endOfLine: 'auto' }],
127+
},
128+
},
129+
);

package.json

Lines changed: 29 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -39,55 +39,58 @@
3939
"@formkit/auto-animate": "^0.8.4",
4040
"@hookform/resolvers": "^3.10.0",
4141
"@lottiefiles/react-lottie-player": "^3.6.0",
42-
"@tanstack/react-query": "^5.90.17",
42+
"@tanstack/react-query": "^5.90.21",
4343
"@tsparticles/engine": "^3.9.1",
4444
"@tsparticles/preset-links": "^3.2.0",
4545
"@tsparticles/react": "^3.0.0",
4646
"@vercel/analytics": "^1.6.1",
4747
"@vercel/speed-insights": "^1.3.1",
48-
"axios": "^1.13.5",
48+
"axios": "^1.13.6",
4949
"clsx": "^2.1.1",
5050
"date-fns": "^3.6.0",
5151
"framer-motion": "^11.18.2",
52-
"jotai": "^2.16.2",
52+
"jotai": "^2.18.0",
5353
"nanoid": "^5.1.6",
54-
"qs": "^6.14.2",
55-
"react": "^18.3.1",
56-
"react-dom": "^18.3.1",
54+
"qs": "^6.15.0",
55+
"react": "^19.2.4",
56+
"react-dom": "^19.2.4",
5757
"react-error-boundary": "^4.1.2",
58-
"react-hook-form": "^7.71.1",
58+
"react-hook-form": "^7.71.2",
5959
"react-icons": "^5.5.0",
6060
"react-router-dom": "^6.30.3",
61-
"sass": "^1.97.2",
61+
"sass": "^1.97.3",
6262
"yup": "^1.7.1"
6363
},
6464
"devDependencies": {
65+
"@eslint/compat": "^2.0.2",
66+
"@eslint/js": "^10.0.1",
6567
"@hookform/devtools": "^4.4.0",
66-
"@tanstack/eslint-plugin-query": "^5.91.2",
67-
"@tanstack/react-query-devtools": "^5.91.2",
68-
"@types/node": "^20.19.29",
68+
"@tanstack/eslint-plugin-query": "^5.91.4",
69+
"@tanstack/react-query-devtools": "^5.91.3",
70+
"@types/node": "^20.19.35",
6971
"@types/qs": "^6.14.0",
70-
"@types/react": "^18.3.27",
72+
"@types/react": "^18.3.28",
7173
"@types/react-dom": "^18.3.7",
72-
"@typescript-eslint/eslint-plugin": "^7.18.0",
73-
"@typescript-eslint/parser": "^7.18.0",
74-
"@vitejs/plugin-react": "^4.7.0",
75-
"eslint": "^8.57.1",
76-
"eslint-config-prettier": "^9.1.2",
77-
"eslint-import-resolver-typescript": "^3.10.1",
78-
"eslint-plugin-import": "^2.32.0",
74+
"@vitejs/plugin-react": "^5.1.4",
75+
"eslint": "^10.0.2",
76+
"eslint-config-prettier": "^10.1.8",
77+
"eslint-import-resolver-typescript": "^4.4.4",
78+
"eslint-plugin-import-x": "^4.16.1",
7979
"eslint-plugin-prettier": "^5.5.5",
8080
"eslint-plugin-react": "^7.37.5",
81-
"eslint-plugin-react-hooks": "^4.6.2",
82-
"eslint-plugin-react-refresh": "^0.4.26",
81+
"eslint-plugin-react-hooks": "^7.0.1",
82+
"eslint-plugin-react-refresh": "^0.5.2",
83+
"globals": "^17.4.0",
8384
"husky": "^9.1.7",
84-
"jotai-devtools": "^0.8.0",
85+
"jotai-babel": "^0.1.0",
86+
"jotai-devtools": "^0.13.0",
8587
"lint-staged": "^15.5.2",
86-
"prettier": "^3.7.4",
88+
"prettier": "^3.8.1",
8789
"rollup-plugin-visualizer": "^5.14.0",
8890
"typescript": "^5.9.3",
89-
"vite": "^5.4.21",
90-
"vite-plugin-pwa": "^0.19.8",
91-
"vite-tsconfig-paths": "^4.3.2"
91+
"typescript-eslint": "^8.56.1",
92+
"vite": "^7.3.1",
93+
"vite-plugin-pwa": "^1.2.0",
94+
"vite-tsconfig-paths": "^6.1.1"
9295
}
9396
}

0 commit comments

Comments
 (0)