-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheslint.config.js
More file actions
113 lines (100 loc) · 3.88 KB
/
Copy patheslint.config.js
File metadata and controls
113 lines (100 loc) · 3.88 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
// eslint.config.js
import globals from "globals";
import reactHooks from "eslint-plugin-react-hooks";
import reactRefresh from "eslint-plugin-react-refresh";
import tseslint from "typescript-eslint";
import pluginReact from "eslint-plugin-react";
import unusedImports from "eslint-plugin-unused-imports";
import eslint from "@eslint/js";
import { defineConfig } from "eslint/config";
import prettier from "eslint-config-prettier";
const customRules = {
// ---- Style & Formatting -----------------------------------------------
semi: ["error", "always"],
quotes: ["error", "double", { avoidEscape: true }],
"no-var": "error",
eqeqeq: ["error", "always"], // Требовать === вместо ==
// ---- Console & Debug -----------------------------------------------
"no-console": ["warn", { allow: ["warn", "error", "group", "groupEnd"] }],
"no-debugger": "error",
// ---- TypeScript -----------------------------------------------
"@typescript-eslint/no-explicit-any": "error",
"@typescript-eslint/no-empty-object-type": "off", // Разрешаем export type {}
"@typescript-eslint/no-unused-vars": "off",
// "@typescript-eslint/no-unused-vars": [
// "warn",
// {
// argsIgnorePattern: "^_", // Разрешаем _arg как "намеренно неиспользуемый"
// varsIgnorePattern: "^_",
// },
// ],
"unused-imports/no-unused-imports": "error",
"unused-imports/no-unused-vars": [
"error",
{
varsIgnorePattern: "^_",
argsIgnorePattern: "^_",
caughtErrorsIgnorePattern: "^_",
},
],
"@typescript-eslint/ban-ts-comment": [
"error",
{
"ts-ignore": "allow-with-description", // "@ts-ignore" только с комментарием
"ts-expect-error": "allow-with-description",
},
],
// ---- React -----------------------------------------------
// Хуки (расширяем рекомендованные)
...reactHooks.configs.recommended.rules,
"react-hooks/exhaustive-deps": "error", // Строго: все зависимости в useEffect
// ---- React Refresh / Vite -----------------------------------------------
"react-refresh/only-export-components": ["warn", { allowConstantExport: true }],
// ---- JSX & Accessibility -----------------------------------------------
"react/jsx-key": [
"error",
{
checkFragmentShorthand: true, // Проверять <>...</>
warnOnDuplicates: true, // Предупреждать о дублях ключей
},
],
// ---- Comments & Documentation -----------------------------------------------
"no-warning-comments": "off", // Отключаем предупреждения про TODO/FIXME
};
// ============================================================================
// 🧪 ПРАВИЛА ДЛЯ ТЕСТОВЫХ ФАЙЛОВ (override)
// ============================================================================
const testRules = {
"no-console": "off", // В тестах можно логировать
"@typescript-eslint/no-explicit-any": "warn", // В тестах можно any для моков
};
export default defineConfig(
eslint.configs.recommended,
...tseslint.configs.recommended,
{ ignores: ["dist", "public", "node_modules", "build", "coverage", "**/src/shared/ui/**"] },
{
files: ["**/*.{ts,tsx}"],
languageOptions: {
ecmaVersion: 2020,
globals: globals.browser,
parserOptions: {
ecmaVersion: "latest",
ecmaFeatures: { jsx: true },
sourceType: "module",
},
},
settings: { react: { version: "18.2.0" } },
plugins: {
"unused-imports": unusedImports,
"react-hooks": reactHooks,
"react-refresh": reactRefresh,
react: pluginReact,
},
rules: customRules,
},
{
files: ["**/*.test.{ts,tsx}", "**/*.spec.{ts,tsx}", "**/__tests__/**", "/tests/**"],
rules: testRules,
},
prettier
);