@perfective/eslint-config 0.27.1 → 0.29.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 +45 -48
- package/README.md +43 -26
- package/config/plugin.d.ts +0 -3
- package/config/plugin.js +0 -24
- package/config.d.ts +1 -1
- package/config.js +1 -4
- package/cypress.js +58 -0
- package/index.js +120 -123
- package/jest-dom.js +11 -0
- package/jest.js +24 -0
- package/package.json +39 -20
- package/rules/array-func/index.js +40 -4
- package/rules/cypress/index.js +55 -12
- package/rules/eslint/index.js +7 -6
- package/rules/eslint/layout-formatting.js +65 -65
- package/rules/eslint/possible-problems.js +97 -89
- package/rules/eslint/suggestions.js +180 -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 +79 -44
- 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/rxjs.js +58 -0
- package/testing-library.js +11 -0
- 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,41 +57,56 @@ 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
|
+
|
|
64
|
+
. Require the configuration in your root `eslint.config.js`.
|
|
65
|
+
+
|
|
66
|
+
[source,javascript]
|
|
67
|
+
----
|
|
68
|
+
const perfectiveEslintConfig = require('@perfective/eslint-config');
|
|
69
|
+
|
|
70
|
+
module.exports = perfectiveEslintConfig.default;
|
|
71
|
+
----
|
|
72
|
+
+
|
|
73
|
+
. `*.d.ts` files and `dist` directories are ignored by the configuration.
|
|
74
|
+
`node_modules` and dot-files are ignored by the `eslint`.
|
|
75
|
+
If more directories or file types need to be ignored, see the
|
|
76
|
+
`link:https://eslint.org/docs/user-guide/configuring/ignoring-code#the-eslintignore-file[.eslintignore]` file docs.
|
|
77
|
+
+
|
|
67
78
|
. Install optional peer dependencies that add linting rules for the tools you use.
|
|
68
79
|
+
|
|
69
80
|
[source,bash]
|
|
70
81
|
----
|
|
71
82
|
npm install --save-dev \
|
|
83
|
+
@smarttools/eslint-plugin-rxjs \
|
|
72
84
|
eslint-plugin-cypress \
|
|
73
85
|
eslint-plugin-jest \
|
|
74
86
|
eslint-plugin-jest-dom \
|
|
75
|
-
eslint-plugin-rxjs \
|
|
76
87
|
eslint-plugin-testing-library
|
|
77
88
|
----
|
|
78
89
|
+
|
|
79
|
-
|
|
80
|
-
if the dependency is installed.
|
|
81
|
-
+
|
|
82
|
-
. Require the configuration in your root `.eslintrc.js`.
|
|
90
|
+
. Add optional configurations to your root `eslint.config.js`.
|
|
83
91
|
+
|
|
84
92
|
[source,javascript]
|
|
85
93
|
----
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
94
|
+
const perfectiveEslintConfig = require('@perfective/eslint-config');
|
|
95
|
+
const perfectiveCypressConfig = require('@perfective/eslint-config/cypress');
|
|
96
|
+
const perfectiveJestConfig = require('@perfective/eslint-config/jest');
|
|
97
|
+
const perfectiveJestDomConfig = require('@perfective/eslint-config/jesd-dom');
|
|
98
|
+
const perfectiveRxjsConfig = require('@perfective/eslint-config/rxjs');
|
|
99
|
+
const perfectiveTestingLibraryConfig = require('@perfective/eslint-config/testing-library');
|
|
100
|
+
|
|
101
|
+
module.exports = [
|
|
102
|
+
...perfectiveEslintConfig.default,
|
|
103
|
+
perfectiveCypressConfig.cypressConfig(),
|
|
104
|
+
perfectiveJestConfig.jestConfig(),
|
|
105
|
+
perfectiveJestDomConfig.jestDomConfig(),
|
|
106
|
+
perfectiveRxjsConfig.rxjsConfig(),
|
|
107
|
+
perfectiveTestingLibraryConfig.testingLibrarysConfig(),
|
|
108
|
+
];
|
|
91
109
|
----
|
|
92
|
-
+
|
|
93
|
-
. `*.d.ts` files and `dist` directories are ignored by the configuration.
|
|
94
|
-
`node_modules` and dot-files are ignored by the `eslint`.
|
|
95
|
-
If more directories or file types need to be ignored, see the
|
|
96
|
-
`link:https://eslint.org/docs/user-guide/configuring/ignoring-code#the-eslintignore-file[.eslintignore]` file docs.
|
|
97
|
-
|
|
98
110
|
|
|
99
111
|
== Rules Configuration Extension Functions
|
|
100
112
|
|
|
@@ -107,20 +119,24 @@ and is simplified by the custom config functions.
|
|
|
107
119
|
These functions and related types are exported in `@perfective/eslint-config/rules`
|
|
108
120
|
and match the rule name in `camelCase`.
|
|
109
121
|
If you need an extended configuration,
|
|
110
|
-
you can use these functions in the
|
|
122
|
+
you can use these functions in the `eslint.config.js` file:
|
|
111
123
|
|
|
112
124
|
[source,javascript]
|
|
113
125
|
----
|
|
126
|
+
const perfectiveEslintConfig = require('@perfective/eslint-config');
|
|
114
127
|
const rules = require('@perfective/eslint-config/rules'); // <.>
|
|
115
128
|
|
|
116
|
-
module.exports =
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
129
|
+
module.exports = [
|
|
130
|
+
...perfectiveEslintConfig.default,
|
|
131
|
+
{
|
|
132
|
+
files: ['**/*.[jt]s?(x)'],
|
|
133
|
+
rules: {
|
|
134
|
+
'simple-import-sort/imports': ['warn', rules.simpleImportSortImports([
|
|
135
|
+
'@perfective',
|
|
136
|
+
])],
|
|
137
|
+
},
|
|
122
138
|
},
|
|
123
|
-
|
|
139
|
+
];
|
|
124
140
|
----
|
|
125
141
|
<1> Framework-specific packages, based on `@perfective/eslint-config`, re-export all the rules.
|
|
126
142
|
So rules should be required from those packages for correct `node_modules` resolution.
|
|
@@ -136,22 +152,3 @@ for the `simple-import-sort/imports` rule.
|
|
|
136
152
|
* `unicornPreventAbbreviations(replacements, options)`
|
|
137
153
|
— extends and overrides the list of `replacements`
|
|
138
154
|
and `options` for the `unicorn/prevent-abbreviation` rule.
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
== Internals
|
|
142
|
-
|
|
143
|
-
The rules for each plugin are described in the `./src/rules/{plugin}` subdirectories,
|
|
144
|
-
where the `{plugin}` is the name of the plugin (after the `eslint-plugin-` prefix).
|
|
145
|
-
Each configuration is exported from the `./index.ts` file
|
|
146
|
-
and is organized as a partial ESLint config.
|
|
147
|
-
It should contain the plugin name and the list of the rules, sorted alphabetically.
|
|
148
|
-
When a plugin's documentation groups rules,
|
|
149
|
-
each group is configured in a separate file
|
|
150
|
-
and then extended in the `./index.ts` file.
|
|
151
|
-
|
|
152
|
-
The final configuration extends each plugin configuration on a file-type basis.
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
== Roadmap
|
|
156
|
-
|
|
157
|
-
* Add the `@perfective/eslint-plugin` with the rules for working with the `@perfective` packages.
|
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,28 +55,48 @@ 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
|
-
2.
|
|
62
|
+
2. Require the configuration in your root `eslint.config.js`.
|
|
63
|
+
|
|
64
|
+
```javascript
|
|
65
|
+
const perfectiveEslintConfig = require('@perfective/eslint-config');
|
|
66
|
+
|
|
67
|
+
module.exports = perfectiveEslintConfig.default;
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
3. Install optional peer dependencies that add linting rules for the tools you use.
|
|
66
71
|
|
|
67
72
|
```bash
|
|
68
73
|
npm install --save-dev \
|
|
74
|
+
@smarttools/eslint-plugin-rxjs \
|
|
69
75
|
eslint-plugin-cypress \
|
|
70
76
|
eslint-plugin-jest \
|
|
71
77
|
eslint-plugin-jest-dom \
|
|
72
|
-
eslint-plugin-rxjs \
|
|
73
78
|
eslint-plugin-testing-library
|
|
74
79
|
```
|
|
75
80
|
|
|
76
81
|
The `@perfective/eslint-config` automatically includes rules for these plugins,
|
|
77
82
|
if the dependency is installed.
|
|
78
83
|
|
|
79
|
-
|
|
84
|
+
4. Add optional configurations to your root `eslint.config.js`.
|
|
80
85
|
|
|
81
86
|
```javascript
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
87
|
+
const perfectiveEslintConfig = require('@perfective/eslint-config');
|
|
88
|
+
const perfectiveCypressConfig = require('@perfective/eslint-config/cypress');
|
|
89
|
+
const perfectiveJestConfig = require('@perfective/eslint-config/jest');
|
|
90
|
+
const perfectiveJestDomConfig = require('@perfective/eslint-config/jesd-dom');
|
|
91
|
+
const perfectiveRxjsConfig = require('@perfective/eslint-config/rxjs');
|
|
92
|
+
const perfectiveTestingLibraryConfig = require('@perfective/eslint-config/testing-library');
|
|
93
|
+
|
|
94
|
+
module.exports = [
|
|
95
|
+
...perfectiveEslintConfig.default,
|
|
96
|
+
perfectiveCypressConfig.cypressConfig(),
|
|
97
|
+
perfectiveJestConfig.jestConfig(),
|
|
98
|
+
perfectiveJestDomConfig.jestDomConfig(),
|
|
99
|
+
perfectiveRxjsConfig.rxjsConfig(),
|
|
100
|
+
perfectiveTestingLibraryConfig.testingLibrarysConfig(),
|
|
101
|
+
];
|
|
85
102
|
```
|
package/config/plugin.d.ts
CHANGED
|
@@ -1,5 +1,2 @@
|
|
|
1
|
-
export declare function optionalConfig(plugin: string, rules: Record<string, unknown>): Record<string, unknown>;
|
|
2
|
-
export declare function optionalOverrides(plugin: string, overrides: Record<string, unknown>): Record<string, unknown> | null;
|
|
3
|
-
export declare function optionalRules(plugin: string): string | null;
|
|
4
1
|
export declare function optionalRule(rule: string, config: unknown): Record<string, unknown>;
|
|
5
2
|
export declare function hasEslintPlugin(plugin: string): boolean;
|
package/config/plugin.js
CHANGED
|
@@ -1,32 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.optionalConfig = optionalConfig;
|
|
4
|
-
exports.optionalOverrides = optionalOverrides;
|
|
5
|
-
exports.optionalRules = optionalRules;
|
|
6
3
|
exports.optionalRule = optionalRule;
|
|
7
4
|
exports.hasEslintPlugin = hasEslintPlugin;
|
|
8
5
|
const node_1 = require("./node");
|
|
9
|
-
function optionalConfig(plugin, rules) {
|
|
10
|
-
if (hasEslintPlugin(plugin)) {
|
|
11
|
-
return {
|
|
12
|
-
plugins: [plugin],
|
|
13
|
-
rules,
|
|
14
|
-
};
|
|
15
|
-
}
|
|
16
|
-
return {};
|
|
17
|
-
}
|
|
18
|
-
function optionalOverrides(plugin, overrides) {
|
|
19
|
-
if (hasEslintPlugin(plugin)) {
|
|
20
|
-
return overrides;
|
|
21
|
-
}
|
|
22
|
-
return null;
|
|
23
|
-
}
|
|
24
|
-
function optionalRules(plugin) {
|
|
25
|
-
if (hasEslintPlugin(plugin)) {
|
|
26
|
-
return `./rules/${plugin.replace(/^@/u, '')}`;
|
|
27
|
-
}
|
|
28
|
-
return null;
|
|
29
|
-
}
|
|
30
6
|
function optionalRule(rule, config) {
|
|
31
7
|
const plugin = pluginOfRule(rule);
|
|
32
8
|
if (plugin === null) {
|
package/config.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { hasEslintPlugin,
|
|
1
|
+
export { hasEslintPlugin, optionalRule, } from './config/plugin';
|
package/config.js
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.optionalRule = exports.hasEslintPlugin = void 0;
|
|
4
4
|
var plugin_1 = require("./config/plugin");
|
|
5
5
|
Object.defineProperty(exports, "hasEslintPlugin", { enumerable: true, get: function () { return plugin_1.hasEslintPlugin; } });
|
|
6
|
-
Object.defineProperty(exports, "optionalConfig", { enumerable: true, get: function () { return plugin_1.optionalConfig; } });
|
|
7
|
-
Object.defineProperty(exports, "optionalOverrides", { enumerable: true, get: function () { return plugin_1.optionalOverrides; } });
|
|
8
6
|
Object.defineProperty(exports, "optionalRule", { enumerable: true, get: function () { return plugin_1.optionalRule; } });
|
|
9
|
-
Object.defineProperty(exports, "optionalRules", { enumerable: true, get: function () { return plugin_1.optionalRules; } });
|
package/cypress.js
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
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
|
+
exports.cypressConfig = cypressConfig;
|
|
37
|
+
const tsEslint = __importStar(require("typescript-eslint"));
|
|
38
|
+
const cypress_1 = require("./rules/cypress");
|
|
39
|
+
const no_extraneous_dependencies_1 = require("./rules/import/rules/no-extraneous-dependencies");
|
|
40
|
+
function cypressConfig(files = ['cypress/**/*.[jt]s']) {
|
|
41
|
+
return {
|
|
42
|
+
files,
|
|
43
|
+
languageOptions: Object.assign(Object.assign({}, cypress_1.cypressOptionalConfig.languageOptions), { parser: tsEslint.parser, parserOptions: {
|
|
44
|
+
ecmaVersion: 6,
|
|
45
|
+
ecmaFeatures: {
|
|
46
|
+
globalReturn: false,
|
|
47
|
+
impliedStrict: true,
|
|
48
|
+
},
|
|
49
|
+
sourceType: 'module',
|
|
50
|
+
project: './tsconfig.json',
|
|
51
|
+
warnOnUnsupportedTypeScriptVersion: true,
|
|
52
|
+
} }),
|
|
53
|
+
plugins: Object.assign({}, cypress_1.cypressOptionalConfig.plugins),
|
|
54
|
+
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', {
|
|
55
|
+
capIsNewExceptions: ['Given', 'When', 'Then', 'And', 'But', 'Before', 'After'],
|
|
56
|
+
}] }),
|
|
57
|
+
};
|
|
58
|
+
}
|
package/index.js
CHANGED
|
@@ -1,34 +1,86 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
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"));
|
|
38
|
+
const array_func_1 = require("./rules/array-func");
|
|
39
|
+
const eslint_1 = require("./rules/eslint");
|
|
40
|
+
const eslint_comments_1 = require("./rules/eslint-comments");
|
|
41
|
+
const import_1 = require("./rules/import");
|
|
3
42
|
const no_extraneous_dependencies_1 = require("./rules/import/rules/no-extraneous-dependencies");
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
43
|
+
const jsdoc_1 = require("./rules/jsdoc");
|
|
44
|
+
const n_1 = require("./rules/n");
|
|
45
|
+
const prefer_arrow_1 = require("./rules/prefer-arrow");
|
|
46
|
+
const promise_1 = require("./rules/promise");
|
|
47
|
+
const security_1 = require("./rules/security");
|
|
48
|
+
const simple_import_sort_1 = require("./rules/simple-import-sort");
|
|
49
|
+
const js_1 = require("./rules/stylistic/js");
|
|
50
|
+
const jsx_1 = require("./rules/stylistic/jsx");
|
|
51
|
+
const plus_1 = require("./rules/stylistic/plus");
|
|
52
|
+
const ts_1 = require("./rules/stylistic/ts");
|
|
53
|
+
const typescript_eslint_1 = require("./rules/typescript-eslint");
|
|
54
|
+
const unicorn_1 = require("./rules/unicorn");
|
|
55
|
+
exports.default = [
|
|
56
|
+
{
|
|
57
|
+
ignores: ['**/*.d.ts', '**/dist'],
|
|
7
58
|
},
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
{
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
'
|
|
19
|
-
'./
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
'./rules/unicorn',
|
|
27
|
-
],
|
|
59
|
+
{
|
|
60
|
+
files: ['**/*.[jt]s?(x)'],
|
|
61
|
+
languageOptions: {
|
|
62
|
+
parser: tsEslint.parser,
|
|
63
|
+
parserOptions: {
|
|
64
|
+
ecmaVersion: 6,
|
|
65
|
+
ecmaFeatures: {
|
|
66
|
+
globalReturn: false,
|
|
67
|
+
impliedStrict: true,
|
|
68
|
+
},
|
|
69
|
+
sourceType: 'module',
|
|
70
|
+
project: './tsconfig.json',
|
|
71
|
+
warnOnUnsupportedTypeScriptVersion: true,
|
|
72
|
+
},
|
|
73
|
+
},
|
|
74
|
+
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),
|
|
75
|
+
settings: {
|
|
76
|
+
jsdoc: jsdoc_1.jsdocConfig.settings,
|
|
28
77
|
},
|
|
29
|
-
{
|
|
30
|
-
|
|
31
|
-
|
|
78
|
+
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),
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
files: ['**/*.js?(x)'],
|
|
82
|
+
languageOptions: {
|
|
83
|
+
parser: babelParser,
|
|
32
84
|
parserOptions: {
|
|
33
85
|
ecmaVersion: 6,
|
|
34
86
|
ecmaFeatures: {
|
|
@@ -38,24 +90,27 @@ module.exports = {
|
|
|
38
90
|
sourceType: 'module',
|
|
39
91
|
requireConfigFile: false,
|
|
40
92
|
},
|
|
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
93
|
},
|
|
56
|
-
{
|
|
57
|
-
|
|
58
|
-
|
|
94
|
+
plugins: {},
|
|
95
|
+
settings: {
|
|
96
|
+
'import/extensions': ['.js', '.jsx'],
|
|
97
|
+
},
|
|
98
|
+
rules: {
|
|
99
|
+
'import/no-commonjs': 'off',
|
|
100
|
+
'import/no-extraneous-dependencies': ['error', (0, no_extraneous_dependencies_1.jsImportNoExtraneousDependencies)()],
|
|
101
|
+
'import/unambiguous': 'off',
|
|
102
|
+
'jsdoc/no-types': 'off',
|
|
103
|
+
'jsdoc/no-undefined-types': 'off',
|
|
104
|
+
'jsdoc/require-param': 'error',
|
|
105
|
+
'jsdoc/require-param-type': 'error',
|
|
106
|
+
'jsdoc/require-returns': 'error',
|
|
107
|
+
'jsdoc/require-returns-type': 'error',
|
|
108
|
+
},
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
files: ['**/*.ts?(x)'],
|
|
112
|
+
languageOptions: {
|
|
113
|
+
parser: tsEslint.parser,
|
|
59
114
|
parserOptions: {
|
|
60
115
|
ecmaVersion: 6,
|
|
61
116
|
ecmaFeatures: {
|
|
@@ -66,85 +121,27 @@ module.exports = {
|
|
|
66
121
|
project: './tsconfig.json',
|
|
67
122
|
warnOnUnsupportedTypeScriptVersion: true,
|
|
68
123
|
},
|
|
69
|
-
extends: [
|
|
70
|
-
'./rules/typescript-eslint',
|
|
71
|
-
'./rules/stylistic/ts',
|
|
72
|
-
(0, plugin_1.optionalRules)('rxjs'),
|
|
73
|
-
].filter(Boolean),
|
|
74
|
-
settings: {
|
|
75
|
-
'import/parsers': {
|
|
76
|
-
'@typescript-eslint/parser': [
|
|
77
|
-
'.ts',
|
|
78
|
-
'.tsx',
|
|
79
|
-
],
|
|
80
|
-
},
|
|
81
|
-
'import/resolver': {
|
|
82
|
-
typescript: {
|
|
83
|
-
alwaysTryTypes: true,
|
|
84
|
-
project: './tsconfig.json',
|
|
85
|
-
},
|
|
86
|
-
},
|
|
87
|
-
},
|
|
88
|
-
},
|
|
89
|
-
{
|
|
90
|
-
files: ['*.jsx', '*.tsx'],
|
|
91
|
-
extends: [
|
|
92
|
-
'./rules/stylistic/jsx',
|
|
93
|
-
],
|
|
94
124
|
},
|
|
95
|
-
(
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
'
|
|
99
|
-
|
|
125
|
+
plugins: Object.assign(Object.assign({}, typescript_eslint_1.typescriptEslintConfig.plugins), ts_1.stylisticTsConfig.plugins),
|
|
126
|
+
settings: {
|
|
127
|
+
'import/parsers': {
|
|
128
|
+
'@typescript-eslint/parser': [
|
|
129
|
+
'.ts',
|
|
130
|
+
'.tsx',
|
|
131
|
+
],
|
|
100
132
|
},
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
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
|
-
}],
|
|
133
|
+
'import/resolver': {
|
|
134
|
+
typescript: {
|
|
135
|
+
alwaysTryTypes: true,
|
|
136
|
+
project: './tsconfig.json',
|
|
137
|
+
},
|
|
147
138
|
},
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
}
|
|
139
|
+
},
|
|
140
|
+
rules: Object.assign(Object.assign({}, typescript_eslint_1.typescriptEslintConfig.rules), ts_1.stylisticTsConfig.rules),
|
|
141
|
+
},
|
|
142
|
+
{
|
|
143
|
+
files: ['**/*.js?(x)'],
|
|
144
|
+
plugins: Object.assign({}, jsx_1.stylisticJsxConfig.plugins),
|
|
145
|
+
rules: Object.assign({}, jsx_1.stylisticJsxConfig.rules),
|
|
146
|
+
},
|
|
147
|
+
].filter(Boolean);
|
package/jest-dom.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.jestDomConfig = jestDomConfig;
|
|
4
|
+
const jest_dom_1 = require("./rules/jest-dom");
|
|
5
|
+
function jestDomConfig(files = ['**/*.@(spec|test).[jt]s?(x)']) {
|
|
6
|
+
return {
|
|
7
|
+
files,
|
|
8
|
+
plugins: jest_dom_1.jestDomConfig.plugins,
|
|
9
|
+
rules: jest_dom_1.jestDomConfig.rules,
|
|
10
|
+
};
|
|
11
|
+
}
|