@zalib/linter 1.0.9 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/.eslintrc.js CHANGED
@@ -1,7 +1,7 @@
1
1
  module.exports = {
2
2
  overrides: [
3
3
  {
4
- extends: ['./eslint/js'],
4
+ extends: ['./eslint/node-js'],
5
5
  files: ['*.js'],
6
6
  },
7
7
  ],
package/README.md CHANGED
@@ -8,8 +8,8 @@ npm i --save-dev --save-exact @zalib/linter
8
8
  ### eslint
9
9
  Пример конфига **.eslintrc.js** из корня сервиса.
10
10
  ```
11
- const jsEslintConfig = require('@zalib/linter/eslint/js');
12
- const tsEslintConfig = require('@zalib/linter/eslint/ts');
11
+ const jsEslintConfig = require('@zalib/linter/eslint/node-js');
12
+ const tsEslintConfig = require('@zalib/linter/eslint/node-ts');
13
13
 
14
14
  module.exports = {
15
15
  overrides: [
@@ -0,0 +1,26 @@
1
+ const nodeBaseConfig = require('./node');
2
+
3
+ module.exports = {
4
+ env: {
5
+ ...nodeBaseConfig.env,
6
+ },
7
+ extends: [
8
+ ...nodeBaseConfig.extends,
9
+ 'eslint:recommended',
10
+ 'plugin:jest/recommended',
11
+ 'plugin:jest/style',
12
+ 'prettier',
13
+ 'plugin:prettier/recommended',
14
+ 'airbnb-base',
15
+ ],
16
+ files: ['*.js'],
17
+ plugins: [
18
+ ...nodeBaseConfig.plugins,
19
+ ],
20
+ rules: {
21
+ ...nodeBaseConfig.rules,
22
+ 'import/extensions': 0,
23
+ 'import/no-unresolved': 0,
24
+ strict: 0,
25
+ },
26
+ };
@@ -1,3 +1,5 @@
1
+ const nodeBaseConfig = require('./node');
2
+
1
3
  function eslintMembersGroup(suffix) {
2
4
  return [
3
5
  `public-static-${suffix}`,
@@ -27,22 +29,30 @@ function eslintMembersGroup(suffix) {
27
29
  }
28
30
 
29
31
  module.exports = {
32
+ env: {
33
+ ...nodeBaseConfig.env,
34
+ },
30
35
  extends: [
36
+ ...nodeBaseConfig.extends,
31
37
  'airbnb-typescript/base',
32
- 'eslint:recommended',
33
38
  'plugin:@typescript-eslint/recommended',
34
39
  'plugin:@typescript-eslint/recommended-requiring-type-checking',
35
40
  'plugin:import/errors',
36
41
  'plugin:import/typescript',
37
42
  'plugin:import/warnings',
38
- 'prettier',
39
- 'plugin:prettier/recommended',
40
43
  ],
41
44
  files: ['*.ts'],
42
45
  parser: '@typescript-eslint/parser',
43
- plugins: ['@typescript-eslint', 'jest', 'simple-import-sort', 'typescript-sort'],
46
+ plugins: [
47
+ ...nodeBaseConfig.plugins,
48
+ '@typescript-eslint',
49
+ 'simple-import-sort',
50
+ 'typescript-sort',
51
+ ],
44
52
  rules: {
53
+ ...nodeBaseConfig.rules,
45
54
  '@typescript-eslint/await-thenable': 1,
55
+ '@typescript-eslint/brace-style': 0,
46
56
  '@typescript-eslint/comma-dangle': [
47
57
  2,
48
58
  {
@@ -72,6 +82,7 @@ module.exports = {
72
82
  },
73
83
  ],
74
84
  '@typescript-eslint/explicit-module-boundary-types': 2,
85
+ '@typescript-eslint/indent': 0,
75
86
  '@typescript-eslint/member-ordering': [
76
87
  'error',
77
88
  {
@@ -167,6 +178,31 @@ module.exports = {
167
178
  selector: 'enumMember',
168
179
  trailingUnderscore: 'forbid',
169
180
  },
181
+ // Правило, разрешающее написание "_id" с нижним подчеркиванием
182
+ {
183
+ filter: {
184
+ match: true,
185
+ regex: '^_id$',
186
+ },
187
+ format: null,
188
+ leadingUnderscore: 'allow',
189
+ selector: 'typeProperty',
190
+ trailingUnderscore: 'forbid',
191
+ },
192
+ ],
193
+ '@typescript-eslint/no-base-to-string': 0,
194
+ '@typescript-eslint/no-empty-function': [
195
+ 2,
196
+ {
197
+ allow: [
198
+ 'constructors',
199
+ 'private-constructors',
200
+ 'protected-constructors',
201
+ 'decoratedFunctions',
202
+ 'overrideMethods',
203
+ 'setters',
204
+ ]
205
+ }
170
206
  ],
171
207
  '@typescript-eslint/no-explicit-any': 2,
172
208
  '@typescript-eslint/no-floating-promises': 0,
@@ -197,18 +233,6 @@ module.exports = {
197
233
  },
198
234
  ],
199
235
  '@typescript-eslint/return-await': [2, 'in-try-catch'],
200
- 'arrow-parens': [
201
- 1,
202
- 'always',
203
- {
204
- requireForBlockBody: true,
205
- },
206
- ],
207
- 'class-methods-use-this': 0,
208
- 'comma-dangle': 0,
209
- complexity: [2, { max: 10 }],
210
- 'function-paren-newline': 0,
211
- 'implicit-arrow-linebreak': 0,
212
236
  'import/default': 2,
213
237
  'import/export': 2,
214
238
  'import/first': 2,
@@ -225,53 +249,6 @@ module.exports = {
225
249
  'import/order': 0,
226
250
  'import/prefer-default-export': 0,
227
251
  'max-classes-per-file': 0,
228
- 'max-lines': [
229
- 2,
230
- {
231
- max: 500,
232
- skipBlankLines: false,
233
- skipComments: true,
234
- },
235
- ],
236
- 'max-lines-per-function': [
237
- 2,
238
- {
239
- max: 200,
240
- skipBlankLines: false,
241
- skipComments: true,
242
- },
243
- ],
244
- 'max-params': [2, { max: 3 }],
245
- 'no-await-in-loop': 0,
246
- 'no-continue': 0,
247
- 'no-plusplus': [
248
- 2,
249
- {
250
- allowForLoopAfterthoughts: true,
251
- },
252
- ],
253
- 'no-promise-executor-return': 0,
254
- 'no-restricted-syntax': 0,
255
- 'padding-line-between-statements': [
256
- 2,
257
- {
258
- blankLine: 'always',
259
- next: '*',
260
- prev: ['block-like'],
261
- },
262
- {
263
- blankLine: 'always',
264
- next: 'if',
265
- prev: '*',
266
- },
267
- {
268
- blankLine: 'always',
269
- next: '*',
270
- prev: 'if',
271
- },
272
- ],
273
- 'react/jsx-filename-extension': 0,
274
- 'require-await': 0,
275
252
  'simple-import-sort/imports': [
276
253
  2,
277
254
  {
@@ -295,7 +272,6 @@ module.exports = {
295
272
  },
296
273
  ],
297
274
  'sort-imports': 0,
298
- 'sort-keys': 2,
299
275
  'typescript-sort/interface': 2,
300
276
  'typescript-sort/type': 2,
301
277
  'typescript-sort/enum': 2,
package/eslint/node.js ADDED
@@ -0,0 +1,91 @@
1
+ module.exports = {
2
+ env: {
3
+ browser: false,
4
+ es6: true,
5
+ jest: true,
6
+ 'jest/globals': true,
7
+ node: true,
8
+ },
9
+ extends: [
10
+ 'eslint:recommended',
11
+ 'plugin:jest/recommended',
12
+ 'plugin:jest/style',
13
+ 'prettier',
14
+ 'plugin:prettier/recommended',
15
+ ],
16
+ plugins: ['jest'],
17
+ rules: {
18
+ 'arrow-parens': [
19
+ 1,
20
+ 'always',
21
+ {
22
+ requireForBlockBody: true,
23
+ },
24
+ ],
25
+ 'class-methods-use-this': 0,
26
+ 'comma-dangle': [
27
+ 'error',
28
+ {
29
+ arrays: 'always-multiline',
30
+ exports: 'always-multiline',
31
+ functions: 'always-multiline',
32
+ imports: 'always-multiline',
33
+ objects: 'always-multiline',
34
+ },
35
+ ],
36
+ complexity: [2, { max: 10 }],
37
+ 'function-paren-newline': 0,
38
+ 'implicit-arrow-linebreak': 0,
39
+ 'max-lines': [
40
+ 2,
41
+ {
42
+ max: 500,
43
+ skipBlankLines: false,
44
+ skipComments: true,
45
+ },
46
+ ],
47
+ 'max-lines-per-function': [
48
+ 2,
49
+ {
50
+ max: 200,
51
+ skipBlankLines: false,
52
+ skipComments: true,
53
+ },
54
+ ],
55
+ 'max-params': [2, { max: 3 }],
56
+ 'no-await-in-loop': 0,
57
+ 'no-continue': 0,
58
+ 'no-empty-function': 0,
59
+ 'no-plusplus': [
60
+ 2,
61
+ {
62
+ allowForLoopAfterthoughts: true,
63
+ },
64
+ ],
65
+ 'no-promise-executor-return': 0,
66
+ 'no-restricted-syntax': 0,
67
+ 'padding-line-between-statements': [
68
+ 2,
69
+ {
70
+ blankLine: 'always',
71
+ next: '*',
72
+ prev: ['block-like'],
73
+ },
74
+ {
75
+ blankLine: 'always',
76
+ next: 'if',
77
+ prev: '*',
78
+ },
79
+ {
80
+ blankLine: 'always',
81
+ next: '*',
82
+ prev: 'if',
83
+ },
84
+ ],
85
+ 'react/jsx-filename-extension': 0,
86
+ 'require-await': 0,
87
+ 'sort-imports': 2,
88
+ 'sort-keys': 2,
89
+ },
90
+ };
91
+
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zalib/linter",
3
- "version": "1.0.9",
3
+ "version": "1.1.0",
4
4
  "description": "Linter configs",
5
5
  "author": "https://github.com/wsp-repo/",
6
6
  "license": "UNLICENSED",
@@ -17,7 +17,7 @@
17
17
  "bugs": {
18
18
  "url": "https://github.com/wsp-repo/linter/issues"
19
19
  },
20
- "devDependencies": {
20
+ "peerDependencies": {
21
21
  "@typescript-eslint/eslint-plugin": "7.18.0",
22
22
  "@typescript-eslint/parser": "7.18.0",
23
23
  "eslint": "8.57.1",
package/eslint/js.js DELETED
@@ -1,94 +0,0 @@
1
- module.exports = {
2
- env: {
3
- browser: false,
4
- es6: true,
5
- jest: true,
6
- 'jest/globals': true,
7
- node: true,
8
- },
9
- extends: [
10
- 'airbnb-base',
11
- 'eslint:recommended',
12
- 'plugin:jest/recommended',
13
- 'plugin:jest/style',
14
- 'prettier',
15
- 'plugin:prettier/recommended',
16
- ],
17
- files: ['*.js'],
18
- plugins: ['jest'],
19
- rules: {
20
- 'arrow-parens': [
21
- 1,
22
- 'always',
23
- {
24
- requireForBlockBody: true,
25
- },
26
- ],
27
- 'class-methods-use-this': 0,
28
- 'comma-dangle': [
29
- 'error',
30
- {
31
- arrays: 'always-multiline',
32
- exports: 'always-multiline',
33
- functions: 'always-multiline',
34
- imports: 'always-multiline',
35
- objects: 'always-multiline',
36
- },
37
- ],
38
- complexity: [2, { max: 10 }],
39
- 'function-paren-newline': 0,
40
- 'implicit-arrow-linebreak': 0,
41
- 'import/extensions': 0,
42
- 'import/no-unresolved': 0,
43
- 'max-lines': [
44
- 2,
45
- {
46
- max: 500,
47
- skipBlankLines: false,
48
- skipComments: true,
49
- },
50
- ],
51
- 'max-lines-per-function': [
52
- 2,
53
- {
54
- max: 200,
55
- skipBlankLines: false,
56
- skipComments: true,
57
- },
58
- ],
59
- 'max-params': [2, { max: 3 }],
60
- 'no-await-in-loop': 0,
61
- 'no-continue': 0,
62
- 'no-plusplus': [
63
- 2,
64
- {
65
- allowForLoopAfterthoughts: true,
66
- },
67
- ],
68
- 'no-promise-executor-return': 0,
69
- 'no-restricted-syntax': 0,
70
- 'padding-line-between-statements': [
71
- 2,
72
- {
73
- blankLine: 'always',
74
- next: '*',
75
- prev: ['block-like'],
76
- },
77
- {
78
- blankLine: 'always',
79
- next: 'if',
80
- prev: '*',
81
- },
82
- {
83
- blankLine: 'always',
84
- next: '*',
85
- prev: 'if',
86
- },
87
- ],
88
- 'react/jsx-filename-extension': 0,
89
- 'require-await': 1,
90
- 'sort-imports': 2,
91
- 'sort-keys': 2,
92
- strict: 0,
93
- },
94
- };