forked from antirek/chat3
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheslint.config.js
More file actions
120 lines (119 loc) · 3.95 KB
/
eslint.config.js
File metadata and controls
120 lines (119 loc) · 3.95 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
import js from '@eslint/js';
import jest from 'eslint-plugin-jest';
import tseslint from '@typescript-eslint/eslint-plugin';
import tsparser from '@typescript-eslint/parser';
export default [
{
ignores: [
'node_modules/**',
'coverage/**',
'*.min.js',
'**/dist/**',
'dist/**',
'build/**',
'packages/*/dist/**',
'packages-shared/*/dist/**',
'packages/tenant-api-client/node_modules/**',
'packages/tenant-api-client/coverage/**',
'**/*.d.ts',
],
},
js.configs.recommended,
{
files: ['**/*.js', '**/*.ts'],
languageOptions: {
parser: tsparser,
parserOptions: {
ecmaVersion: 2022,
sourceType: 'module'
},
globals: {
console: 'readonly',
process: 'readonly',
Buffer: 'readonly',
__dirname: 'readonly',
__filename: 'readonly',
global: 'readonly',
module: 'readonly',
require: 'readonly',
exports: 'readonly',
setTimeout: 'readonly',
clearTimeout: 'readonly',
setInterval: 'readonly',
clearInterval: 'readonly',
fetch: 'readonly',
URL: 'readonly',
URLSearchParams: 'readonly',
structuredClone: 'readonly',
},
},
plugins: {
'@typescript-eslint': tseslint
},
rules: {
// Запрещаем динамические импорты (import()) для JS
'no-restricted-syntax': [
'error',
{
selector: 'ImportExpression',
message: 'Динамические импорты (import()) запрещены. Используйте статические импорты в начале файла.',
},
],
// Разрешаем неиспользуемые переменные с префиксом _ (стандартная практика)
'no-unused-vars': 'off', // Отключаем для JS, используем TypeScript правило
// TypeScript правила
'@typescript-eslint/no-unused-vars': [
'error',
{
argsIgnorePattern: '^_',
varsIgnorePattern: '^_',
caughtErrorsIgnorePattern: '^_'
}
]
},
},
// Конфигурация для UI файлов (браузерное окружение)
{
files: ['packages/controlo-ui/src/**/*.ts', 'packages/controlo-ui/src/**/*.js'],
languageOptions: {
globals: {
window: 'readonly',
document: 'readonly',
navigator: 'readonly',
location: 'readonly',
history: 'readonly',
alert: 'readonly',
confirm: 'readonly',
HTMLElement: 'readonly',
KeyboardEvent: 'readonly',
structuredClone: 'readonly',
},
},
},
// Конфигурация для роутера (разрешаем динамические импорты для code splitting)
{
files: ['**/router/**', '**/router/**/*.ts', '**/router/**/*.js', 'packages/controlo-ui/src/app/router/**'],
rules: {
'no-restricted-syntax': 'off', // Разрешаем динамические импорты в роутере (стандартная практика Vue Router)
},
},
// Конфигурация для тестовых файлов
{
files: ['**/__tests__/**', '**/*.test.js', '**/*.test.ts', '**/*.spec.js', '**/*.spec.ts'],
plugins: {
jest,
},
languageOptions: {
globals: {
...jest.environments.globals.globals,
},
},
rules: {
// В тестах разрешаем динамические импорты (могут быть нужны для условной загрузки)
'no-restricted-syntax': 'off',
// В тестах разрешаем неиспользуемые переменные (могут быть для отладки или будущего использования)
'no-unused-vars': 'off',
'@typescript-eslint/no-unused-vars': 'off',
},
},
];