Skip to content

Commit 506e273

Browse files
committed
Fixed pre-commit eslint configuration
1 parent c1126ba commit 506e273

30 files changed

Lines changed: 671 additions & 468 deletions

File tree

.pre-commit-config.yaml

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,15 @@ repos:
1919
- id: end-of-file-fixer
2020

2121
- repo: https://github.com/pre-commit/mirrors-eslint
22-
rev: ''
22+
rev: 'v9.28.0'
2323
hooks:
2424
- id: eslint
25-
name: ESLint
26-
entry: eslint --fix --config frontend/.eslintrc --ignore-path frontend/.eslintignore
27-
language: node
28-
pass_filenames: false
29-
cwd: "frontend/"
25+
args: ['--fix', '--config', 'frontend/eslint-precommit.config.mjs', '--no-warn-ignored', 'frontend/']
3026
additional_dependencies:
31-
- eslint@8.31.0
32-
- eslint-config-prettier@8.10.0
27+
- eslint@9.28.0
28+
- eslint-config-prettier@10.1.5
3329
- eslint-plugin-i18n@2.4.0
34-
- eslint-plugin-prettier@4.2.1
35-
- eslint-plugin-simple-import-sort@10.0.0
36-
- '@typescript-eslint/eslint-plugin@5.48.1'
37-
- '@typescript-eslint/parser@5.48.1'
30+
- eslint-plugin-prettier@5.4.1
31+
- eslint-plugin-simple-import-sort@12.1.1
32+
- '@typescript-eslint/eslint-plugin@8.33.1'
33+
- '@typescript-eslint/parser@8.33.1'

frontend/.eslintignore

Lines changed: 0 additions & 12 deletions
This file was deleted.

frontend/.eslintrc

Lines changed: 0 additions & 34 deletions
This file was deleted.
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import { defineConfig, globalIgnores } from 'eslint/config';
2+
3+
import { BASE_CONFIG } from './eslint.config.mjs';
4+
5+
export default defineConfig([
6+
globalIgnores([
7+
'frontend/node_modules',
8+
'frontend/build',
9+
'frontend/server.js',
10+
'frontend/src/locale',
11+
'frontend/src/types',
12+
'frontend/src/setupProxy.js',
13+
'frontend/webpack/**/*',
14+
'frontend/webpack/env.js',
15+
'frontend/webpack/prod.js',
16+
'frontend/public',
17+
'frontend/staticServer.js',
18+
'frontend/webpack.config.js',
19+
'docs/**/*',
20+
]),
21+
22+
{ ...BASE_CONFIG },
23+
]);

frontend/eslint.config.mjs

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
import { defineConfig, globalIgnores } from 'eslint/config';
2+
import i18N from 'eslint-plugin-i18n';
3+
import simpleImportSort from 'eslint-plugin-simple-import-sort';
4+
import path from 'node:path';
5+
import { fileURLToPath } from 'node:url';
6+
import { FlatCompat } from '@eslint/eslintrc';
7+
import js from '@eslint/js';
8+
import typescriptEslint from '@typescript-eslint/eslint-plugin';
9+
import tsParser from '@typescript-eslint/parser';
10+
11+
const __filename = fileURLToPath(import.meta.url);
12+
const __dirname = path.dirname(__filename);
13+
const compat = new FlatCompat({
14+
baseDirectory: __dirname,
15+
recommendedConfig: js.configs.recommended,
16+
allConfig: js.configs.all,
17+
});
18+
19+
export const BASE_CONFIG = {
20+
extends: compat.extends(
21+
'eslint:recommended',
22+
'plugin:@typescript-eslint/eslint-recommended',
23+
'plugin:@typescript-eslint/recommended',
24+
'prettier',
25+
'plugin:prettier/recommended',
26+
),
27+
28+
plugins: {
29+
'@typescript-eslint': typescriptEslint,
30+
i18n: i18N,
31+
'simple-import-sort': simpleImportSort,
32+
},
33+
34+
languageOptions: {
35+
parser: tsParser,
36+
},
37+
38+
rules: {
39+
'i18n/no-russian-character': 1,
40+
41+
'simple-import-sort/imports': [
42+
'error',
43+
{
44+
groups: [
45+
['^react', 'lodash', '^\\w', '^@?\\w'],
46+
['^components', '^layouts'],
47+
['^consts', '^hooks', '^libs', '^routes', '^services', '^types'],
48+
['^App', '^pages'],
49+
['^\\./(?=.*/)(?!/?$)', '^\\.(?!/?$)', '^\\./?$'],
50+
['./constants/.'],
51+
['./definitions/.', './types'],
52+
['^.+\\.svg', '^.+\\.png$', '^.+\\.jpg', '^.+\\.s?css$'],
53+
],
54+
},
55+
],
56+
},
57+
};
58+
59+
export default defineConfig([
60+
globalIgnores([
61+
'node_modules',
62+
'build',
63+
'server.js',
64+
'src/locale',
65+
'src/types',
66+
'src/setupProxy.js',
67+
'webpack/**/*',
68+
'webpack/env.js',
69+
'webpack/prod.js',
70+
'public',
71+
'staticServer.js',
72+
'webpack.config.js',
73+
]),
74+
{ ...BASE_CONFIG },
75+
]);

0 commit comments

Comments
 (0)