-
Notifications
You must be signed in to change notification settings - Fork 0
/
.eslintrc.js
executable file
·138 lines (134 loc) · 4.38 KB
/
.eslintrc.js
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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
// https://eslint.org/docs/user-guide/configuring
module.exports = {
// Линтинг JavaScript (инфраструктурный код)
root: true,
extends: ['airbnb-base', 'plugin:import/recommended', 'plugin:prettier/recommended'],
parserOptions: {
ecmaVersion: 2020,
sourceType: 'module',
allowImportExportEverywhere: true,
},
env: {
node: true,
},
rules: {
'no-underscore-dangle': 0,
'linebreak-style': 0,
// https://github.com/prettier/eslint-config-prettier#special-rules
// https://github.com/airbnb/javascript/tree/master/packages/eslint-config-airbnb-base/rules
curly: ['error', 'all'],
'no-tabs': 'error',
'no-unexpected-multiline': 'error',
'import/order': [
'error',
{
groups: ['external', ['internal', 'parent', 'sibling', 'index'], 'unknown'],
'newlines-between': 'always',
},
],
'padding-line-between-statements': [
'error',
{ blankLine: 'always', prev: '*', next: 'block' },
{ blankLine: 'always', prev: 'block', next: '*' },
{ blankLine: 'always', prev: '*', next: 'block-like' },
{ blankLine: 'always', prev: 'block-like', next: '*' },
{ blankLine: 'always', prev: '*', next: 'return' },
{ blankLine: 'always', prev: ['const', 'let', 'var'], next: '*' },
{ blankLine: 'any', prev: ['const', 'let', 'var'], next: ['const', 'let', 'var'] },
],
},
overrides: [
// Линтинг TypeScript (сорсы и сервер)
{
files: ['src/**/*.ts', 'src/**/*.tsx', 'typings/**/*.ts', 'server/**/*.ts'],
extends: [
'plugin:@typescript-eslint/recommended',
'plugin:react/recommended',
'plugin:react-hooks/recommended',
'plugin:import/typescript',
],
plugins: ['simple-import-sort', '@andreyvolokitin/destructuring'],
parserOptions: {
project: 'tsconfig.json',
},
env: {
browser: true,
node: true,
},
rules: {
'class-methods-use-this': 'warn',
'lines-between-class-members': ['error', 'always', { exceptAfterSingleLine: true }],
// https://stackoverflow.com/a/64024916/718630
'no-use-before-define': 'off',
'@typescript-eslint/no-use-before-define': ['error'],
'@typescript-eslint/no-this-alias': 'warn',
// https://stackoverflow.com/questions/59265981/typescript-eslint-missing-file-extension-ts-import-extensions
'import/extensions': [
'error',
'ignorePackages',
{
js: 'never',
jsx: 'never',
ts: 'never',
tsx: 'never',
},
],
'import/order': 'off',
'simple-import-sort/imports': [
'error',
{
groups: [
// Packages. `react` related packages come first.
['^react', '^@?\\w'],
// Internal packages.
['^(@|@company|@ui|components|utils|config|vendored-lib)(/.*|$)'],
// Side effect imports.
['^\\u0000'],
// Parent imports. Put `..` last.
['^\\.\\.(?!/?$)', '^\\.\\./?$'],
// Other relative imports. Put same-folder imports and `.` last.
['^\\./(?=.*/)(?!/?$)', '^\\.(?!/?$)', '^\\./?$'],
// File imports.
['^.+\\..+(?<!s?css)$'],
// Style imports.
['^.+\\.s?css$'],
],
},
],
'import/first': 'error',
'import/newline-after-import': 'error',
'import/no-duplicates': 'error',
'@andreyvolokitin/destructuring/in-params': [
'error',
{ 'max-params': 2, 'max-destructured': 3 },
],
},
settings: {
react: {
version: 'detect',
},
'import/resolver': {
node: {
paths: ['static'],
},
webpack: {
config: './webpack/webpack.client.js',
},
},
},
},
// Линтинг тестов
{
files: ['**/__tests__/**/*.[jt]s?(x)', '**/?(*.)+(spec|test).[jt]s?(x)'],
extends: ['plugin:testing-library/react', 'plugin:jest-dom/recommended'],
rules: {
'import/no-extraneous-dependencies': [
'error',
{
devDependencies: ['**/*.test.ts', '**/*.spec.ts', '**/*.test.tsx', '**/*.spec.tsx'],
},
],
},
},
],
};