/**
* ESLint (flat config): исходники движка и игры. Логика качества — tsc (типы)
* и гвард границы (imports); ESLint ловит остальное: неиспользуемое, промахи
* промисов, равенства. Тулзы .mjs не линтятся (node-скрипты без типов).
*/
import js from '@eslint/js';
import tseslint from 'typescript-eslint';
export default tseslint.config(
{
ignores: ['**/node_modules/**', '**/dist/**', '**/*.d.ts']
},
js.configs.recommended,
...tseslint.configs.recommended,
{
files: ['packages/engine/src/**/*.ts', 'apps/game/src/**/*.ts', 'apps/game/tools/**/*.ts'],
rules: {
// no-undef в TS ложится на глобали DOM/Vite — типы проверяет tsc.
'no-undef': 'off',
// Неиспользуемое — ошибка, кроме параметров с ведущим _ (хуки движка).
'@typescript-eslint/no-unused-vars': [
'error',
{ argsIgnorePattern: '^_', varsIgnorePattern: '^_', caughtErrors: 'none' }
],
'no-console': 'off',
'prefer-const': 'error'
}
},
{
// Node-тулзы (.mjs): глобали Node без типов (tsc их не видит).
files: ['apps/game/tools/**/*.mjs', 'apps/game/tools/**/*.ts'],
languageOptions: {
globals: {
console: 'readonly',
process: 'readonly',
URL: 'readonly',
Buffer: 'readonly',
fetch: 'readonly',
setTimeout: 'readonly',
clearTimeout: 'readonly',
// Страница игры в puppeteer-сценариях (page.evaluate).
window: 'readonly'
}
}
},
{
// Сценарии-тулзы: консоль — их интерфейс; пустой catch — «браузер мог умереть».
files: ['apps/game/tools/**/*.ts', 'apps/game/tools/**/*.mjs'],
rules: {
'no-console': 'off',
'no-empty': ['error', { allowEmptyCatch: true }]
}
},
{
// Браузерный скрипт редактора диалогов.
files: ['apps/game/tools/dialogue-editor/**/*.js'],
languageOptions: {
globals: {
console: 'readonly',
document: 'readonly',
window: 'readonly',
fetch: 'readonly',
setTimeout: 'readonly',
setInterval: 'readonly',
clearInterval: 'readonly',
requestAnimationFrame: 'readonly',
localStorage: 'readonly',
history: 'readonly',
Option: 'readonly',
confirm: 'readonly'
}
}
}
);