-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheslint.config.js
More file actions
92 lines (90 loc) · 2.52 KB
/
eslint.config.js
File metadata and controls
92 lines (90 loc) · 2.52 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
// ESLint Flat Config for JS & TS coding test practice
// 참고: https://eslint.org/docs/latest/use/configure/configuration-files-new
import js from '@eslint/js';
import globals from 'globals';
import tseslint from 'typescript-eslint';
import vitest from '@vitest/eslint-plugin';
/**
* 설계 원칙
* 1. 오류 가능성 높은 규칙(error) 우선
* 2. 학습/풀이 편의 위해 스타일 과도 제약 X (Prettier 별도)
* 3. 미사용 변수는 _ prefix 허용
* 4. 테스트 파일은 vitest 전역 허용 및 집중 규칙 적용
*/
export default [
// 무시 경로
{
ignores: [
'node_modules/**',
'.yarn/**',
'*.log',
'coverage/**',
'dist/**',
'build/**',
'*.d.ts',
],
},
// JavaScript 파일 기본 설정
{
files: ['**/*.js', '**/*.cjs', '**/*.mjs'],
languageOptions: {
ecmaVersion: 2022,
sourceType: 'module',
globals: {
...globals.es2022,
...globals.node,
},
},
rules: {
...js.configs.recommended.rules,
// 일반 규칙 조정
'no-unused-vars': 'off', // TS 쪽에서 처리
'no-undef': 'error',
'no-console': 'off',
'prefer-const': 'warn',
'no-var': 'error',
eqeqeq: 'warn',
curly: 'warn',
'no-implicit-coercion': 'off',
},
},
// TypeScript 전용 (타입 기반 규칙은 초기부담 줄이기 위해 project 미지정)
...tseslint.config({
files: ['**/*.ts'],
extends: [...tseslint.configs.recommended],
languageOptions: {
parserOptions: {
// project: './tsconfig.json', // 필요시 활성화하여 타입 기반 규칙 강화
},
},
rules: {
'@typescript-eslint/no-unused-vars': [
'warn',
{ argsIgnorePattern: '^_', varsIgnorePattern: '^_' },
],
'@typescript-eslint/no-explicit-any': 'warn',
'@typescript-eslint/explicit-function-return-type': 'off',
// TS 파일에서도 prefer-const는 경고 수준 유지
'prefer-const': 'warn',
},
}),
// Vitest 테스트 파일
{
files: ['**/*.test.{js,ts}', '**/*.spec.{js,ts}', 'test/**/*.{js,ts}'],
plugins: { vitest },
languageOptions: {
globals: {
...globals.es2022,
...globals.node,
...vitest.environments.env.globals,
},
},
rules: {
...vitest.configs.recommended.rules,
'vitest/no-disabled-tests': 'warn',
'vitest/no-focused-tests': 'error',
'vitest/prefer-to-be': 'warn',
'vitest/prefer-to-have-length': 'warn',
},
},
];