Skip to content

Commit b40786b

Browse files
committed
📦️ ESLint v8 > v10 마이그레이션
1 parent cc1fd68 commit b40786b

4 files changed

Lines changed: 905 additions & 1031 deletions

File tree

.eslintrc.cjs

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

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';
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', '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/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/no-unresolved': 'error',
82+
'import/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: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@
5252
"jotai": "^2.18.0",
5353
"nanoid": "^5.1.6",
5454
"qs": "^6.15.0",
55-
"react": "^18.3.1",
56-
"react-dom": "^18.3.1",
55+
"react": "^19.2.4",
56+
"react-dom": "^19.2.4",
5757
"react-error-boundary": "^4.1.2",
5858
"react-hook-form": "^7.71.2",
5959
"react-icons": "^5.5.0",
@@ -62,32 +62,34 @@
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",
6668
"@tanstack/eslint-plugin-query": "^5.91.4",
6769
"@tanstack/react-query-devtools": "^5.91.3",
6870
"@types/node": "^20.19.35",
6971
"@types/qs": "^6.14.0",
7072
"@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",
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",
7878
"eslint-plugin-import": "^2.32.0",
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",
8485
"jotai-devtools": "^0.8.0",
8586
"lint-staged": "^15.5.2",
8687
"prettier": "^3.8.1",
8788
"rollup-plugin-visualizer": "^5.14.0",
8889
"typescript": "^5.9.3",
89-
"vite": "^5.4.21",
90-
"vite-plugin-pwa": "^0.19.8",
91-
"vite-tsconfig-paths": "^4.3.2"
90+
"typescript-eslint": "^8.56.1",
91+
"vite": "^7.3.1",
92+
"vite-plugin-pwa": "^1.2.0",
93+
"vite-tsconfig-paths": "^6.1.1"
9294
}
9395
}

0 commit comments

Comments
 (0)