-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy patheslint.config.mjs
132 lines (122 loc) · 4.19 KB
/
eslint.config.mjs
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
import { dirname } from 'path'
import { fileURLToPath } from 'url'
import { FlatCompat } from '@eslint/eslintrc'
const __filename = fileURLToPath(import.meta.url)
const __dirname = dirname(__filename)
const compat = new FlatCompat({
baseDirectory: __dirname,
})
const eslintConfig = [
{
ignores: ['node_modules/**', '.next/**', 'dist/**', 'build/**', 'public/**'],
},
...compat.extends(
'next/core-web-vitals',
'plugin:@typescript-eslint/recommended',
'plugin:jsx-a11y/recommended',
'prettier',
),
{
files: ['**/*.ts', '**/*.tsx'],
languageOptions: {
parserOptions: {
project: './tsconfig.json',
tsconfigRootDir: __dirname,
},
},
rules: {
// 네이밍 규칙
'react/jsx-pascal-case': 'error',
camelcase: ['error', { properties: 'never' }],
'react/jsx-handler-names': [
'error',
{
eventHandlerPrefix: 'handle',
eventHandlerPropPrefix: 'on',
},
],
// 변수명 길이 제한
'id-length': [
'error',
{
min: 2,
exceptions: ['x', 'y', 'i', 'j', 'id', '_'],
},
],
// 특정 약어 사용 금지
'id-denylist': ['error', 'err', 'idx', 'e'],
// TypeScript 네이밍 컨벤션
'@typescript-eslint/naming-convention': [
'error',
{
selector: 'variable',
types: ['boolean'],
format: ['camelCase'],
},
{
selector: 'variable',
types: ['function'],
format: ['camelCase'],
suffix: ['Ref'],
filter: {
regex: 'Ref$',
match: true,
},
},
// {
// selector: 'interface',
// format: ['PascalCase'],
// custom: {
// regex: '(Props|Model)$',
// match: true,
// },
// },
{
selector: 'typeAlias',
format: ['PascalCase'],
suffix: ['Type'],
},
],
// React 컴포넌트 규칙
'react/destructuring-assignment': ['error', 'always'],
'react/function-component-definition': [
2,
{
namedComponents: 'arrow-function',
unnamedComponents: 'arrow-function',
},
],
'react/jsx-key': ['error', { checkFragmentShorthand: true }],
// Import 순서
'import/order': [
'error',
{
groups: ['builtin', 'external', 'internal', 'parent', 'sibling', 'index', 'object', 'type'],
pathGroups: [
{
pattern: 'react',
group: 'external',
position: 'before',
},
],
'newlines-between': 'always',
alphabetize: { order: 'asc', caseInsensitive: true },
},
],
// JavaScript 기본 규칙
'prefer-const': 'error',
'no-var': 'error',
eqeqeq: 'error',
'object-shorthand': 'error',
'no-console': ['warn', { allow: ['warn', 'error'] }],
// TypeScript 규칙
'@typescript-eslint/no-explicit-any': 'warn',
'@typescript-eslint/no-unused-vars': ['warn', { argsIgnorePattern: '^_', varsIgnorePattern: '^_' }],
// React Hooks 규칙
'react-hooks/rules-of-hooks': 'error',
'react-hooks/exhaustive-deps': 'warn',
'react-hooks/rules-of-hooks': 'off',
},
},
]
export default eslintConfig