eslint-config-beslogic 3.0.0 → 3.0.2
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 +6 -1
- package/README.md +5 -3
- package/javascript.js +38 -29
- package/jest.js +17 -10
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
-
##
|
|
3
|
+
## 3.0.2
|
|
4
|
+
|
|
5
|
+
- Made `eslint-plugin-sonarjs` optional for pre-commit.ci contexts
|
|
6
|
+
|
|
7
|
+
## 3.0.0
|
|
4
8
|
|
|
5
9
|
### Important migration points
|
|
6
10
|
|
|
@@ -13,6 +17,7 @@
|
|
|
13
17
|
- If you only have `tsconfig.json` files and no complex `tsconfig.*.json`, you can also try this instead:
|
|
14
18
|
|
|
15
19
|
```js
|
|
20
|
+
/** @type {import("eslint").Linter.Config} */
|
|
16
21
|
module.exports = {
|
|
17
22
|
parserOptions: {
|
|
18
23
|
projectService: {
|
package/README.md
CHANGED
|
@@ -91,16 +91,18 @@ As you'll easily bust the 250MiB limit on the free tier, omit the following depe
|
|
|
91
91
|
|
|
92
92
|
- `dprint`
|
|
93
93
|
- `@eslint-community/eslint-plugin-eslint-comments`
|
|
94
|
-
- `eslint-import-resolver-typescript`
|
|
95
94
|
- `esling-plugin-no-autofix`
|
|
96
|
-
- `eslint-
|
|
95
|
+
- `eslint-import-resolver-typescript`
|
|
96
|
+
- `eslint-plugin-etc`
|
|
97
97
|
- `eslint-plugin-jest-formatting`
|
|
98
98
|
- `eslint-plugin-jest`
|
|
99
|
-
- `eslint-plugin-
|
|
99
|
+
- `eslint-plugin-sonarjs`
|
|
100
|
+
- `eslint-plugin-testing-library`
|
|
100
101
|
|
|
101
102
|
If using TypeScript and pre-commit.ci, in your ESLint config you'll _have to_ use the project service, or you'll run into OOM issues:
|
|
102
103
|
|
|
103
104
|
```js
|
|
105
|
+
/** @type {import("eslint").Linter.Config} */
|
|
104
106
|
module.exports = {
|
|
105
107
|
parser: "@typescript-eslint/parser",
|
|
106
108
|
parserOptions: {
|
package/javascript.js
CHANGED
|
@@ -17,6 +17,9 @@ const hasNoAutofix = !!resolveModuleLocation("eslint-plugin-no-autofix")
|
|
|
17
17
|
// @eslint-community/eslint-comments' only autofix is removing unused suppression comments
|
|
18
18
|
// Some rules get globally disabled for pre-commit.ci, so finding unused comments is expected
|
|
19
19
|
const hasEslintComments = !!resolveModuleLocation("@eslint-community/eslint-plugin-eslint-comments")
|
|
20
|
+
// eslint-plugin-sonarjs@2 pulls in a ton of extra dependnecies we don't need
|
|
21
|
+
// https://community.sonarsource.com/t/warning-react-version-not-specified-in-eslint-plugin-react/125412/11?u=avasam
|
|
22
|
+
const hasSonarJS = !!resolveModuleLocation("eslint-plugin-sonarjs")
|
|
20
23
|
|
|
21
24
|
const noRestrictedSyntax = [
|
|
22
25
|
"error",
|
|
@@ -52,7 +55,9 @@ module.exports = {
|
|
|
52
55
|
],
|
|
53
56
|
"extends": [
|
|
54
57
|
"eslint:recommended",
|
|
55
|
-
|
|
58
|
+
...hasSonarJS
|
|
59
|
+
? ["plugin:sonarjs/recommended-legacy"] // "legacy" is for ESLint v8 compatibility
|
|
60
|
+
: [],
|
|
56
61
|
"plugin:unicorn/all",
|
|
57
62
|
"plugin:regexp/all",
|
|
58
63
|
"plugin:import/recommended",
|
|
@@ -322,33 +327,37 @@ module.exports = {
|
|
|
322
327
|
}
|
|
323
328
|
: {},
|
|
324
329
|
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
330
|
+
...hasSonarJS
|
|
331
|
+
? {
|
|
332
|
+
/*
|
|
333
|
+
* sonarjs/recommended overrides (https://github.com/SonarSource/SonarJS/blob/master/packages/jsts/src/rules/README.md#rules)
|
|
334
|
+
*/
|
|
335
|
+
// Same as eslint (cyclomatic) complexity
|
|
336
|
+
// This is also based on the fact that react-app service workers template hits this
|
|
337
|
+
"sonarjs/cognitive-complexity": [
|
|
338
|
+
"warn",
|
|
339
|
+
20
|
|
340
|
+
],
|
|
341
|
+
// False-positives with top-level Promises (and maybe more, but that was enough for me ot disable)
|
|
342
|
+
"sonarjs/constructor-for-side-effects": "off",
|
|
343
|
+
"sonarjs/deprecation": "warn",
|
|
344
|
+
"sonarjs/no-duplicate-string": "error",
|
|
345
|
+
// Duplicates etc/no-commented-out-code. But is faster but also catches less.
|
|
346
|
+
// Incidentally this is good for a non-strict config.
|
|
347
|
+
"sonarjs/no-commented-code": "error",
|
|
348
|
+
// Too annoying, let us use our lovely PATH :)
|
|
349
|
+
"sonarjs/no-os-command-from-path": "off",
|
|
350
|
+
// Too annoying, consider maybe for an extra-strict
|
|
351
|
+
// but JS doesn't have kw params unlike Python
|
|
352
|
+
"sonarjs/no-selector-parameter": "off",
|
|
353
|
+
// Is default, but let's note that this option replaced `eslint-plugin-unused-imports` entirely,
|
|
354
|
+
// so if there's an issue, we can always go back.
|
|
355
|
+
"sonarjs/unused-import": "error",
|
|
356
|
+
// TODO: Raise an issue. Also mention that online doc examples sees to be inverted
|
|
357
|
+
// False-positives using Intl.DateTimeFormat()
|
|
358
|
+
"sonarjs/new-cap": "off"
|
|
359
|
+
}
|
|
360
|
+
: {},
|
|
352
361
|
|
|
353
362
|
/*
|
|
354
363
|
* eslint-plugin-sonarjs@2 added rules that duplicate base ESLint rules or specific plugins we prefer
|
|
@@ -365,7 +374,7 @@ module.exports = {
|
|
|
365
374
|
"sonarjs/default-param-last": "off",
|
|
366
375
|
"sonarjs/no-delete-var": "off",
|
|
367
376
|
"sonarjs/no-empty-function": "off",
|
|
368
|
-
"sonarjs/no-extend-native": "
|
|
377
|
+
"sonarjs/no-extend-native": "off",
|
|
369
378
|
"sonarjs/no-redeclare": "off",
|
|
370
379
|
"sonarjs/no-unreachable": "off",
|
|
371
380
|
"sonarjs/no-unused-expressions": "off",
|
package/jest.js
CHANGED
|
@@ -8,6 +8,9 @@ const jestGlobalsVersion = getModuleVersion("@jest/globals", 29)
|
|
|
8
8
|
const hasTestingLibrary = !!resolveModuleLocation("eslint-plugin-testing-library")
|
|
9
9
|
const hasJestFormatting = !!resolveModuleLocation("eslint-plugin-jest-formatting")
|
|
10
10
|
const hasJest = !!resolveModuleLocation("eslint-plugin-jest")
|
|
11
|
+
// eslint-plugin-sonarjs@2 pulls in a ton of extra dependnecies we don't need
|
|
12
|
+
// https://community.sonarsource.com/t/warning-react-version-not-specified-in-eslint-plugin-react/125412/11?u=avasam
|
|
13
|
+
const hasSonarJS = !!resolveModuleLocation("eslint-plugin-sonarjs")
|
|
11
14
|
|
|
12
15
|
/** @type {import("eslint").Linter.Config} */
|
|
13
16
|
module.exports = {
|
|
@@ -73,16 +76,20 @@ module.exports = {
|
|
|
73
76
|
"@typescript-eslint/no-unsafe-call": "off",
|
|
74
77
|
// Allow printing "as-is" in tests
|
|
75
78
|
"@typescript-eslint/restrict-template-expressions": "off",
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
79
|
+
...hasSonarJS
|
|
80
|
+
? {
|
|
81
|
+
// Higher requirements for tests since we like being explicit
|
|
82
|
+
// Arbitrary same as max-params (+1 because this is exclusive)
|
|
83
|
+
"sonarjs/no-duplicate-string": [
|
|
84
|
+
"error",
|
|
85
|
+
{ "threshold": 8 }
|
|
86
|
+
],
|
|
87
|
+
// We could bump it higher than 4, but doc doesn't provide its config
|
|
88
|
+
// So disabling since fluent tests are nested functions
|
|
89
|
+
// (same comment in jsx)
|
|
90
|
+
"sonarjs/no-nested-functions": "off"
|
|
91
|
+
}
|
|
92
|
+
: {},
|
|
86
93
|
|
|
87
94
|
/*
|
|
88
95
|
* jest/all overrides (https://github.com/jest-community/eslint-plugin-jest#rules)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-config-beslogic",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.2",
|
|
4
4
|
"description": "ESLint rules, plugins and configs used at Beslogic",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"// dependencies": "Run for ourselves when we install dependencies w/o running npm i afterward",
|