-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheslint.config.mjs
More file actions
242 lines (233 loc) · 5.98 KB
/
eslint.config.mjs
File metadata and controls
242 lines (233 loc) · 5.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
/**
* THIS FILE WAS AUTO-GENERATED.
* PLEASE DO NOT EDIT IT MANUALLY.
* ===============================
* IF YOU'RE COPYING THIS INTO AN ESLINT CONFIG, REMOVE THIS COMMENT BLOCK.
*/
import path from 'node:path';
import { includeIgnoreFile } from '@eslint/compat';
import js from '@eslint/js';
import { configs, plugins } from 'eslint-config-airbnb-extended';
import { rules as prettierConfigRules } from 'eslint-config-prettier';
import prettierPlugin from 'eslint-plugin-prettier';
import importPlugin from 'eslint-plugin-import';
export const projectRoot = path.resolve('.');
export const gitignorePath = path.resolve(projectRoot, '.gitignore');
const jsConfig = [
// ESLint Recommended Rules
{
name: 'js/config',
...js.configs.recommended,
},
// Stylistic Plugin
plugins.stylistic,
// Import X Plugin
plugins.importX,
// Airbnb Base Recommended Config
...configs.base.recommended,
];
const reactConfig = [
// React Plugin
plugins.react,
// React Hooks Plugin
plugins.reactHooks,
// React JSX A11y Plugin
plugins.reactA11y,
// Airbnb React Recommended Config
...configs.react.recommended,
];
const typescriptConfig = [
// TypeScript ESLint Plugin
plugins.typescriptEslint,
// Airbnb Base TypeScript Config
...configs.base.typescript,
// Airbnb React TypeScript Config
...configs.react.typescript,
];
const prettierConfig = [
// Prettier Plugin
{
name: 'prettier/plugin/config',
plugins: {
prettier: prettierPlugin,
},
},
// Prettier Config
{
name: 'prettier/config',
rules: {
...prettierConfigRules,
'prettier/prettier': [
'error',
{
tabWidth: 2,
singleQuote: true,
printWidth: 80,
semi: true,
bracketSpacing: true,
objectWrap: 'preserve',
bracketSameLine: false,
arrowParens: 'always',
},
],
},
},
];
const myCustomConfig = [
{
name: 'my-custom-config',
rules: {
'react/react-in-jsx-scope': 'off',
'react/function-component-definition': [
'error',
{
namedComponents: 'function-declaration',
unnamedComponents: 'function-expression',
},
],
},
},
{
name: 'import-plugin',
plugins: {
import: importPlugin,
},
settings: {
'import/resolver': {
typescript: {},
node: {
extensions: ['.js', '.jsx', '.ts', '.tsx'],
},
},
},
},
// 컴포넌트 파일들 - default export 강제
{
name: 'component-files-config',
files: [
'**/components/**/*.{js,jsx,ts,tsx}',
'**/pages/**/*.{js,jsx,ts,tsx}',
'**/*Component.{js,jsx,ts,tsx}',
],
rules: {
'import/prefer-default-export': 'error',
'import-x/prefer-default-export': 'error',
},
},
// 커스텀 훅 파일들 - named export 허용
{
name: 'custom-hooks-config',
files: [
'**/hooks/**/*.{js,jsx,ts,tsx}',
'**/use*.{js,jsx,ts,tsx}',
'**/*Hook.{js,jsx,ts,tsx}',
'**/*Hooks.{js,jsx,ts,tsx}',
],
rules: {
'import/prefer-default-export': 'off',
'import-x/prefer-default-export': 'off',
// 훅 관련 규칙들도 추가로 적용
'react-hooks/rules-of-hooks': 'error',
'react-hooks/exhaustive-deps': 'warn',
},
},
// 유틸리티 함수들 - named export 허용
{
name: 'utility-files-config',
files: [
'**/utils/**/*.{js,jsx,ts,tsx}',
'**/helpers/**/*.{js,jsx,ts,tsx}',
'**/lib/**/*.{js,jsx,ts,tsx}', // 기존 설정과 통합
'**/*Utils.{js,jsx,ts,tsx}',
'**/*Helper.{js,jsx,ts,tsx}',
'**/*Util.{js,jsx,ts,tsx}',
],
rules: {
'import/prefer-default-export': 'off',
'import-x/prefer-default-export': 'off',
},
},
// 상수 및 설정 파일들 - named export 허용
{
name: 'constants-config-files',
files: [
'**/constants/**/*.{js,jsx,ts,tsx}',
'**/config/**/*.{js,jsx,ts,tsx}',
'**/*Constants.{js,jsx,ts,tsx}',
'**/*Config.{js,jsx,ts,tsx}',
'**/*Settings.{js,jsx,ts,tsx}',
'**/env.{js,ts}',
'**/environment.{js,ts}',
],
rules: {
'import/prefer-default-export': 'off',
'import-x/prefer-default-export': 'off',
},
},
// 타입 정의 파일들 - named export 허용 (TypeScript)
{
name: 'type-definition-files',
files: [
'**/types/**/*.{ts,tsx}',
'**/*Types.{ts,tsx}',
'**/*Type.{ts,tsx}',
'**/*.d.ts',
'**/interfaces/**/*.{ts,tsx}',
'**/*Interface.{ts,tsx}',
],
rules: {
'import/prefer-default-export': 'off',
'import-x/prefer-default-export': 'off',
},
},
// API 관련 파일들 - named export 허용
{
name: 'api-files-config',
files: [
'**/api/**/*.{js,jsx,ts,tsx}',
'**/services/**/*.{js,jsx,ts,tsx}',
'**/*Service.{js,jsx,ts,tsx}',
'**/*Api.{js,jsx,ts,tsx}',
'**/graphql/**/*.{js,jsx,ts,tsx}',
'**/queries/**/*.{js,jsx,ts,tsx}',
'**/mutations/**/*.{js,jsx,ts,tsx}',
],
rules: {
'import/prefer-default-export': 'off',
'import-x/prefer-default-export': 'off',
},
},
// 스토어/상태 관리 파일들 - named export 허용
{
name: 'store-files-config',
files: [
'**/store/**/*.{js,jsx,ts,tsx}',
'**/stores/**/*.{js,jsx,ts,tsx}',
'**/redux/**/*.{js,jsx,ts,tsx}',
'**/zustand/**/*.{js,jsx,ts,tsx}',
'**/context/**/*.{js,jsx,ts,tsx}',
'**/*Store.{js,jsx,ts,tsx}',
'**/*Context.{js,jsx,ts,tsx}',
'**/*Slice.{js,jsx,ts,tsx}',
'**/*Reducer.{js,jsx,ts,tsx}',
],
rules: {
'import/prefer-default-export': 'off',
'import-x/prefer-default-export': 'off',
},
},
];
export default [
// Ignore .gitignore files/folder in eslint
includeIgnoreFile(gitignorePath),
// Javascript Config
...jsConfig,
// React Config
...reactConfig,
// TypeScript Config
...typescriptConfig,
// Prettier Config
...prettierConfig,
// My Custom Config
...myCustomConfig,
];