@tinkoff/eslint-config 1.13.0 → 1.22.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/CHANGELOG.md +34 -0
- package/README.md +12 -12
- package/app.js +3 -3
- package/index.js +13 -13
- package/internal/base.js +83 -79
- package/internal/import.js +29 -29
- package/internal/prettier.js +1 -1
- package/internal/promise.js +7 -7
- package/internal/sort-class-members.js +54 -54
- package/internal/test-files.js +14 -14
- package/internal/typescript.js +139 -139
- package/jest.js +13 -13
- package/lib.js +8 -8
- package/package.json +41 -41
- package/test/index.test.js +40 -34
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,40 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [1.22.0](https://github.com/TinkoffCreditSystems/linters/compare/v1.21.0...v1.22.0) (2021-12-09)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* **prettier-config:** upgrade to new prettier version ([#161](https://github.com/TinkoffCreditSystems/linters/issues/161)) ([419597f](https://github.com/TinkoffCreditSystems/linters/commit/419597f313bdd46f3b71e14779d55a7c7dd6a0ee))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
## [1.14.0](https://github.com/TinkoffCreditSystems/linters/compare/v1.13.2...v1.14.0) (2021-11-17)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
### Features
|
|
19
|
+
|
|
20
|
+
* **eslint-config-angular:** support member ordering ([a57a57d](https://github.com/TinkoffCreditSystems/linters/commit/a57a57d68d8b624da95f6b93d577f4d2adea0fd0))
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
### [1.13.2](https://github.com/TinkoffCreditSystems/linters/compare/v1.13.1...v1.13.2) (2021-11-17)
|
|
25
|
+
|
|
26
|
+
**Note:** Version bump only for package @tinkoff/eslint-config
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
### [1.13.1](https://github.com/TinkoffCreditSystems/linters/compare/v1.13.0...v1.13.1) (2021-11-17)
|
|
33
|
+
|
|
34
|
+
**Note:** Version bump only for package @tinkoff/eslint-config
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
|
|
6
40
|
## [1.13.0](https://github.com/TinkoffCreditSystems/linters/compare/v1.12.2...v1.13.0) (2021-11-10)
|
|
7
41
|
|
|
8
42
|
|
package/README.md
CHANGED
|
@@ -46,27 +46,27 @@ necessary additional configs. Package include `eslint@7` and `prettier@2` depend
|
|
|
46
46
|
|
|
47
47
|
Main configurations sets contains common rules
|
|
48
48
|
|
|
49
|
-
-
|
|
50
|
-
-
|
|
49
|
+
- `@tinkoff/eslint-config/app` - common rules and specific rules for applications
|
|
50
|
+
- `@tinkoff/eslint-config/lib` - common rules and specific rules for libraries
|
|
51
51
|
|
|
52
52
|
Additional configurations sets. This configs **not** contain common eslint rules, and must be included with main
|
|
53
53
|
configurations
|
|
54
54
|
|
|
55
|
-
-
|
|
55
|
+
- `@tinkoff/eslint-config/jest` - rules for lint Jest test suits
|
|
56
56
|
|
|
57
57
|
## Internal used plugins
|
|
58
58
|
|
|
59
59
|
`@tinkoff/eslint-config/app` and `@tinkoff/eslint-config/lib` include:
|
|
60
60
|
|
|
61
|
-
-
|
|
62
|
-
-
|
|
63
|
-
-
|
|
64
|
-
-
|
|
65
|
-
-
|
|
66
|
-
-
|
|
67
|
-
|
|
68
|
-
-
|
|
69
|
-
|
|
61
|
+
- `eslint-config-airbnb` - common and popular configuration
|
|
62
|
+
- `eslint-plugin-eslint-comments` - validate `eslint` comments
|
|
63
|
+
- `eslint-plugin-import` - validate proper imports
|
|
64
|
+
- `eslint-plugin-promise` - enforce best practices for promises
|
|
65
|
+
- `eslint-plugin-jest` - validate jest tests
|
|
66
|
+
- `@typescript-eslint/eslint-plugin` - lint TypeScript files, adopt many eslint rules to TS code, and provide specific
|
|
67
|
+
TS rules
|
|
68
|
+
- `eslint-plugin-prettier` - disable code formatting using eslint tools and transfers all the logic to a prettier, and
|
|
69
|
+
report differences as eslint issues
|
|
70
70
|
|
|
71
71
|
## Troubleshooting
|
|
72
72
|
|
package/app.js
CHANGED
package/index.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
module.exports = {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
2
|
+
extends: [
|
|
3
|
+
'./internal/base',
|
|
4
|
+
'./internal/sort-class-members',
|
|
5
|
+
'./internal/import',
|
|
6
|
+
'./internal/promise',
|
|
7
|
+
'./internal/test-files',
|
|
8
|
+
'./internal/typescript',
|
|
9
|
+
'./internal/prettier',
|
|
10
|
+
],
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
env: {
|
|
13
|
+
browser: true,
|
|
14
|
+
node: true,
|
|
15
|
+
},
|
|
16
16
|
};
|
package/internal/base.js
CHANGED
|
@@ -1,87 +1,91 @@
|
|
|
1
1
|
module.exports = {
|
|
2
|
-
|
|
2
|
+
extends: ['eslint-config-airbnb-base', 'plugin:eslint-comments/recommended'],
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
parser: '@babel/eslint-parser',
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
settings: {
|
|
7
|
+
'import/parser': '@babel/eslint-parser',
|
|
8
|
+
},
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
plugins: ['@babel'],
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
},
|
|
12
|
+
parserOptions: {
|
|
13
|
+
ecmaFeatures: {
|
|
14
|
+
legacyDecorators: true,
|
|
16
15
|
},
|
|
16
|
+
},
|
|
17
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
|
-
|
|
18
|
+
rules: {
|
|
19
|
+
'no-unused-expressions': [
|
|
20
|
+
'error',
|
|
21
|
+
{
|
|
22
|
+
allowShortCircuit: true,
|
|
23
|
+
allowTernary: true,
|
|
24
|
+
},
|
|
25
|
+
],
|
|
26
|
+
'no-use-before-define': [
|
|
27
|
+
'error',
|
|
28
|
+
{
|
|
29
|
+
functions: false,
|
|
30
|
+
classes: false,
|
|
31
|
+
variables: true,
|
|
32
|
+
},
|
|
33
|
+
],
|
|
34
|
+
'func-name-matching': 'off',
|
|
35
|
+
'global-require': 'off',
|
|
36
|
+
'class-methods-use-this': 'off',
|
|
37
|
+
'no-continue': 'off',
|
|
38
|
+
'no-restricted-syntax': [
|
|
39
|
+
'warn',
|
|
40
|
+
{
|
|
41
|
+
selector: 'LabeledStatement',
|
|
42
|
+
message:
|
|
43
|
+
'Labels are a form of GOTO; using them makes code confusing and hard to maintain and understand.',
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
selector: 'WithStatement',
|
|
47
|
+
message:
|
|
48
|
+
'`with` is disallowed in strict mode because it makes code impossible to predict and optimize.',
|
|
49
|
+
},
|
|
50
|
+
],
|
|
51
|
+
'guard-for-in': 'off',
|
|
52
|
+
'default-case': 'warn',
|
|
53
|
+
'no-plusplus': ['warn', { allowForLoopAfterthoughts: true }],
|
|
54
|
+
'consistent-return': 'warn',
|
|
55
|
+
'vars-on-top': 'warn',
|
|
56
|
+
'no-var': 'warn',
|
|
57
|
+
camelcase: [
|
|
58
|
+
'warn',
|
|
59
|
+
{
|
|
60
|
+
allow: ['^UNSAFE_'],
|
|
61
|
+
ignoreDestructuring: false,
|
|
62
|
+
properties: 'never',
|
|
63
|
+
},
|
|
64
|
+
],
|
|
65
|
+
'func-style': [
|
|
66
|
+
'error',
|
|
67
|
+
'declaration',
|
|
68
|
+
{
|
|
69
|
+
allowArrowFunctions: true,
|
|
70
|
+
},
|
|
71
|
+
],
|
|
72
|
+
'max-depth': ['warn', 4],
|
|
73
|
+
'max-params': ['warn', 4],
|
|
74
|
+
'max-classes-per-file': ['error', 4],
|
|
75
|
+
complexity: ['error', 25],
|
|
76
|
+
'max-statements': ['error', 25],
|
|
77
|
+
'no-empty': ['error', { allowEmptyCatch: true }],
|
|
78
|
+
'no-underscore-dangle': 'off',
|
|
79
|
+
'no-return-assign': ['error', 'except-parens'],
|
|
80
|
+
'lines-between-class-members': [
|
|
81
|
+
'error',
|
|
82
|
+
'always',
|
|
83
|
+
{ exceptAfterSingleLine: true },
|
|
84
|
+
],
|
|
85
|
+
'spaced-comment': ['error', 'always', { exceptions: ['*'] }],
|
|
86
|
+
'max-nested-callbacks': ['error', 4],
|
|
87
|
+
'no-bitwise': 'warn',
|
|
88
|
+
'no-useless-escape': 'warn',
|
|
89
|
+
'no-await-in-loop': 'off',
|
|
90
|
+
},
|
|
87
91
|
};
|
package/internal/import.js
CHANGED
|
@@ -1,34 +1,34 @@
|
|
|
1
1
|
module.exports = {
|
|
2
|
-
|
|
2
|
+
plugins: ['import'],
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
},
|
|
4
|
+
settings: {
|
|
5
|
+
'import/resolver': {
|
|
6
|
+
node: {
|
|
7
|
+
extensions: ['.js', '.ts'],
|
|
8
|
+
},
|
|
9
|
+
typescript: {},
|
|
10
|
+
webpack: {},
|
|
12
11
|
},
|
|
12
|
+
},
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
14
|
+
rules: {
|
|
15
|
+
'import/no-commonjs': 'off',
|
|
16
|
+
'import/unambiguous': 'off',
|
|
17
|
+
'import/no-deprecated': 'warn',
|
|
18
|
+
'import/prefer-default-export': 'off', // default imports is evil
|
|
19
|
+
'import/default': 'error', // enable default import validation
|
|
20
|
+
'import/extensions': [
|
|
21
|
+
'error',
|
|
22
|
+
'always',
|
|
23
|
+
{
|
|
24
|
+
js: 'never',
|
|
25
|
+
jsx: 'never',
|
|
26
|
+
ts: 'never',
|
|
27
|
+
tsx: 'never',
|
|
28
|
+
},
|
|
29
|
+
],
|
|
30
|
+
'import/order': ['warn', { groups: [['builtin', 'external', 'internal']] }],
|
|
31
|
+
'import/no-extraneous-dependencies': 'off', // need fine tuning
|
|
32
|
+
'import/no-cycle': 'off',
|
|
33
|
+
},
|
|
34
34
|
};
|
package/internal/prettier.js
CHANGED
package/internal/promise.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
module.exports = {
|
|
2
|
-
|
|
2
|
+
extends: ['plugin:promise/recommended'],
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
4
|
+
rules: {
|
|
5
|
+
'promise/always-return': 'off',
|
|
6
|
+
'promise/no-callback-in-promise': 'off',
|
|
7
|
+
'promise/catch-or-return': 'warn',
|
|
8
|
+
'promise/param-names': 'warn',
|
|
9
|
+
},
|
|
10
10
|
};
|
|
@@ -1,58 +1,58 @@
|
|
|
1
1
|
module.exports = {
|
|
2
|
-
|
|
2
|
+
plugins: ['sort-class-members'],
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
],
|
|
20
|
-
groups: {
|
|
21
|
-
'static-members': [{static: true}],
|
|
22
|
-
handlers: [
|
|
23
|
-
{name: '/^on.+$/', type: 'method'},
|
|
24
|
-
{name: '/^on.+$/', type: 'property'},
|
|
25
|
-
{name: '/^handle.+$/', type: 'method'},
|
|
26
|
-
{name: '/^handle.+$/', type: 'property'},
|
|
27
|
-
],
|
|
28
|
-
lifecycle: [
|
|
29
|
-
'displayName',
|
|
30
|
-
'propTypes',
|
|
31
|
-
'contextTypes',
|
|
32
|
-
'childContextTypes',
|
|
33
|
-
'defaultProps',
|
|
34
|
-
'getDefaultProps',
|
|
35
|
-
'getInitialState',
|
|
36
|
-
'getChildContext',
|
|
37
|
-
'getDerivedStateFromProps',
|
|
38
|
-
'componentWillMount',
|
|
39
|
-
'UNSAFE_componentWillMount',
|
|
40
|
-
'componentDidMount',
|
|
41
|
-
'componentWillReceiveProps',
|
|
42
|
-
'UNSAFE_componentWillReceiveProps',
|
|
43
|
-
'shouldComponentUpdate',
|
|
44
|
-
'componentWillUpdate',
|
|
45
|
-
'UNSAFE_componentWillUpdate',
|
|
46
|
-
'getSnapshotBeforeUpdate',
|
|
47
|
-
'componentDidUpdate',
|
|
48
|
-
'componentDidCatch',
|
|
49
|
-
'componentWillUnmount',
|
|
50
|
-
'componentDidCatch',
|
|
51
|
-
],
|
|
52
|
-
rendering: ['/^render.+$/', 'render'],
|
|
53
|
-
},
|
|
54
|
-
accessorPairPositioning: 'getThenSet',
|
|
55
|
-
},
|
|
4
|
+
rules: {
|
|
5
|
+
'sort-class-members/sort-class-members': [
|
|
6
|
+
'error',
|
|
7
|
+
{
|
|
8
|
+
order: [
|
|
9
|
+
'[static-members]',
|
|
10
|
+
'[properties]',
|
|
11
|
+
'[conventional-private-properties]',
|
|
12
|
+
'constructor',
|
|
13
|
+
'[lifecycle]',
|
|
14
|
+
'[handlers]',
|
|
15
|
+
'[methods]',
|
|
16
|
+
'[conventional-private-methods]',
|
|
17
|
+
'[rendering]',
|
|
18
|
+
'[everything-else]',
|
|
56
19
|
],
|
|
57
|
-
|
|
20
|
+
groups: {
|
|
21
|
+
'static-members': [{ static: true }],
|
|
22
|
+
handlers: [
|
|
23
|
+
{ name: '/^on.+$/', type: 'method' },
|
|
24
|
+
{ name: '/^on.+$/', type: 'property' },
|
|
25
|
+
{ name: '/^handle.+$/', type: 'method' },
|
|
26
|
+
{ name: '/^handle.+$/', type: 'property' },
|
|
27
|
+
],
|
|
28
|
+
lifecycle: [
|
|
29
|
+
'displayName',
|
|
30
|
+
'propTypes',
|
|
31
|
+
'contextTypes',
|
|
32
|
+
'childContextTypes',
|
|
33
|
+
'defaultProps',
|
|
34
|
+
'getDefaultProps',
|
|
35
|
+
'getInitialState',
|
|
36
|
+
'getChildContext',
|
|
37
|
+
'getDerivedStateFromProps',
|
|
38
|
+
'componentWillMount',
|
|
39
|
+
'UNSAFE_componentWillMount',
|
|
40
|
+
'componentDidMount',
|
|
41
|
+
'componentWillReceiveProps',
|
|
42
|
+
'UNSAFE_componentWillReceiveProps',
|
|
43
|
+
'shouldComponentUpdate',
|
|
44
|
+
'componentWillUpdate',
|
|
45
|
+
'UNSAFE_componentWillUpdate',
|
|
46
|
+
'getSnapshotBeforeUpdate',
|
|
47
|
+
'componentDidUpdate',
|
|
48
|
+
'componentDidCatch',
|
|
49
|
+
'componentWillUnmount',
|
|
50
|
+
'componentDidCatch',
|
|
51
|
+
],
|
|
52
|
+
rendering: ['/^render.+$/', 'render'],
|
|
53
|
+
},
|
|
54
|
+
accessorPairPositioning: 'getThenSet',
|
|
55
|
+
},
|
|
56
|
+
],
|
|
57
|
+
},
|
|
58
58
|
};
|
package/internal/test-files.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
module.exports = {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
overrides: [
|
|
3
|
+
{
|
|
4
|
+
files: ['*.spec.*', '*.test.*', '*.unit.*', '*/__tests__/*'],
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
6
|
+
rules: {
|
|
7
|
+
'@typescript-eslint/no-empty-function': 'off',
|
|
8
|
+
'max-statements': 'off',
|
|
9
|
+
'max-classes-per-file': 'off',
|
|
10
|
+
'max-nested-callbacks': ['warn', 10],
|
|
11
|
+
'prefer-promise-reject-errors': 'warn',
|
|
12
|
+
'import/no-unresolved': 'off',
|
|
13
|
+
'import/extensions': 'off',
|
|
14
|
+
},
|
|
15
|
+
},
|
|
16
|
+
],
|
|
17
17
|
};
|
package/internal/typescript.js
CHANGED
|
@@ -1,147 +1,147 @@
|
|
|
1
1
|
module.exports = {
|
|
2
|
-
|
|
2
|
+
extends: ['plugin:@typescript-eslint/eslint-recommended'],
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
4
|
+
overrides: [
|
|
5
|
+
{
|
|
6
|
+
extends: [
|
|
7
|
+
'plugin:@typescript-eslint/recommended',
|
|
8
|
+
'prettier/@typescript-eslint',
|
|
9
|
+
'plugin:import/typescript',
|
|
10
|
+
],
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
parser: '@typescript-eslint/parser',
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
plugins: ['@typescript-eslint'],
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
files: ['*.ts', '*.tsx'],
|
|
17
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
|
-
extendDefaults: false,
|
|
68
|
-
},
|
|
69
|
-
],
|
|
70
|
-
'@typescript-eslint/no-extraneous-class': [
|
|
71
|
-
'error',
|
|
72
|
-
{
|
|
73
|
-
allowWithDecorator: true,
|
|
74
|
-
allowStaticOnly: true,
|
|
75
|
-
},
|
|
76
|
-
],
|
|
77
|
-
// '@typescript-eslint/no-unnecessary-qualifier': 'error', need ts config
|
|
78
|
-
// '@typescript-eslint/restrict-plus-operands': 'error', need ts config
|
|
79
|
-
'@typescript-eslint/no-explicit-any': 'off',
|
|
80
|
-
camelcase: 'off',
|
|
81
|
-
'@typescript-eslint/camelcase': 'off',
|
|
82
|
-
'@typescript-eslint/naming-convention': [
|
|
83
|
-
'error',
|
|
84
|
-
{
|
|
85
|
-
selector: 'default',
|
|
86
|
-
format: ['camelCase', 'PascalCase'],
|
|
87
|
-
leadingUnderscore: 'allow',
|
|
88
|
-
trailingUnderscore: 'allow',
|
|
89
|
-
},
|
|
90
|
-
{
|
|
91
|
-
selector: 'variable',
|
|
92
|
-
format: ['camelCase', 'PascalCase', 'UPPER_CASE'],
|
|
93
|
-
leadingUnderscore: 'allow',
|
|
94
|
-
trailingUnderscore: 'allow',
|
|
95
|
-
},
|
|
96
|
-
{
|
|
97
|
-
selector: 'typeLike',
|
|
98
|
-
format: ['PascalCase', 'UPPER_CASE'],
|
|
99
|
-
},
|
|
100
|
-
{
|
|
101
|
-
selector: 'property',
|
|
102
|
-
format: ['camelCase', 'PascalCase'],
|
|
103
|
-
},
|
|
104
|
-
],
|
|
105
|
-
'@typescript-eslint/ban-ts-comment': 'warn',
|
|
106
|
-
'@typescript-eslint/no-empty-function': 'warn',
|
|
107
|
-
// standard no-unused-expressions don't understand optional chaining from ts
|
|
108
|
-
'no-unused-expressions': 'off',
|
|
109
|
-
'@typescript-eslint/no-unused-expressions': [
|
|
110
|
-
'error',
|
|
111
|
-
{
|
|
112
|
-
allowShortCircuit: true,
|
|
113
|
-
allowTernary: true,
|
|
114
|
-
},
|
|
115
|
-
],
|
|
116
|
-
'@typescript-eslint/no-var-requires': 'warn',
|
|
117
|
-
'@typescript-eslint/no-namespace': 'off',
|
|
118
|
-
'no-use-before-define': 'off',
|
|
119
|
-
'@typescript-eslint/no-use-before-define': [
|
|
120
|
-
'error',
|
|
121
|
-
{
|
|
122
|
-
functions: false,
|
|
123
|
-
classes: false,
|
|
124
|
-
variables: true,
|
|
125
|
-
enums: true,
|
|
126
|
-
typedefs: true,
|
|
127
|
-
},
|
|
128
|
-
],
|
|
129
|
-
'@typescript-eslint/explicit-module-boundary-types': 'off',
|
|
130
|
-
'consistent-return': 'off',
|
|
131
|
-
'@typescript-eslint/consistent-type-imports': [
|
|
132
|
-
'warn',
|
|
133
|
-
{
|
|
134
|
-
prefer: 'type-imports',
|
|
135
|
-
disallowTypeAnnotations: true,
|
|
136
|
-
},
|
|
137
|
-
],
|
|
138
|
-
'no-shadow': 'off',
|
|
139
|
-
'@typescript-eslint/no-shadow': ['warn'],
|
|
140
|
-
// conflict with import type statement, try to merge default and named imports
|
|
141
|
-
// https://github.com/typescript-eslint/typescript-eslint/issues/2545#issuecomment-692842483
|
|
142
|
-
// https://github.com/import-js/eslint-plugin-import/issues/2114
|
|
143
|
-
'import/no-duplicates': 'off',
|
|
18
|
+
rules: {
|
|
19
|
+
// swears on cases like constructor(public c: C) {}
|
|
20
|
+
'no-useless-constructor': 'off',
|
|
21
|
+
'@typescript-eslint/explicit-function-return-type': 'off',
|
|
22
|
+
'no-unused-vars': 'off',
|
|
23
|
+
'@typescript-eslint/no-unused-vars': [
|
|
24
|
+
'warn',
|
|
25
|
+
{
|
|
26
|
+
argsIgnorePattern: '^_',
|
|
27
|
+
varsIgnorePattern: '^_',
|
|
28
|
+
},
|
|
29
|
+
],
|
|
30
|
+
'class-methods-use-this': 'off',
|
|
31
|
+
'@typescript-eslint/member-ordering': [
|
|
32
|
+
'off',
|
|
33
|
+
{
|
|
34
|
+
default: [
|
|
35
|
+
'public-static-field',
|
|
36
|
+
'protected-static-field',
|
|
37
|
+
'private-static-field',
|
|
38
|
+
'public-static-method',
|
|
39
|
+
'protected-static-method',
|
|
40
|
+
'private-static-method',
|
|
41
|
+
'public-instance-field',
|
|
42
|
+
'protected-instance-field',
|
|
43
|
+
'private-instance-field',
|
|
44
|
+
'constructor',
|
|
45
|
+
'public-instance-method',
|
|
46
|
+
'protected-instance-method',
|
|
47
|
+
'private-instance-method',
|
|
48
|
+
],
|
|
49
|
+
},
|
|
50
|
+
],
|
|
51
|
+
'@typescript-eslint/ban-types': [
|
|
52
|
+
'error',
|
|
53
|
+
{
|
|
54
|
+
types: {
|
|
55
|
+
String: { message: 'Use string instead', fixWith: 'string' },
|
|
56
|
+
Boolean: { message: 'Use boolean instead', fixWith: 'boolean' },
|
|
57
|
+
Number: { message: 'Use number instead', fixWith: 'number' },
|
|
58
|
+
Object: {
|
|
59
|
+
message: 'Use Record<string, any> instead',
|
|
60
|
+
fixWith: 'Record<string, any>',
|
|
61
|
+
},
|
|
62
|
+
object: {
|
|
63
|
+
message: 'Use Record<string, any> instead',
|
|
64
|
+
fixWith: 'Record<string, any>',
|
|
65
|
+
},
|
|
144
66
|
},
|
|
145
|
-
|
|
146
|
-
|
|
67
|
+
extendDefaults: false,
|
|
68
|
+
},
|
|
69
|
+
],
|
|
70
|
+
'@typescript-eslint/no-extraneous-class': [
|
|
71
|
+
'error',
|
|
72
|
+
{
|
|
73
|
+
allowWithDecorator: true,
|
|
74
|
+
allowStaticOnly: true,
|
|
75
|
+
},
|
|
76
|
+
],
|
|
77
|
+
// '@typescript-eslint/no-unnecessary-qualifier': 'error', need ts config
|
|
78
|
+
// '@typescript-eslint/restrict-plus-operands': 'error', need ts config
|
|
79
|
+
'@typescript-eslint/no-explicit-any': 'off',
|
|
80
|
+
camelcase: 'off',
|
|
81
|
+
'@typescript-eslint/camelcase': 'off',
|
|
82
|
+
'@typescript-eslint/naming-convention': [
|
|
83
|
+
'error',
|
|
84
|
+
{
|
|
85
|
+
selector: 'default',
|
|
86
|
+
format: ['camelCase', 'PascalCase'],
|
|
87
|
+
leadingUnderscore: 'allow',
|
|
88
|
+
trailingUnderscore: 'allow',
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
selector: 'variable',
|
|
92
|
+
format: ['camelCase', 'PascalCase', 'UPPER_CASE'],
|
|
93
|
+
leadingUnderscore: 'allow',
|
|
94
|
+
trailingUnderscore: 'allow',
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
selector: 'typeLike',
|
|
98
|
+
format: ['PascalCase', 'UPPER_CASE'],
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
selector: 'property',
|
|
102
|
+
format: ['camelCase', 'PascalCase'],
|
|
103
|
+
},
|
|
104
|
+
],
|
|
105
|
+
'@typescript-eslint/ban-ts-comment': 'warn',
|
|
106
|
+
'@typescript-eslint/no-empty-function': 'warn',
|
|
107
|
+
// standard no-unused-expressions don't understand optional chaining from ts
|
|
108
|
+
'no-unused-expressions': 'off',
|
|
109
|
+
'@typescript-eslint/no-unused-expressions': [
|
|
110
|
+
'error',
|
|
111
|
+
{
|
|
112
|
+
allowShortCircuit: true,
|
|
113
|
+
allowTernary: true,
|
|
114
|
+
},
|
|
115
|
+
],
|
|
116
|
+
'@typescript-eslint/no-var-requires': 'warn',
|
|
117
|
+
'@typescript-eslint/no-namespace': 'off',
|
|
118
|
+
'no-use-before-define': 'off',
|
|
119
|
+
'@typescript-eslint/no-use-before-define': [
|
|
120
|
+
'error',
|
|
121
|
+
{
|
|
122
|
+
functions: false,
|
|
123
|
+
classes: false,
|
|
124
|
+
variables: true,
|
|
125
|
+
enums: true,
|
|
126
|
+
typedefs: true,
|
|
127
|
+
},
|
|
128
|
+
],
|
|
129
|
+
'@typescript-eslint/explicit-module-boundary-types': 'off',
|
|
130
|
+
'consistent-return': 'off',
|
|
131
|
+
'@typescript-eslint/consistent-type-imports': [
|
|
132
|
+
'warn',
|
|
133
|
+
{
|
|
134
|
+
prefer: 'type-imports',
|
|
135
|
+
disallowTypeAnnotations: true,
|
|
136
|
+
},
|
|
137
|
+
],
|
|
138
|
+
'no-shadow': 'off',
|
|
139
|
+
'@typescript-eslint/no-shadow': ['warn'],
|
|
140
|
+
// conflict with import type statement, try to merge default and named imports
|
|
141
|
+
// https://github.com/typescript-eslint/typescript-eslint/issues/2545#issuecomment-692842483
|
|
142
|
+
// https://github.com/import-js/eslint-plugin-import/issues/2114
|
|
143
|
+
'import/no-duplicates': 'off',
|
|
144
|
+
},
|
|
145
|
+
},
|
|
146
|
+
],
|
|
147
147
|
};
|
package/jest.js
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
module.exports = {
|
|
2
|
-
|
|
2
|
+
extends: ['plugin:jest/recommended'],
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
plugins: [],
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
],
|
|
15
|
-
},
|
|
6
|
+
rules: {
|
|
7
|
+
'jest/expect-expect': [
|
|
8
|
+
'warn',
|
|
9
|
+
{
|
|
10
|
+
assertFunctionNames: [
|
|
11
|
+
'expect',
|
|
12
|
+
// support superagent library
|
|
13
|
+
'request.**.expect',
|
|
16
14
|
],
|
|
17
|
-
|
|
15
|
+
},
|
|
16
|
+
],
|
|
17
|
+
},
|
|
18
18
|
};
|
package/lib.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
module.exports = {
|
|
2
|
-
|
|
2
|
+
extends: ['./index'],
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
plugins: [],
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
6
|
+
rules: {
|
|
7
|
+
'import/no-dynamic-require': 'off',
|
|
8
|
+
'import/no-deprecated': 'off',
|
|
9
|
+
'@typescript-eslint/no-var-requires': 'off',
|
|
10
|
+
'@typescript-eslint/no-empty-function': 'off',
|
|
11
|
+
},
|
|
12
12
|
};
|
package/package.json
CHANGED
|
@@ -1,43 +1,43 @@
|
|
|
1
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
|
-
|
|
2
|
+
"name": "@tinkoff/eslint-config",
|
|
3
|
+
"version": "1.22.0",
|
|
4
|
+
"description": "Tinkoff ESLint configs to rule them all",
|
|
5
|
+
"license": "Apache-2.0",
|
|
6
|
+
"keywords": [
|
|
7
|
+
"eslint",
|
|
8
|
+
"eslintconfig",
|
|
9
|
+
"eslint-config"
|
|
10
|
+
],
|
|
11
|
+
"scripts": {},
|
|
12
|
+
"main": "index.js",
|
|
13
|
+
"author": {
|
|
14
|
+
"name": "Tinkoff Team",
|
|
15
|
+
"email": "frontend@tinkoff.ru"
|
|
16
|
+
},
|
|
17
|
+
"repository": {
|
|
18
|
+
"type": "git",
|
|
19
|
+
"url": "https://github.com/TinkoffCreditSystems/linters.git"
|
|
20
|
+
},
|
|
21
|
+
"dependencies": {
|
|
22
|
+
"@babel/eslint-parser": "^7.14.7",
|
|
23
|
+
"@babel/eslint-plugin": "^7.14.5",
|
|
24
|
+
"@typescript-eslint/eslint-plugin": "^5.4.0",
|
|
25
|
+
"@typescript-eslint/parser": "^5.4.0",
|
|
26
|
+
"eslint": "^7.5.0",
|
|
27
|
+
"eslint-config-airbnb-base": "^14.2.0",
|
|
28
|
+
"eslint-config-prettier": "^6.11.0",
|
|
29
|
+
"eslint-import-resolver-typescript": "^2.0.0",
|
|
30
|
+
"eslint-import-resolver-webpack": "^0.12.2",
|
|
31
|
+
"eslint-plugin-eslint-comments": "^3.2.0",
|
|
32
|
+
"eslint-plugin-import": "^2.22.0",
|
|
33
|
+
"eslint-plugin-jest": "^23.18.0",
|
|
34
|
+
"eslint-plugin-prettier": "^3.1.4",
|
|
35
|
+
"eslint-plugin-promise": "^4.2.1",
|
|
36
|
+
"eslint-plugin-sort-class-members": "^1.7.0",
|
|
37
|
+
"prettier": "2.5.1"
|
|
38
|
+
},
|
|
39
|
+
"publishConfig": {
|
|
40
|
+
"access": "public"
|
|
41
|
+
},
|
|
42
|
+
"gitHead": "8da9cb5674760f5edd760e38c3b6b8a7bc7f51f1"
|
|
43
43
|
}
|
package/test/index.test.js
CHANGED
|
@@ -2,45 +2,51 @@ import ESlint from 'eslint';
|
|
|
2
2
|
import path from 'path';
|
|
3
3
|
|
|
4
4
|
describe('@tinkoff/eslint-config', () => {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
expect(() => cli.executeOnText(`const foo = 'bar';`)).not.toThrow();
|
|
15
|
-
expect(() => cli.executeOnText(`const foo = 'bar';`, 'index.ts')).not.toThrow();
|
|
5
|
+
it('app config working', () => {
|
|
6
|
+
const cli = new ESlint.CLIEngine({
|
|
7
|
+
useEslintrc: false,
|
|
8
|
+
cwd: path.join(__dirname, '..'),
|
|
9
|
+
baseConfig: {
|
|
10
|
+
extends: ['./app'],
|
|
11
|
+
},
|
|
16
12
|
});
|
|
17
13
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
extends: ['./lib'],
|
|
24
|
-
},
|
|
25
|
-
});
|
|
14
|
+
expect(() => cli.executeOnText(`const foo = 'bar';`)).not.toThrow();
|
|
15
|
+
expect(() =>
|
|
16
|
+
cli.executeOnText(`const foo = 'bar';`, 'index.ts')
|
|
17
|
+
).not.toThrow();
|
|
18
|
+
});
|
|
26
19
|
|
|
27
|
-
|
|
28
|
-
|
|
20
|
+
it('lib config working', () => {
|
|
21
|
+
const cli = new ESlint.CLIEngine({
|
|
22
|
+
useEslintrc: false,
|
|
23
|
+
cwd: path.join(__dirname, '..'),
|
|
24
|
+
baseConfig: {
|
|
25
|
+
extends: ['./lib'],
|
|
26
|
+
},
|
|
29
27
|
});
|
|
30
28
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
extends: ['./jest'],
|
|
37
|
-
},
|
|
38
|
-
});
|
|
29
|
+
expect(() => cli.executeOnText(`const foo = 'bar';`)).not.toThrow();
|
|
30
|
+
expect(() =>
|
|
31
|
+
cli.executeOnText(`const foo = 'bar';`, 'index.ts')
|
|
32
|
+
).not.toThrow();
|
|
33
|
+
});
|
|
39
34
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
35
|
+
it('jest config working', () => {
|
|
36
|
+
const cli = new ESlint.CLIEngine({
|
|
37
|
+
useEslintrc: false,
|
|
38
|
+
cwd: path.join(__dirname, '..'),
|
|
39
|
+
baseConfig: {
|
|
40
|
+
extends: ['./jest'],
|
|
41
|
+
},
|
|
45
42
|
});
|
|
43
|
+
|
|
44
|
+
expect(() => cli.executeOnText(`const foo = 'bar';`)).not.toThrow();
|
|
45
|
+
expect(() =>
|
|
46
|
+
cli.executeOnText(`const foo = 'bar';`, 'index.ts')
|
|
47
|
+
).not.toThrow();
|
|
48
|
+
expect(() =>
|
|
49
|
+
cli.executeOnText(`const foo = 'bar';`, 'index.spec.ts')
|
|
50
|
+
).not.toThrow();
|
|
51
|
+
});
|
|
46
52
|
});
|