@perfective/eslint-config 0.27.1 → 0.28.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/README.adoc +18 -19
- package/README.md +21 -24
- package/index.js +151 -121
- package/package.json +13 -15
- package/rules/array-func/index.js +40 -4
- package/rules/cypress/index.js +52 -12
- package/rules/eslint/index.js +7 -6
- package/rules/eslint/layout-formatting.js +65 -65
- package/rules/eslint/possible-problems.js +89 -89
- package/rules/eslint/suggestions.js +178 -178
- package/rules/eslint-comments/best-practices.js +9 -9
- package/rules/eslint-comments/index.js +43 -8
- package/rules/eslint-comments/stylistic-issues.js +16 -16
- package/rules/import/helpful-warnings.js +11 -11
- package/rules/import/index.js +12 -10
- package/rules/import/module-systems.js +11 -11
- package/rules/import/static-analysis.js +27 -27
- package/rules/import/style-guide.js +34 -34
- package/rules/jest/index.js +53 -78
- package/rules/jest/typescript-eslint.js +6 -6
- package/rules/jest-dom/index.js +40 -4
- package/rules/jsdoc/index.js +42 -4
- package/rules/n/index.js +40 -4
- package/rules/prefer-arrow/index.js +40 -4
- package/rules/promise/index.js +54 -7
- package/rules/rxjs/index.js +40 -4
- package/rules/security/index.js +40 -4
- package/rules/simple-import-sort/index.js +41 -4
- package/rules/stylistic/js/index.js +40 -4
- package/rules/stylistic/jsx/index.js +41 -5
- package/rules/stylistic/plus/index.js +40 -4
- package/rules/stylistic/ts/index.js +40 -4
- package/rules/testing-library/index.js +40 -4
- package/rules/typescript-eslint/extension-rules.js +114 -114
- package/rules/typescript-eslint/index.js +43 -8
- package/rules/typescript-eslint/supported-rules.js +315 -314
- package/rules/unicorn/index.js +40 -4
- package/rules/sonarjs/bug-detection.js +0 -15
- package/rules/sonarjs/code-smell-detection.js +0 -27
- package/rules/sonarjs/index.js +0 -10
package/README.adoc
CHANGED
|
@@ -23,7 +23,6 @@ and https://eslint.style[ESLint Stylistic] plugin rules,
|
|
|
23
23
|
* `link:https://github.com/cartant/eslint-plugin-rxjs[eslint-plugin-rxjs]` _(optional)_;
|
|
24
24
|
* `link:https://github.com/eslint-community/eslint-plugin-security[eslint-plugin-security]`;
|
|
25
25
|
* `link:https://github.com/lydell/eslint-plugin-simple-import-sort[eslint-plugin-simple-import-sort]`;
|
|
26
|
-
* `link:https://github.com/SonarSource/eslint-plugin-sonarjs[eslint-plugin-sonarjs]`;
|
|
27
26
|
* `link:https://github.com/testing-library/eslint-plugin-testing-library[eslint-plugin-testing-library]` _(optional)_;
|
|
28
27
|
* `link:https://github.com/sindresorhus/eslint-plugin-unicorn[eslint-plugin-unicorn]`.
|
|
29
28
|
|
|
@@ -47,8 +46,6 @@ npm install --save-dev \
|
|
|
47
46
|
@stylistic/eslint-plugin-jsx \
|
|
48
47
|
@stylistic/eslint-plugin-ts \
|
|
49
48
|
@stylistic/eslint-plugin-plus \
|
|
50
|
-
@typescript-eslint/eslint-plugin \
|
|
51
|
-
@typescript-eslint/parser \
|
|
52
49
|
eslint \
|
|
53
50
|
eslint-import-resolver-typescript \
|
|
54
51
|
eslint-plugin-array-func \
|
|
@@ -60,8 +57,8 @@ npm install --save-dev \
|
|
|
60
57
|
eslint-plugin-promise \
|
|
61
58
|
eslint-plugin-security \
|
|
62
59
|
eslint-plugin-simple-import-sort \
|
|
63
|
-
eslint-plugin-
|
|
64
|
-
eslint
|
|
60
|
+
eslint-plugin-unicorn \
|
|
61
|
+
typescript-eslint
|
|
65
62
|
----
|
|
66
63
|
+
|
|
67
64
|
. Install optional peer dependencies that add linting rules for the tools you use.
|
|
@@ -79,15 +76,13 @@ npm install --save-dev \
|
|
|
79
76
|
The `@perfective/eslint-config` automatically includes rules for these plugins,
|
|
80
77
|
if the dependency is installed.
|
|
81
78
|
+
|
|
82
|
-
. Require the configuration in your root
|
|
79
|
+
. Require the configuration in your root `eslint.config.js`.
|
|
83
80
|
+
|
|
84
81
|
[source,javascript]
|
|
85
82
|
----
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
],
|
|
90
|
-
};
|
|
83
|
+
const perfectiveEslintConfig = require('@perfective/eslint-config');
|
|
84
|
+
|
|
85
|
+
module.exports = perfectiveEslintConfig.default;
|
|
91
86
|
----
|
|
92
87
|
+
|
|
93
88
|
. `*.d.ts` files and `dist` directories are ignored by the configuration.
|
|
@@ -107,20 +102,24 @@ and is simplified by the custom config functions.
|
|
|
107
102
|
These functions and related types are exported in `@perfective/eslint-config/rules`
|
|
108
103
|
and match the rule name in `camelCase`.
|
|
109
104
|
If you need an extended configuration,
|
|
110
|
-
you can use these functions in the
|
|
105
|
+
you can use these functions in the `eslint.config.js` file:
|
|
111
106
|
|
|
112
107
|
[source,javascript]
|
|
113
108
|
----
|
|
109
|
+
const perfectiveEslintConfig = require('@perfective/eslint-config');
|
|
114
110
|
const rules = require('@perfective/eslint-config/rules'); // <.>
|
|
115
111
|
|
|
116
|
-
module.exports =
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
112
|
+
module.exports = [
|
|
113
|
+
...perfectiveEslintConfig.default,
|
|
114
|
+
{
|
|
115
|
+
files: ['**/*.[jt]s?(x)'],
|
|
116
|
+
rules: {
|
|
117
|
+
'simple-import-sort/imports': ['warn', rules.simpleImportSortImports([
|
|
118
|
+
'@perfective',
|
|
119
|
+
])],
|
|
120
|
+
},
|
|
122
121
|
},
|
|
123
|
-
|
|
122
|
+
];
|
|
124
123
|
----
|
|
125
124
|
<1> Framework-specific packages, based on `@perfective/eslint-config`, re-export all the rules.
|
|
126
125
|
So rules should be required from those packages for correct `node_modules` resolution.
|
package/README.md
CHANGED
|
@@ -10,22 +10,21 @@ In addition to the core [ESLint rules](https://eslint.org/docs/latest/rules/),
|
|
|
10
10
|
and [ESlint Stylistic](https://eslint.style) plugin rules,
|
|
11
11
|
`@perfective/eslint-config` includes configurations for the ESLint plugins:
|
|
12
12
|
|
|
13
|
-
-
|
|
14
|
-
-
|
|
15
|
-
-
|
|
16
|
-
-
|
|
17
|
-
-
|
|
18
|
-
-
|
|
19
|
-
-
|
|
20
|
-
-
|
|
21
|
-
-
|
|
22
|
-
-
|
|
23
|
-
-
|
|
24
|
-
-
|
|
25
|
-
-
|
|
26
|
-
-
|
|
27
|
-
-
|
|
28
|
-
- [`eslint-plugin-unicorn`](https://github.com/sindresorhus/eslint-plugin-unicorn).
|
|
13
|
+
- [`eslint-plugin-array-func`](https://github.com/freaktechnik/eslint-plugin-array-func);
|
|
14
|
+
- [`eslint-plugin-cypress`](https://github.com/cypress-io/eslint-plugin-cypress) _(optional)_;
|
|
15
|
+
- [`eslint-plugin-eslint-comments`](https://mysticatea.github.io/eslint-plugin-eslint-comments/);
|
|
16
|
+
- [`eslint-plugin-import`](https://github.com/import-js/eslint-plugin-import);
|
|
17
|
+
- [`eslint-plugin-jest`](https://github.com/jest-community/eslint-plugin-jest) _(optional)_;
|
|
18
|
+
- [`eslint-plugin-jest-dom`](https://github.com/testing-library/eslint-plugin-jest-dom) _(optional)_;
|
|
19
|
+
- [`eslint-plugin-jsdoc`](https://github.com/gajus/eslint-plugin-jsdoc);
|
|
20
|
+
- [`eslint-plugin-n`](https://github.com/eslint-community/eslint-plugin-n);
|
|
21
|
+
- [`eslint-plugin-prefer-arrow`](https://github.com/TristonJ/eslint-plugin-prefer-arrow);
|
|
22
|
+
- [`eslint-plugin-promise`](https://github.com/eslint-community/eslint-plugin-promise);
|
|
23
|
+
- [`eslint-plugin-rxjs`](https://github.com/cartant/eslint-plugin-rxjs) _(optional)_;
|
|
24
|
+
- [`eslint-plugin-security`](https://github.com/eslint-community/eslint-plugin-security);
|
|
25
|
+
- [`eslint-plugin-simple-import-sort`](https://github.com/lydell/eslint-plugin-simple-import-sort);
|
|
26
|
+
- [`eslint-plugin-testing-library`](https://github.com/testing-library/eslint-plugin-testing-library) _(optional)_;
|
|
27
|
+
- [`eslint-plugin-unicorn`](https://github.com/sindresorhus/eslint-plugin-unicorn).
|
|
29
28
|
|
|
30
29
|
To simplify configuring ESLint support in the IDEs and editors,
|
|
31
30
|
the severity of all fixable rules is a `warning`.
|
|
@@ -45,8 +44,6 @@ from issues that will be fixed automatically.
|
|
|
45
44
|
@stylistic/eslint-plugin-jsx \
|
|
46
45
|
@stylistic/eslint-plugin-ts \
|
|
47
46
|
@stylistic/eslint-plugin-plus \
|
|
48
|
-
@typescript-eslint/eslint-plugin \
|
|
49
|
-
@typescript-eslint/parser \
|
|
50
47
|
eslint \
|
|
51
48
|
eslint-import-resolver-typescript \
|
|
52
49
|
eslint-plugin-array-func \
|
|
@@ -58,8 +55,8 @@ from issues that will be fixed automatically.
|
|
|
58
55
|
eslint-plugin-promise \
|
|
59
56
|
eslint-plugin-security \
|
|
60
57
|
eslint-plugin-simple-import-sort \
|
|
61
|
-
eslint-plugin-
|
|
62
|
-
eslint
|
|
58
|
+
eslint-plugin-unicorn \
|
|
59
|
+
typescript-eslint
|
|
63
60
|
```
|
|
64
61
|
|
|
65
62
|
2. Install optional peer dependencies that add linting rules for the tools you use.
|
|
@@ -76,10 +73,10 @@ from issues that will be fixed automatically.
|
|
|
76
73
|
The `@perfective/eslint-config` automatically includes rules for these plugins,
|
|
77
74
|
if the dependency is installed.
|
|
78
75
|
|
|
79
|
-
3. Require the configuration in your root
|
|
76
|
+
3. Require the configuration in your root `eslint.config.js`.
|
|
80
77
|
|
|
81
78
|
```javascript
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
79
|
+
const perfectiveEslintConfig = require('@perfective/eslint-config');
|
|
80
|
+
|
|
81
|
+
module.exports = perfectiveEslintConfig.default;
|
|
85
82
|
```
|
package/index.js
CHANGED
|
@@ -1,34 +1,92 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
const tsEslint = __importStar(require("typescript-eslint"));
|
|
37
|
+
const babelParser = __importStar(require("@babel/eslint-parser"));
|
|
2
38
|
const plugin_1 = require("./config/plugin");
|
|
39
|
+
const array_func_1 = require("./rules/array-func");
|
|
40
|
+
const cypress_1 = require("./rules/cypress");
|
|
41
|
+
const eslint_1 = require("./rules/eslint");
|
|
42
|
+
const eslint_comments_1 = require("./rules/eslint-comments");
|
|
43
|
+
const import_1 = require("./rules/import");
|
|
3
44
|
const no_extraneous_dependencies_1 = require("./rules/import/rules/no-extraneous-dependencies");
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
45
|
+
const jest_1 = require("./rules/jest");
|
|
46
|
+
const jest_dom_1 = require("./rules/jest-dom");
|
|
47
|
+
const jsdoc_1 = require("./rules/jsdoc");
|
|
48
|
+
const n_1 = require("./rules/n");
|
|
49
|
+
const prefer_arrow_1 = require("./rules/prefer-arrow");
|
|
50
|
+
const promise_1 = require("./rules/promise");
|
|
51
|
+
const rxjs_1 = require("./rules/rxjs");
|
|
52
|
+
const security_1 = require("./rules/security");
|
|
53
|
+
const simple_import_sort_1 = require("./rules/simple-import-sort");
|
|
54
|
+
const js_1 = require("./rules/stylistic/js");
|
|
55
|
+
const jsx_1 = require("./rules/stylistic/jsx");
|
|
56
|
+
const plus_1 = require("./rules/stylistic/plus");
|
|
57
|
+
const ts_1 = require("./rules/stylistic/ts");
|
|
58
|
+
const testing_library_1 = require("./rules/testing-library");
|
|
59
|
+
const typescript_eslint_1 = require("./rules/typescript-eslint");
|
|
60
|
+
const unicorn_1 = require("./rules/unicorn");
|
|
61
|
+
exports.default = [
|
|
62
|
+
{
|
|
63
|
+
ignores: ['**/*.d.ts', '**/dist'],
|
|
7
64
|
},
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
{
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
'
|
|
19
|
-
'./
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
'./rules/unicorn',
|
|
27
|
-
],
|
|
65
|
+
{
|
|
66
|
+
files: ['**/*.[jt]s?(x)'],
|
|
67
|
+
languageOptions: {
|
|
68
|
+
parser: tsEslint.parser,
|
|
69
|
+
parserOptions: {
|
|
70
|
+
ecmaVersion: 6,
|
|
71
|
+
ecmaFeatures: {
|
|
72
|
+
globalReturn: false,
|
|
73
|
+
impliedStrict: true,
|
|
74
|
+
},
|
|
75
|
+
sourceType: 'module',
|
|
76
|
+
project: './tsconfig.json',
|
|
77
|
+
warnOnUnsupportedTypeScriptVersion: true,
|
|
78
|
+
},
|
|
79
|
+
},
|
|
80
|
+
plugins: Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, array_func_1.arrayFuncConfig.plugins), eslint_comments_1.eslintCommentsConfig.plugins), import_1.importConfig.plugins), jsdoc_1.jsdocConfig.plugins), n_1.nConfig.plugins), prefer_arrow_1.preferArrowConfig.plugins), promise_1.promiseConfig.plugins), security_1.securityConfig.plugins), simple_import_sort_1.simpleImportSortConfig.plugins), js_1.stylisticJsConfig.plugins), plus_1.stylisticPlusConfig.plugins), unicorn_1.unicornConfig.plugins),
|
|
81
|
+
settings: {
|
|
82
|
+
jsdoc: jsdoc_1.jsdocConfig.settings,
|
|
28
83
|
},
|
|
29
|
-
{
|
|
30
|
-
|
|
31
|
-
|
|
84
|
+
rules: Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, array_func_1.arrayFuncConfig.rules), eslint_1.eslintConfig.rules), eslint_comments_1.eslintCommentsConfig.rules), import_1.importConfig.rules), jsdoc_1.jsdocConfig.rules), n_1.nConfig.rules), prefer_arrow_1.preferArrowConfig.rules), promise_1.promiseConfig.rules), security_1.securityConfig.rules), simple_import_sort_1.simpleImportSortConfig.rules), js_1.stylisticJsConfig.rules), plus_1.stylisticPlusConfig.rules), unicorn_1.unicornConfig.rules),
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
files: ['**/*.js?(x)'],
|
|
88
|
+
languageOptions: {
|
|
89
|
+
parser: babelParser,
|
|
32
90
|
parserOptions: {
|
|
33
91
|
ecmaVersion: 6,
|
|
34
92
|
ecmaFeatures: {
|
|
@@ -38,24 +96,27 @@ module.exports = {
|
|
|
38
96
|
sourceType: 'module',
|
|
39
97
|
requireConfigFile: false,
|
|
40
98
|
},
|
|
41
|
-
settings: {
|
|
42
|
-
'import/extensions': ['.js', '.jsx'],
|
|
43
|
-
},
|
|
44
|
-
rules: {
|
|
45
|
-
'import/no-commonjs': 'off',
|
|
46
|
-
'import/no-extraneous-dependencies': ['error', (0, no_extraneous_dependencies_1.jsImportNoExtraneousDependencies)()],
|
|
47
|
-
'import/unambiguous': 'off',
|
|
48
|
-
'jsdoc/no-types': 'off',
|
|
49
|
-
'jsdoc/no-undefined-types': 'off',
|
|
50
|
-
'jsdoc/require-param': 'error',
|
|
51
|
-
'jsdoc/require-param-type': 'error',
|
|
52
|
-
'jsdoc/require-returns': 'error',
|
|
53
|
-
'jsdoc/require-returns-type': 'error',
|
|
54
|
-
},
|
|
55
99
|
},
|
|
56
|
-
{
|
|
57
|
-
|
|
58
|
-
|
|
100
|
+
plugins: {},
|
|
101
|
+
settings: {
|
|
102
|
+
'import/extensions': ['.js', '.jsx'],
|
|
103
|
+
},
|
|
104
|
+
rules: {
|
|
105
|
+
'import/no-commonjs': 'off',
|
|
106
|
+
'import/no-extraneous-dependencies': ['error', (0, no_extraneous_dependencies_1.jsImportNoExtraneousDependencies)()],
|
|
107
|
+
'import/unambiguous': 'off',
|
|
108
|
+
'jsdoc/no-types': 'off',
|
|
109
|
+
'jsdoc/no-undefined-types': 'off',
|
|
110
|
+
'jsdoc/require-param': 'error',
|
|
111
|
+
'jsdoc/require-param-type': 'error',
|
|
112
|
+
'jsdoc/require-returns': 'error',
|
|
113
|
+
'jsdoc/require-returns-type': 'error',
|
|
114
|
+
},
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
files: ['**/*.ts?(x)'],
|
|
118
|
+
languageOptions: {
|
|
119
|
+
parser: tsEslint.parser,
|
|
59
120
|
parserOptions: {
|
|
60
121
|
ecmaVersion: 6,
|
|
61
122
|
ecmaFeatures: {
|
|
@@ -66,85 +127,54 @@ module.exports = {
|
|
|
66
127
|
project: './tsconfig.json',
|
|
67
128
|
warnOnUnsupportedTypeScriptVersion: true,
|
|
68
129
|
},
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
typescript: {
|
|
83
|
-
alwaysTryTypes: true,
|
|
84
|
-
project: './tsconfig.json',
|
|
85
|
-
},
|
|
130
|
+
},
|
|
131
|
+
plugins: Object.assign(Object.assign(Object.assign({}, typescript_eslint_1.typescriptEslintConfig.plugins), ts_1.stylisticTsConfig.plugins), (0, plugin_1.hasEslintPlugin)('rxjs') ? rxjs_1.rxjsConfig.plugins : {}),
|
|
132
|
+
settings: {
|
|
133
|
+
'import/parsers': {
|
|
134
|
+
'@typescript-eslint/parser': [
|
|
135
|
+
'.ts',
|
|
136
|
+
'.tsx',
|
|
137
|
+
],
|
|
138
|
+
},
|
|
139
|
+
'import/resolver': {
|
|
140
|
+
typescript: {
|
|
141
|
+
alwaysTryTypes: true,
|
|
142
|
+
project: './tsconfig.json',
|
|
86
143
|
},
|
|
87
144
|
},
|
|
88
145
|
},
|
|
89
|
-
{
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
146
|
+
rules: Object.assign(Object.assign(Object.assign({}, typescript_eslint_1.typescriptEslintConfig.rules), ts_1.stylisticTsConfig.rules), (0, plugin_1.hasEslintPlugin)('rxjs') ? rxjs_1.rxjsConfig.rules : {}),
|
|
147
|
+
},
|
|
148
|
+
{
|
|
149
|
+
files: ['**/*.js?(x)'],
|
|
150
|
+
plugins: Object.assign({}, jsx_1.stylisticJsxConfig.plugins),
|
|
151
|
+
rules: Object.assign({}, jsx_1.stylisticJsxConfig.rules),
|
|
152
|
+
},
|
|
153
|
+
(0, plugin_1.hasEslintPlugin)('jest') ? {
|
|
154
|
+
files: ['**/*.@(spec|test).[jt]s?(x)'],
|
|
155
|
+
plugins: Object.assign(Object.assign(Object.assign({}, jest_1.jestConfig.plugins), (0, plugin_1.hasEslintPlugin)('jest-dom') ? jest_dom_1.jestDomConfig.plugins : {}), (0, plugin_1.hasEslintPlugin)('testing-library') ? testing_library_1.testingLibraryConfig.plugins : {}),
|
|
156
|
+
rules: Object.assign(Object.assign(Object.assign(Object.assign({}, jest_1.jestConfig.rules), (0, plugin_1.hasEslintPlugin)('jest-dom') ? jest_dom_1.jestDomConfig.rules : {}), (0, plugin_1.hasEslintPlugin)('testing-library') ? testing_library_1.testingLibraryConfig.rules : {}), { '@typescript-eslint/ban-ts-comment': ['error', {
|
|
157
|
+
'ts-expect-error': 'allow-with-description',
|
|
158
|
+
'ts-ignore': true,
|
|
159
|
+
'ts-nocheck': true,
|
|
160
|
+
'ts-check': false,
|
|
161
|
+
}], '@typescript-eslint/init-declarations': 'off', '@typescript-eslint/unbound-method': 'off', 'import/no-extraneous-dependencies': ['error', (0, no_extraneous_dependencies_1.jestImportNoExtraneousDependencies)()], 'import/no-unassigned-import': ['error', {
|
|
162
|
+
allow: [
|
|
163
|
+
'@testing-library/jest-dom',
|
|
164
|
+
'@testing-library/jest-dom/extend-expect',
|
|
165
|
+
],
|
|
166
|
+
}], 'max-nested-callbacks': ['error', 6], 'n/no-unpublished-import': ['error', {
|
|
167
|
+
allowModules: ['@jest/globals'],
|
|
168
|
+
}], 'prefer-arrow/prefer-arrow-functions': 'off', 'promise/always-return': 'off', 'rxjs/no-topromise': 'off' }),
|
|
169
|
+
} : null,
|
|
170
|
+
(0, plugin_1.hasEslintPlugin)('cypress') ? {
|
|
171
|
+
files: ['cypress/**/*.[jt]s'],
|
|
172
|
+
env: {
|
|
173
|
+
'cypress/globals': true,
|
|
94
174
|
},
|
|
95
|
-
(
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
extends: [
|
|
102
|
-
'./rules/jest',
|
|
103
|
-
(0, plugin_1.optionalRules)('jest-dom'),
|
|
104
|
-
(0, plugin_1.optionalRules)('testing-library'),
|
|
105
|
-
].filter(Boolean),
|
|
106
|
-
rules: {
|
|
107
|
-
'@typescript-eslint/ban-ts-comment': ['error', {
|
|
108
|
-
'ts-expect-error': 'allow-with-description',
|
|
109
|
-
'ts-ignore': true,
|
|
110
|
-
'ts-nocheck': true,
|
|
111
|
-
'ts-check': false,
|
|
112
|
-
}],
|
|
113
|
-
'@typescript-eslint/init-declarations': 'off',
|
|
114
|
-
'@typescript-eslint/unbound-method': 'off',
|
|
115
|
-
'import/no-extraneous-dependencies': ['error', (0, no_extraneous_dependencies_1.jestImportNoExtraneousDependencies)()],
|
|
116
|
-
'import/no-unassigned-import': ['error', {
|
|
117
|
-
allow: [
|
|
118
|
-
'@testing-library/jest-dom',
|
|
119
|
-
'@testing-library/jest-dom/extend-expect',
|
|
120
|
-
],
|
|
121
|
-
}],
|
|
122
|
-
'max-nested-callbacks': ['error', 6],
|
|
123
|
-
'n/no-unpublished-import': ['error', {
|
|
124
|
-
allowModules: ['@jest/globals'],
|
|
125
|
-
}],
|
|
126
|
-
'prefer-arrow/prefer-arrow-functions': 'off',
|
|
127
|
-
'promise/always-return': 'off',
|
|
128
|
-
'rxjs/no-topromise': 'off',
|
|
129
|
-
},
|
|
130
|
-
}),
|
|
131
|
-
(0, plugin_1.optionalOverrides)('cypress', {
|
|
132
|
-
files: ['cypress/**/*.[jt]s'],
|
|
133
|
-
env: {
|
|
134
|
-
'cypress/globals': true,
|
|
135
|
-
},
|
|
136
|
-
extends: [
|
|
137
|
-
'./rules/cypress',
|
|
138
|
-
],
|
|
139
|
-
rules: {
|
|
140
|
-
'init-declarations': 'off',
|
|
141
|
-
'@typescript-eslint/init-declarations': 'off',
|
|
142
|
-
'import/no-extraneous-dependencies': ['error', (0, no_extraneous_dependencies_1.cypressImportNoExtraneousDependencies)()],
|
|
143
|
-
'max-nested-callbacks': ['error', 4],
|
|
144
|
-
'new-cap': ['error', {
|
|
145
|
-
capIsNewExceptions: ['Given', 'When', 'Then', 'And', 'But', 'Before', 'After'],
|
|
146
|
-
}],
|
|
147
|
-
},
|
|
148
|
-
}),
|
|
149
|
-
].filter(Boolean),
|
|
150
|
-
};
|
|
175
|
+
plugins: Object.assign({}, cypress_1.cypressOptionalConfig.plugins),
|
|
176
|
+
rules: Object.assign(Object.assign({}, cypress_1.cypressOptionalConfig.rules), { 'init-declarations': 'off', '@typescript-eslint/init-declarations': 'off', 'import/no-extraneous-dependencies': ['error', (0, no_extraneous_dependencies_1.cypressImportNoExtraneousDependencies)()], 'max-nested-callbacks': ['error', 4], 'new-cap': ['error', {
|
|
177
|
+
capIsNewExceptions: ['Given', 'When', 'Then', 'And', 'But', 'Before', 'After'],
|
|
178
|
+
}] }),
|
|
179
|
+
} : null,
|
|
180
|
+
].filter(Boolean);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@perfective/eslint-config",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.28.0",
|
|
4
4
|
"description": "ESLint shareable rules configuration",
|
|
5
5
|
"keywords": ["code quality", "code standard", "code style", "eslint", "eslint config", "lint", "perfective", "tslint", "tslint config", "typescript"],
|
|
6
6
|
"author": "Andrey Mikheychik <a.mikheychik@gmail.com>",
|
|
@@ -12,13 +12,11 @@
|
|
|
12
12
|
"license": "MIT",
|
|
13
13
|
"peerDependencies": {
|
|
14
14
|
"@babel/eslint-parser": "^7.25.9",
|
|
15
|
-
"@stylistic/eslint-plugin": "^2.
|
|
16
|
-
"@stylistic/eslint-plugin-js": "^2.
|
|
17
|
-
"@stylistic/eslint-plugin-jsx": "^2.
|
|
18
|
-
"@stylistic/eslint-plugin-plus": "^2.
|
|
19
|
-
"@stylistic/eslint-plugin-ts": "^2.
|
|
20
|
-
"@typescript-eslint/eslint-plugin": "^8.14.0",
|
|
21
|
-
"@typescript-eslint/parser": "^8.14.0",
|
|
15
|
+
"@stylistic/eslint-plugin": "^2.11.0",
|
|
16
|
+
"@stylistic/eslint-plugin-js": "^2.11.0",
|
|
17
|
+
"@stylistic/eslint-plugin-jsx": "^2.11.0",
|
|
18
|
+
"@stylistic/eslint-plugin-plus": "^2.11.0",
|
|
19
|
+
"@stylistic/eslint-plugin-ts": "^2.11.0",
|
|
22
20
|
"eslint": "^8.57.1",
|
|
23
21
|
"eslint-import-resolver-typescript": "^3.6.3",
|
|
24
22
|
"eslint-plugin-array-func": "^4.0.0",
|
|
@@ -26,17 +24,17 @@
|
|
|
26
24
|
"eslint-plugin-eslint-comments": "^3.2.0",
|
|
27
25
|
"eslint-plugin-import": "^2.31.0",
|
|
28
26
|
"eslint-plugin-jest": "^28.9.0",
|
|
29
|
-
"eslint-plugin-jest-dom": "^5.
|
|
30
|
-
"eslint-plugin-jsdoc": "^50.
|
|
31
|
-
"eslint-plugin-n": "^17.
|
|
27
|
+
"eslint-plugin-jest-dom": "^5.5.0",
|
|
28
|
+
"eslint-plugin-jsdoc": "^50.6.0",
|
|
29
|
+
"eslint-plugin-n": "^17.14.0",
|
|
32
30
|
"eslint-plugin-prefer-arrow": "^1.2.3",
|
|
33
|
-
"eslint-plugin-promise": "^7.1
|
|
31
|
+
"eslint-plugin-promise": "^7.2.1",
|
|
34
32
|
"eslint-plugin-rxjs": "^5.0.3",
|
|
35
33
|
"eslint-plugin-security": "^3.0.1",
|
|
36
34
|
"eslint-plugin-simple-import-sort": "^12.1.1",
|
|
37
|
-
"eslint-plugin-
|
|
38
|
-
"eslint-plugin-
|
|
39
|
-
"eslint
|
|
35
|
+
"eslint-plugin-testing-library": "^7.0.0",
|
|
36
|
+
"eslint-plugin-unicorn": "^56.0.1",
|
|
37
|
+
"typescript-eslint": "^8.16.0"
|
|
40
38
|
},
|
|
41
39
|
"peerDependenciesMeta": {
|
|
42
40
|
"eslint-plugin-cypress": {
|
|
@@ -1,8 +1,44 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.arrayFuncConfig = void 0;
|
|
37
|
+
const eslintPluginArrayFunc = __importStar(require("eslint-plugin-array-func"));
|
|
38
|
+
exports.arrayFuncConfig = {
|
|
39
|
+
plugins: {
|
|
40
|
+
'array-func': eslintPluginArrayFunc,
|
|
41
|
+
},
|
|
6
42
|
rules: {
|
|
7
43
|
'array-func/from-map': 'warn',
|
|
8
44
|
'array-func/no-unnecessary-this-arg': 'error',
|
package/rules/cypress/index.js
CHANGED
|
@@ -1,14 +1,54 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
14
17
|
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.cypressOptionalConfig = void 0;
|
|
37
|
+
const eslintPluginCypress = __importStar(require("eslint-plugin-cypress"));
|
|
38
|
+
exports.cypressOptionalConfig = {
|
|
39
|
+
plugins: {
|
|
40
|
+
cypress: eslintPluginCypress,
|
|
41
|
+
},
|
|
42
|
+
rules: {
|
|
43
|
+
'cypress/assertion-before-screenshot': 'error',
|
|
44
|
+
'cypress/no-assigning-return-values': 'error',
|
|
45
|
+
'cypress/no-async-before': 'error',
|
|
46
|
+
'cypress/no-async-tests': 'error',
|
|
47
|
+
'cypress/no-debug': 'error',
|
|
48
|
+
'cypress/no-force': 'error',
|
|
49
|
+
'cypress/no-pause': 'error',
|
|
50
|
+
'cypress/no-unnecessary-waiting': 'error',
|
|
51
|
+
'cypress/require-data-selectors': 'error',
|
|
52
|
+
'cypress/unsafe-to-chain-command': 'error',
|
|
53
|
+
},
|
|
54
|
+
};
|
package/rules/eslint/index.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.eslintConfig = void 0;
|
|
4
|
+
const layout_formatting_1 = require("./layout-formatting");
|
|
5
|
+
const possible_problems_1 = require("./possible-problems");
|
|
6
|
+
const suggestions_1 = require("./suggestions");
|
|
7
|
+
exports.eslintConfig = {
|
|
8
|
+
rules: Object.assign(Object.assign(Object.assign({}, possible_problems_1.eslintPossibleProblemsRules), suggestions_1.eslintSuggestionsRules), layout_formatting_1.eslintLayoutFormattingRules),
|
|
8
9
|
};
|