71 lines
2.1 KiB
JavaScript
71 lines
2.1 KiB
JavaScript
import { fileURLToPath } from 'node:url';
|
||
import { dirname } from 'node:path';
|
||
import eslint from '@eslint/js';
|
||
import { FlatCompat } from '@eslint/eslintrc';
|
||
import globals from 'globals';
|
||
import unusedImports from 'eslint-plugin-unused-imports';
|
||
import reactPlugin from 'eslint-plugin-react';
|
||
import tsPlugin from '@typescript-eslint/eslint-plugin';
|
||
|
||
// Аналог __dirname для ES-модулей
|
||
const __filename = fileURLToPath(import.meta.url);
|
||
const __dirname = dirname(__filename);
|
||
|
||
const compat = new FlatCompat({
|
||
baseDirectory: __dirname, // Теперь работает
|
||
recommendedConfig: eslint.configs.recommended,
|
||
});
|
||
|
||
export default [
|
||
...compat.config({
|
||
extends: [
|
||
'plugin:@typescript-eslint/recommended',
|
||
'plugin:react/recommended',
|
||
'plugin:react/jsx-runtime',
|
||
],
|
||
parser: '@typescript-eslint/parser',
|
||
}),
|
||
{
|
||
files: ['**/*.ts', '**/*.tsx'],
|
||
plugins: {
|
||
'unused-imports': unusedImports,
|
||
'react': reactPlugin,
|
||
'@typescript-eslint': tsPlugin,
|
||
},
|
||
languageOptions: {
|
||
sourceType: 'module',
|
||
globals: {
|
||
...globals.browser,
|
||
...globals.es2021,
|
||
},
|
||
},
|
||
settings: {
|
||
react: {
|
||
version: 'detect',
|
||
},
|
||
},
|
||
rules: {
|
||
'quotes': ['error', 'double'],
|
||
'@typescript-eslint/ban-ts-comment': 'off',
|
||
'react/jsx-uses-react': 'error',
|
||
'react/jsx-uses-vars': 'error',
|
||
'@typescript-eslint/no-unused-vars': 'off',
|
||
'unused-imports/no-unused-imports': 'error',
|
||
'@typescript-eslint/no-explicit-any': 'off',
|
||
'unused-imports/no-unused-vars': [
|
||
'error',
|
||
{
|
||
vars: 'all',
|
||
args: 'none',
|
||
caughtErrors: 'none',
|
||
ignoreRestSiblings: true,
|
||
varsIgnorePattern: '^_',
|
||
},
|
||
],
|
||
'prefer-const': ['error', {
|
||
destructuring: 'all', // Требует const, только если ВСЕ переменные не переопределяются
|
||
ignoreReadBeforeAssign: true // Игнорирует, если переменная меняется после первого использования
|
||
}]
|
||
}
|
||
},
|
||
]; |