@perfective/eslint-config 0.18.0-beta → 0.18.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 CHANGED
@@ -1,19 +1,18 @@
1
1
  = Perfective ESLint Config
2
2
 
3
3
  `@perfective/eslint-config` provides
4
- a https://eslint.org/docs/developer-guide/shareable-configs[shareable ESLint configuration]
4
+ a https://eslint.org/docs/latest/developer-guide/shareable-configs[shareable ESLint configuration]
5
5
  that is used for the development of the `@perfective` packages.
6
- As the `@perfective` library itself,
7
- these rules are configured for the TypeScript projects only.
6
+ These rules are primarily configured for TypeScript projects.
8
7
 
9
- In addition to the core https://eslint.org/docs/rules/[ESLint rules]
8
+ In addition to the core https://eslint.org/docs/latest/rules/[ESLint rules]
10
9
  and the `link:https://typescript-eslint.io/rules/[@typescript-eslint]` plugin rules,
11
10
  `@perfective/eslint-config` configures:
12
11
 
13
12
  * `link:https://github.com/freaktechnik/eslint-plugin-array-func[eslint-plugin-array-func]`;
14
13
  * `link:https://github.com/cypress-io/eslint-plugin-cypress[eslint-plugin-cypress]`;
15
14
  * `link:https://github.com/gund/eslint-plugin-deprecation[eslint-plugin-deprecation]`;
16
- * `link:https://mysticatea.github.io/eslint-plugin-eslint-comments[eslint-plugin-eslint-comments]`;
15
+ * `link:https://mysticatea.github.io/eslint-plugin-eslint-comments/]`;
17
16
  * `link:https://github.com/import-js/eslint-plugin-import[eslint-plugin-import]`;
18
17
  * `link:https://github.com/jest-community/eslint-plugin-jest[eslint-plugin-jest]`;
19
18
  * `link:https://github.com/testing-library/eslint-plugin-jest-dom[eslint-plugin-jest-dom]`;
@@ -29,8 +28,8 @@ and the `link:https://typescript-eslint.io/rules/[@typescript-eslint]` plugin ru
29
28
  * `link:https://github.com/sindresorhus/eslint-plugin-unicorn[eslint-plugin-unicorn]`.
30
29
 
31
30
  To simplify configuring ESLint support in the IDEs and editors,
32
- the severity of all fixable rules is `warning`.
33
- That allows to visually distinguish errors that have to be fixed manually
31
+ the severity of all fixable rules is a `warning`.
32
+ In addition, it allows distinguishing errors that have to be fixed manually
34
33
  from issues that will be fixed automatically.
35
34
 
36
35
 
@@ -68,32 +67,34 @@ npm install --save-dev \
68
67
  tslint
69
68
  ----
70
69
  +
71
- . Require the configuration in your root `.eslintrc.js` or `.eslintrc.json`.
70
+ . Require the configuration in your root `.eslintrc.js`.
72
71
  +
73
- [source,json]
72
+ [source,javascript]
74
73
  ----
75
- {
76
- "extends": ["@perfective"]
77
- }
74
+ module.exports = {
75
+ extends: [
76
+ '@perfective/eslint-config',
77
+ ],
78
+ };
78
79
  ----
79
80
  +
80
81
  . `*.d.ts` files and `dist` directories are ignored by the configuration.
81
82
  `node_modules` and dot-files are ignored by the `eslint`.
82
- If more directories or file-types need to be ignored, see the
83
+ If more directories or file types need to be ignored, see the
83
84
  `link:https://eslint.org/docs/user-guide/configuring/ignoring-code#the-eslintignore-file[.eslintignore]` file docs.
84
85
 
85
86
  == Rules Configuration Extension Functions
86
87
 
87
88
  Some rules have complex configuration objects or arrays
88
- that are not merged but completely overridden by ESLint.
89
- It requires to copy/paste a rule config, instead of just extending it.
90
- This is a challenge to maintain rules updates,
91
- which is solved by providing custom config functions.
89
+ that are not merged but are completely overridden by ESLint.
90
+ Therefore, it requires copying and pasting a rule config instead of just extending it.
91
+ Maintaining rules updates is challenging
92
+ and is simplified by the custom config functions.
92
93
 
93
- These functions and their related types are exported in `@perfective/eslint-config/rules`
94
+ These functions and related types are exported in `@perfective/eslint-config/rules`
94
95
  and match the rule name in `camelCase`.
95
- When an extended configuration is needed,
96
- it can be applied in the `.eslintrc.js` file:
96
+ If you need an extended configuration,
97
+ you can use these functions in the `.eslintrc.js` file:
97
98
 
98
99
  [source,javascript]
99
100
  ----
@@ -122,14 +123,14 @@ for the `simple-import-sort/imports` rule.
122
123
  — overrides `rules` and provides custom `directories`
123
124
  for the `@typescript-eslint/tslint/config` rule.
124
125
  * `unicornPreventAbbreviations(replacements, options)`
125
- — extends and overrides the list of `replacements`,
126
- and override `options` for the `unicorn/prevent-abbreviation` rule.
126
+ — extends and overrides the list of `replacements`
127
+ and `options` for the `unicorn/prevent-abbreviation` rule.
127
128
 
128
129
 
129
130
  == TSLint
130
131
 
131
132
  ESLint and its plugins replace most of the https://palantir.github.io/tslint/[TSLint] rules.
132
- Yet, there are few rules that still need to be supported.
133
+ Yet, a few rules still need to be supported.
133
134
  TSLint rules are executed using the
134
135
  https://github.com/typescript-eslint/typescript-eslint/tree/main/packages/eslint-plugin-tslint[ESLint Plugin TSLint].
135
136
 
@@ -150,35 +151,25 @@ export = {
150
151
  }
151
152
  }
152
153
  ----
153
- <1> Overriding only one of the rules,
154
+ <1> Overrides only one of the rules
154
155
  while keeping all others set by default.
155
156
 
156
157
 
157
158
  == Internals
158
159
 
159
- Rule for each plugin are described in the `./src/rules/{plugin}` subdirectories,
160
- where `plugin` is the name of the plugin (`eslint-plugin-` prefix).
160
+ The rules for each plugin are described in the `./src/rules/{plugin}` subdirectories,
161
+ where the `{plugin}` is the name of the plugin (after the `eslint-plugin-` prefix).
161
162
  Each configuration is exported from the `./index.ts` file
162
163
  and is organized as a partial ESLint config.
163
164
  It should contain the plugin name and the list of the rules, sorted alphabetically.
164
165
  When a plugin's documentation groups rules,
165
- each group is configured in its own file
166
+ each group is configured in a separate file
166
167
  and then extended in the `./index.ts` file.
167
168
 
168
- The final configuration extends each plugin configuration on the file-type basis.
169
+ The final configuration extends each plugin configuration on a file-type basis.
169
170
 
170
171
 
171
172
  == Roadmap
172
173
 
173
- * Add `@perfective/eslint-plugin` with the rules for working with the `@perfective` library.
174
+ * Add the `@perfective/eslint-plugin` with the rules for working with the `@perfective` packages.
174
175
  * Replace all TSLint rules with ESLint rules.
175
-
176
-
177
- == Legacy
178
-
179
- Starting from version `0.11.0` the project was extracted into its own repository
180
- `link:https://github.com/perfective/eslint-config[@perfective/eslint-config]` from the original
181
- `link:https://github.com/perfective/js[@perfective/js]` monorepo.
182
- Its Git repository was rebuilt using `git filter-branch` to preserve commit log.
183
- Legacy commits cannot be used for rollbacks and debug,
184
- as there is no `package-lock.json`.
package/README.md CHANGED
@@ -1,19 +1,17 @@
1
1
  # Perfective ESLint Config
2
2
 
3
3
  `@perfective/eslint-config` provides
4
- a [shareable ESLint configuration](https://eslint.org/docs/developer-guide/shareable-configs)
4
+ a [shareable ESLint configuration](https://eslint.org/docs/latest/developer-guide/shareable-configs)
5
5
  that is used for the development of the `@perfective` packages.
6
- As the `@perfective` library itself,
7
- these rules are configured for the TypeScript projects only.
6
+ These rules are primarily configured for TypeScript projects.
8
7
 
9
- In addition to the core [ESLint rules](https://eslint.org/docs/rules/)
10
- and the [`@typescript-eslint`](https://typescript-eslint.io/rules/) plugin rules,
11
- `@perfective/eslint-config` configures:
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:
12
10
 
13
11
  - [`eslint-plugin-array-func`](https://github.com/freaktechnik/eslint-plugin-array-func);
14
12
  - [`eslint-plugin-cypress`](https://github.com/cypress-io/eslint-plugin-cypress);
15
13
  - [`eslint-plugin-deprecation`](https://github.com/gund/eslint-plugin-deprecation);
16
- - [`eslint-plugin-eslint-comments`](https://mysticatea.github.io/eslint-plugin-eslint-comments);
14
+ - [`eslint-plugin-eslint-comments`](https://mysticatea.github.io/eslint-plugin-eslint-comments/);
17
15
  - [`eslint-plugin-import`](https://github.com/import-js/eslint-plugin-import);
18
16
  - [`eslint-plugin-jest`](https://github.com/jest-community/eslint-plugin-jest);
19
17
  - [`eslint-plugin-jest-dom`](https://github.com/testing-library/eslint-plugin-jest-dom);
@@ -29,8 +27,8 @@ and the [`@typescript-eslint`](https://typescript-eslint.io/rules/) plugin rules
29
27
  - [`eslint-plugin-unicorn`](https://github.com/sindresorhus/eslint-plugin-unicorn).
30
28
 
31
29
  To simplify configuring ESLint support in the IDEs and editors,
32
- the severity of all fixable rules is `warning`.
33
- That allows to visually distinguish errors that have to be fixed manually
30
+ the severity of all fixable rules is a `warning`.
31
+ In addition, it allows distinguishing errors that have to be fixed manually
34
32
  from issues that will be fixed automatically.
35
33
 
36
34
  ## Setup
@@ -66,18 +64,18 @@ npm install --save-dev \
66
64
  tslint
67
65
  ```
68
66
 
69
- Require the configuration in your root `.eslintrc.js` or `.eslintrc.json`.
67
+ Require the configuration in your root `.eslintrc.js`.
70
68
 
71
- ```json
72
- {
73
- "extends": ["@perfective"]
74
- }
69
+ ```javascript
70
+ module.exports = {
71
+ extends: ['@perfective/eslint-config'],
72
+ };
75
73
  ```
76
74
 
77
75
  ## TSLint
78
76
 
79
77
  ESLint and its plugins replace most of the [TSLint](https://palantir.github.io/tslint/) rules.
80
- Yet, there are few rules that still need to be supported.
78
+ Yet, a few rules still need to be supported.
81
79
  TSLint rules are executed using the
82
80
  [ESLint Plugin TSLint](https://github.com/typescript-eslint/typescript-eslint/tree/main/packages/eslint-plugin-tslint).
83
81
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@perfective/eslint-config",
3
- "version": "0.18.0-beta",
3
+ "version": "0.18.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>",
@@ -11,18 +11,18 @@
11
11
  },
12
12
  "license": "MIT",
13
13
  "peerDependencies": {
14
- "@babel/eslint-parser": "^7.17.0",
15
- "@typescript-eslint/eslint-plugin": "^5.30.5",
16
- "@typescript-eslint/eslint-plugin-tslint": "^5.30.5",
17
- "@typescript-eslint/parser": "^5.30.5",
18
- "eslint": "^8.19.0",
19
- "eslint-import-resolver-typescript": "^3.2.4",
14
+ "@babel/eslint-parser": "^7.18.9",
15
+ "@typescript-eslint/eslint-plugin": "^5.31.0",
16
+ "@typescript-eslint/eslint-plugin-tslint": "^5.31.0",
17
+ "@typescript-eslint/parser": "^5.31.0",
18
+ "eslint": "^8.20.0",
19
+ "eslint-import-resolver-typescript": "~3.3.0",
20
20
  "eslint-plugin-array-func": "^3.1.7",
21
21
  "eslint-plugin-cypress": "^2.12.1",
22
22
  "eslint-plugin-deprecation": "^1.3.2",
23
23
  "eslint-plugin-eslint-comments": "^3.2.0",
24
24
  "eslint-plugin-import": "^2.26.0",
25
- "eslint-plugin-jest": "^26.5.3",
25
+ "eslint-plugin-jest": "^26.6.0",
26
26
  "eslint-plugin-jest-dom": "^4.0.2",
27
27
  "eslint-plugin-jest-formatting": "^3.1.0",
28
28
  "eslint-plugin-jsdoc": "^39.3.3",
@@ -31,13 +31,12 @@
31
31
  "eslint-plugin-promise": "^6.0.0",
32
32
  "eslint-plugin-rxjs": "^5.0.2",
33
33
  "eslint-plugin-simple-import-sort": "^7.0.0",
34
- "eslint-plugin-sonarjs": "^0.13.0",
34
+ "eslint-plugin-sonarjs": "^0.14.0",
35
35
  "eslint-plugin-testing-library": "^5.5.1",
36
- "eslint-plugin-unicorn": "^43.0.0",
36
+ "eslint-plugin-unicorn": "^43.0.2",
37
37
  "tslint": "^6.1.3"
38
38
  },
39
39
  "main": "./index.js",
40
- "types": "./index.d.ts",
41
40
  "directories": {
42
41
  "lib": "./"
43
42
  },
@@ -15,6 +15,9 @@ module.exports = {
15
15
  assertFunctionNames: ['expect', 'request.*.expect'],
16
16
  additionalTestBlockFunctions: [],
17
17
  }],
18
+ 'jest/max-expects': ['error', {
19
+ max: 5,
20
+ }],
18
21
  'jest/max-nested-describe': ['error', {
19
22
  max: 3,
20
23
  }],
@@ -188,7 +188,11 @@ module.exports = {
188
188
  allowBitwiseExpressions: true,
189
189
  }],
190
190
  '@typescript-eslint/prefer-namespace-keyword': 'warn',
191
- '@typescript-eslint/prefer-nullish-coalescing': 'error',
191
+ '@typescript-eslint/prefer-nullish-coalescing': ['error', {
192
+ ignoreTernaryTests: false,
193
+ ignoreConditionalTests: true,
194
+ ignoreMixedLogicalExpressions: true,
195
+ }],
192
196
  '@typescript-eslint/prefer-optional-chain': 'error',
193
197
  '@typescript-eslint/prefer-readonly': 'warn',
194
198
  '@typescript-eslint/prefer-readonly-parameter-types': 'off',