Phase 10: запрет inline eslint-disable, file-level overrides, IUser-тип
This commit is contained in:
+42
-7
@@ -18,6 +18,8 @@ const CONFIG_ROOT = import.meta.dirname;
|
||||
const TEST_FILES = ['**/*.{test,spec}.{ts,tsx}'];
|
||||
const CONFIG_AND_SCRIPT_FILES = ['**/*.config.{ts,mts,cts}', '**/vite.config.*'];
|
||||
|
||||
/* eslint-disable no-unused-vars -- eslint.config.js lintится самим собой */
|
||||
|
||||
/* Забираем правила из пресетов плагинов */
|
||||
const reactRecommendedRules =
|
||||
react.configs.flat?.recommended?.rules ??
|
||||
@@ -50,8 +52,11 @@ export default defineConfig(
|
||||
{
|
||||
name: 'client/linter-policy',
|
||||
linterOptions: {
|
||||
noInlineConfig: false,
|
||||
// Inline-директивы (eslint-disable и т.п.) в коде запрещены.
|
||||
// Единственный способ отключить правило — file-level override в этом конфиге.
|
||||
noInlineConfig: true,
|
||||
reportUnusedDisableDirectives: 'error',
|
||||
reportUnusedInlineConfigs: 'error',
|
||||
},
|
||||
},
|
||||
|
||||
@@ -274,12 +279,6 @@ export default defineConfig(
|
||||
'newlines-between': 'always',
|
||||
}],
|
||||
|
||||
/* Запрет необъяснённых disable-директив */
|
||||
'@eslint-community/eslint-comments/disable-enable-pair': ['error', { allowWholeFile: false }],
|
||||
'@eslint-community/eslint-comments/no-aggregating-enable': 'error',
|
||||
'@eslint-community/eslint-comments/no-duplicate-disable': 'error',
|
||||
'@eslint-community/eslint-comments/no-unlimited-disable': 'error',
|
||||
'@eslint-community/eslint-comments/require-description': ['error', { ignore: ['eslint-enable'] }],
|
||||
},
|
||||
},
|
||||
|
||||
@@ -310,4 +309,40 @@ export default defineConfig(
|
||||
'@typescript-eslint/require-await': 'off',
|
||||
},
|
||||
},
|
||||
|
||||
/* ── Файловые исключения (единственный способ отключить правило) ── */
|
||||
{
|
||||
name: 'client/api-client',
|
||||
files: ['src/api/client.ts'],
|
||||
rules: {
|
||||
// fetch.json() возвращает any — assertion неизбежен
|
||||
'@typescript-eslint/no-unsafe-type-assertion': 'off',
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'client/news-editor',
|
||||
files: ['src/hooks/useNewsEditor.ts'],
|
||||
rules: {
|
||||
// Хук-оркестратор: 4 action-обработчика + toolbar + upload
|
||||
'max-lines-per-function': 'off',
|
||||
// window.confirm для подтверждения удаления
|
||||
'no-alert': 'off',
|
||||
// e.target.value = '' — сброс file input (стандартный паттерн)
|
||||
'no-param-reassign': ['error', { props: true, ignorePropertyModificationsFor: ['e'] }],
|
||||
// Навигация после await (window.location.href → useNavigate)
|
||||
'require-atomic-updates': 'off',
|
||||
// async IIFE в useEffect для загрузки новости
|
||||
'@typescript-eslint/no-floating-promises': 'off',
|
||||
// newsId гарантированно string (проверено isNew)
|
||||
'@typescript-eslint/restrict-template-expressions': 'off',
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'client/auth-pages',
|
||||
files: ['src/pages/LoginPage.tsx', 'src/pages/RegisterPage.tsx'],
|
||||
rules: {
|
||||
// .then()/.catch() в цепочке — не floating promise
|
||||
'@typescript-eslint/no-floating-promises': 'off',
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user