@perfective/eslint-config 0.20.0 → 0.21.0-alpha

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 CHANGED
@@ -7,12 +7,12 @@ These rules are primarily configured for TypeScript projects.
7
7
 
8
8
  In addition to the core https://eslint.org/docs/latest/rules/[ESLint rules]
9
9
  and the `link:https://typescript-eslint.io/rules/[@typescript-eslint]` plugin rules,
10
- `@perfective/eslint-config` configures:
10
+ `@perfective/eslint-config` includes configurations for the ESLint plugins:
11
11
 
12
12
  * `link:https://github.com/freaktechnik/eslint-plugin-array-func[eslint-plugin-array-func]`;
13
- * `link:https://github.com/cypress-io/eslint-plugin-cypress[eslint-plugin-cypress]`;
13
+ * `link:https://github.com/cypress-io/eslint-plugin-cypress[eslint-plugin-cypress]` _(optional)_;
14
14
  * `link:https://github.com/gund/eslint-plugin-deprecation[eslint-plugin-deprecation]`;
15
- * `link:https://mysticatea.github.io/eslint-plugin-eslint-comments/]`;
15
+ * `link:https://mysticatea.github.io/eslint-plugin-eslint-comments/[eslint-plugin-eslint-comments]`;
16
16
  * `link:https://github.com/import-js/eslint-plugin-import[eslint-plugin-import]`;
17
17
  * `link:https://github.com/jest-community/eslint-plugin-jest[eslint-plugin-jest]`;
18
18
  * `link:https://github.com/testing-library/eslint-plugin-jest-dom[eslint-plugin-jest-dom]`;
@@ -48,7 +48,6 @@ npm install --save-dev \
48
48
  eslint \
49
49
  eslint-import-resolver-typescript \
50
50
  eslint-plugin-array-func \
51
- eslint-plugin-cypress \
52
51
  eslint-plugin-deprecation \
53
52
  eslint-plugin-eslint-comments \
54
53
  eslint-plugin-import \
@@ -67,6 +66,20 @@ npm install --save-dev \
67
66
  tslint
68
67
  ----
69
68
  +
69
+ . Install optional peer dependencies that add linting rules for the tools you use.
70
+ +
71
+ [source,bash]
72
+ ----
73
+ npm install --save-dev \
74
+ eslint-plugin-cypress
75
+ ----
76
+ +
77
+ [NOTE]
78
+ ====
79
+ The `@perfective/eslint-config` automatically includes rules for these plugins,
80
+ if the dependency is installed.
81
+ ====
82
+ +
70
83
  . Require the configuration in your root `.eslintrc.js`.
71
84
  +
72
85
  [source,javascript]
package/README.md CHANGED
@@ -6,10 +6,11 @@ that is used for the development of the `@perfective` packages.
6
6
  These rules are primarily configured for TypeScript projects.
7
7
 
8
8
  In addition to the core [ESLint rules](https://eslint.org/docs/latest/rules/)
9
- and the [`@typescript-eslint`](https://typescript-eslint.io/rules/) plugin rules, `@perfective/eslint-config` configures:
9
+ and the [`@typescript-eslint`](https://typescript-eslint.io/rules/) plugin rules,
10
+ `@perfective/eslint-config` includes configurations for the ESLint plugins:
10
11
 
11
12
  - [`eslint-plugin-array-func`](https://github.com/freaktechnik/eslint-plugin-array-func);
12
- - [`eslint-plugin-cypress`](https://github.com/cypress-io/eslint-plugin-cypress);
13
+ - [`eslint-plugin-cypress`](https://github.com/cypress-io/eslint-plugin-cypress) _(optional)_;
13
14
  - [`eslint-plugin-deprecation`](https://github.com/gund/eslint-plugin-deprecation);
14
15
  - [`eslint-plugin-eslint-comments`](https://mysticatea.github.io/eslint-plugin-eslint-comments/);
15
16
  - [`eslint-plugin-import`](https://github.com/import-js/eslint-plugin-import);
@@ -33,44 +34,53 @@ from issues that will be fixed automatically.
33
34
 
34
35
  ## Setup
35
36
 
36
- Require `@perfective/eslint-config` and its peer dependencies as dev dependencies.
37
+ 1. Require `@perfective/eslint-config` and its peer dependencies as dev dependencies.
37
38
 
38
- ```bash
39
- npm install --save-dev \
40
- @perfective/eslint-config \
41
- @babel/eslint-parser \
42
- @typescript-eslint/eslint-plugin \
43
- @typescript-eslint/eslint-plugin-tslint \
44
- @typescript-eslint/parser \
45
- eslint \
46
- eslint-import-resolver-typescript \
47
- eslint-plugin-array-func \
48
- eslint-plugin-cypress \
49
- eslint-plugin-deprecation \
50
- eslint-plugin-eslint-comments \
51
- eslint-plugin-import \
52
- eslint-plugin-jest \
53
- eslint-plugin-jest-dom \
54
- eslint-plugin-jest-formatting \
55
- eslint-plugin-jsdoc \
56
- eslint-plugin-node \
57
- eslint-plugin-prefer-arrow \
58
- eslint-plugin-promise \
59
- eslint-plugin-rxjs \
60
- eslint-plugin-simple-import-sort \
61
- eslint-plugin-sonarjs \
62
- eslint-plugin-testing-library \
63
- eslint-plugin-unicorn \
64
- tslint
65
- ```
39
+ ```bash
40
+ npm install --save-dev \
41
+ @perfective/eslint-config \
42
+ @babel/eslint-parser \
43
+ @typescript-eslint/eslint-plugin \
44
+ @typescript-eslint/eslint-plugin-tslint \
45
+ @typescript-eslint/parser \
46
+ eslint \
47
+ eslint-import-resolver-typescript \
48
+ eslint-plugin-array-func \
49
+ eslint-plugin-deprecation \
50
+ eslint-plugin-eslint-comments \
51
+ eslint-plugin-import \
52
+ eslint-plugin-jest \
53
+ eslint-plugin-jest-dom \
54
+ eslint-plugin-jest-formatting \
55
+ eslint-plugin-jsdoc \
56
+ eslint-plugin-node \
57
+ eslint-plugin-prefer-arrow \
58
+ eslint-plugin-promise \
59
+ eslint-plugin-rxjs \
60
+ eslint-plugin-simple-import-sort \
61
+ eslint-plugin-sonarjs \
62
+ eslint-plugin-testing-library \
63
+ eslint-plugin-unicorn \
64
+ tslint
65
+ ```
66
66
 
67
- Require the configuration in your root `.eslintrc.js`.
67
+ 2. Install optional peer dependencies that add linting rules for the tools you use.
68
68
 
69
- ```javascript
70
- module.exports = {
71
- extends: ['@perfective/eslint-config'],
72
- };
73
- ```
69
+ ```bash
70
+ npm install --save-dev \
71
+ eslint-plugin-cypress
72
+ ```
73
+
74
+ The `@perfective/eslint-config` automatically includes rules for these plugins,
75
+ if the dependency is installed.
76
+
77
+ 3. Require the configuration in your root `.eslintrc.js`.
78
+
79
+ ```javascript
80
+ module.exports = {
81
+ extends: ['@perfective/eslint-config'],
82
+ };
83
+ ```
74
84
 
75
85
  ## TSLint
76
86
 
package/config/node.js ADDED
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.hasNodeModule = void 0;
4
+ function hasNodeModule(module) {
5
+ try {
6
+ return Boolean(require.resolve(module));
7
+ }
8
+ catch (_a) {
9
+ return false;
10
+ }
11
+ }
12
+ exports.hasNodeModule = hasNodeModule;
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.hasEslintPlugin = exports.optionalOverrides = exports.optionalConfig = void 0;
4
+ const node_1 = require("./node");
5
+ function optionalConfig(plugin, rules) {
6
+ if (hasEslintPlugin(plugin)) {
7
+ return {
8
+ plugins: [plugin],
9
+ rules,
10
+ };
11
+ }
12
+ return {};
13
+ }
14
+ exports.optionalConfig = optionalConfig;
15
+ function optionalOverrides(plugin, overrides) {
16
+ if (hasEslintPlugin(plugin)) {
17
+ return overrides;
18
+ }
19
+ return null;
20
+ }
21
+ exports.optionalOverrides = optionalOverrides;
22
+ function hasEslintPlugin(plugin) {
23
+ if (plugin.startsWith('@')) {
24
+ return (0, node_1.hasNodeModule)(`${plugin}/eslint-plugin`);
25
+ }
26
+ return (0, node_1.hasNodeModule)(`eslint-plugin-${plugin}`);
27
+ }
28
+ exports.hasEslintPlugin = hasEslintPlugin;
package/index.js CHANGED
@@ -1,4 +1,5 @@
1
1
  "use strict";
2
+ const plugin_1 = require("./config/plugin");
2
3
  const no_extraneous_dependencies_1 = require("./rules/import/rules/no-extraneous-dependencies");
3
4
  module.exports = {
4
5
  env: {
@@ -113,7 +114,7 @@ module.exports = {
113
114
  'rxjs/no-topromise': 'off',
114
115
  },
115
116
  },
116
- {
117
+ (0, plugin_1.optionalOverrides)('cypress', {
117
118
  files: ['cypress/**/*.[jt]s'],
118
119
  env: {
119
120
  'cypress/globals': true,
@@ -130,6 +131,6 @@ module.exports = {
130
131
  capIsNewExceptions: ['Given', 'When', 'Then', 'And', 'But', 'Before', 'After'],
131
132
  }],
132
133
  },
133
- },
134
- ],
134
+ }),
135
+ ].filter(Boolean),
135
136
  };
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@perfective/eslint-config",
3
- "version": "0.20.0",
3
+ "version": "0.21.0-alpha",
4
4
  "description": "ESLint shareable rules configuration",
5
- "keywords": ["code quality", "code standard", "code style", "eslint", "eslint-config", "lint", "perfective", "tslint", "tslint-config", "typescript"],
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>",
7
7
  "homepage": "https://github.com/perfective/eslint-config",
8
8
  "repository": {
@@ -11,31 +11,36 @@
11
11
  },
12
12
  "license": "MIT",
13
13
  "peerDependencies": {
14
- "@babel/eslint-parser": "^7.19.1",
15
- "@typescript-eslint/eslint-plugin": "^5.53.0",
16
- "@typescript-eslint/eslint-plugin-tslint": "^5.53.0",
17
- "@typescript-eslint/parser": "^5.53.0",
18
- "eslint": "^8.34.0",
14
+ "@babel/eslint-parser": "^7.21.3",
15
+ "@typescript-eslint/eslint-plugin": "^5.57.0",
16
+ "@typescript-eslint/eslint-plugin-tslint": "^5.57.0",
17
+ "@typescript-eslint/parser": "^5.57.0",
18
+ "eslint": "^8.37.0",
19
19
  "eslint-import-resolver-typescript": "^3.5.3",
20
20
  "eslint-plugin-array-func": "^3.1.8",
21
- "eslint-plugin-cypress": "^2.12.1",
21
+ "eslint-plugin-cypress": "^2.13.1",
22
22
  "eslint-plugin-deprecation": "^1.3.3",
23
23
  "eslint-plugin-eslint-comments": "^3.2.0",
24
24
  "eslint-plugin-import": "^2.27.5",
25
25
  "eslint-plugin-jest": "^27.2.1",
26
26
  "eslint-plugin-jest-dom": "^4.0.3",
27
27
  "eslint-plugin-jest-formatting": "^3.1.0",
28
- "eslint-plugin-jsdoc": "^40.0.0",
28
+ "eslint-plugin-jsdoc": "^40.1.0",
29
29
  "eslint-plugin-node": "^11.1.0",
30
30
  "eslint-plugin-prefer-arrow": "^1.2.3",
31
31
  "eslint-plugin-promise": "^6.1.1",
32
- "eslint-plugin-rxjs": "^5.0.2",
32
+ "eslint-plugin-rxjs": "^5.0.3",
33
33
  "eslint-plugin-simple-import-sort": "^10.0.0",
34
- "eslint-plugin-sonarjs": "^0.18.0",
34
+ "eslint-plugin-sonarjs": "^0.19.0",
35
35
  "eslint-plugin-testing-library": "^5.10.2",
36
- "eslint-plugin-unicorn": "^45.0.2",
36
+ "eslint-plugin-unicorn": "^46.0.0",
37
37
  "tslint": "^6.1.3"
38
38
  },
39
+ "peerDependenciesMeta": {
40
+ "eslint-plugin-cypress": {
41
+ "optional": true
42
+ }
43
+ },
39
44
  "main": "./index.js",
40
45
  "directories": {
41
46
  "lib": "./"
@@ -1,15 +1,11 @@
1
1
  "use strict";
2
- module.exports = {
3
- plugins: [
4
- 'cypress',
5
- ],
6
- rules: {
7
- 'cypress/assertion-before-screenshot': 'error',
8
- 'cypress/no-assigning-return-values': 'error',
9
- 'cypress/no-async-tests': 'error',
10
- 'cypress/no-force': 'error',
11
- 'cypress/no-pause': 'error',
12
- 'cypress/no-unnecessary-waiting': 'error',
13
- 'cypress/require-data-selectors': 'error',
14
- },
15
- };
2
+ const plugin_1 = require("../../config/plugin");
3
+ module.exports = (0, plugin_1.optionalConfig)('cypress', {
4
+ 'cypress/assertion-before-screenshot': 'error',
5
+ 'cypress/no-assigning-return-values': 'error',
6
+ 'cypress/no-async-tests': 'error',
7
+ 'cypress/no-force': 'error',
8
+ 'cypress/no-pause': 'error',
9
+ 'cypress/no-unnecessary-waiting': 'error',
10
+ 'cypress/require-data-selectors': 'error',
11
+ });
@@ -67,6 +67,7 @@ module.exports = {
67
67
  allowArrayEnd: false,
68
68
  allowClassStart: true,
69
69
  allowClassEnd: false,
70
+ afterHashbangComment: true,
70
71
  }],
71
72
  'lines-between-class-members': ['warn', 'always', {
72
73
  exceptAfterSingleLine: true,
@@ -44,7 +44,9 @@ module.exports = {
44
44
  'max-statements': ['off', {
45
45
  max: 10,
46
46
  }],
47
- 'multiline-comment-style': ['warn', 'separate-lines'],
47
+ 'multiline-comment-style': ['warn', 'separate-lines', {
48
+ checkJSDoc: false,
49
+ }],
48
50
  'new-cap': ['error', {
49
51
  newIsCap: true,
50
52
  capIsNew: true,
@@ -51,6 +51,25 @@ module.exports = {
51
51
  before: true,
52
52
  after: true,
53
53
  }],
54
+ 'lines-around-comment': 'off',
55
+ '@typescript-eslint/lines-around-comment': ['warn', {
56
+ beforeBlockComment: true,
57
+ afterBlockComment: false,
58
+ beforeLineComment: false,
59
+ afterLineComment: false,
60
+ allowBlockStart: false,
61
+ allowBlockEnd: false,
62
+ allowObjectStart: false,
63
+ allowObjectEnd: false,
64
+ allowArrayStart: false,
65
+ allowArrayEnd: false,
66
+ allowClassStart: true,
67
+ allowClassEnd: false,
68
+ allowInterfaceStart: true,
69
+ allowInterfaceEnd: true,
70
+ allowTypeStart: true,
71
+ allowTypeEnd: true,
72
+ }],
54
73
  'lines-between-class-members': 'off',
55
74
  '@typescript-eslint/lines-between-class-members': ['warn', 'always', {
56
75
  exceptAfterSingleLine: true,
@@ -125,6 +125,10 @@ module.exports = {
125
125
  ignoreVoidOperator: false,
126
126
  }],
127
127
  '@typescript-eslint/no-duplicate-enum-values': 'error',
128
+ '@typescript-eslint/no-duplicate-type-constituents': ['error', {
129
+ ignoreIntersections: false,
130
+ ignoreUnions: false,
131
+ }],
128
132
  '@typescript-eslint/no-dynamic-delete': 'warn',
129
133
  '@typescript-eslint/no-empty-interface': ['off', {
130
134
  allowSingleExtends: true,
@@ -226,6 +230,7 @@ module.exports = {
226
230
  allowNullish: false,
227
231
  allowNumber: false,
228
232
  allowRegExp: false,
233
+ allowNever: false,
229
234
  }],
230
235
  '@typescript-eslint/sort-type-union-intersection-members': ['off', {
231
236
  checkIntersections: true,