eslint-config-beslogic 4.0.3 → 4.2.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/CHANGELOG.md +24 -0
- package/eslint.config.mjs +1 -1
- package/extra-strict.mjs +8 -1
- package/javascript.mjs +10 -10
- package/node-js.mjs +5 -0
- package/package.json +3 -3
- package/typescript.mjs +26 -12
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 4.2.0
|
|
4
|
+
|
|
5
|
+
- `@typescript-eslint/no-floating-promises` is now ignored on `i18next.changeLanguage` as it is known to not throw and already `console.warn` itself
|
|
6
|
+
- In `extra-strict` preset, `@typescript-eslint/no-floating-promises`doesn't ignore voided promises, forcing a comment to explain
|
|
7
|
+
- Disabled `@typescript-eslint/no-misused-spread`:\
|
|
8
|
+
Still a handful of false-positives and I couldn't get the configuration working.\
|
|
9
|
+
Especially annoying with autogenerated API when spreading class instance
|
|
10
|
+
with readonly properties as its contructor object.\
|
|
11
|
+
ie: `new Myclass({...someInstance, overwritten_prop: "foo"})`\
|
|
12
|
+
NOTE: If fixed, we'd still only want this in extra-strict config.
|
|
13
|
+
|
|
14
|
+
## 4.1.0
|
|
15
|
+
|
|
16
|
+
- Migrated from `eslint-plugin-import` to `eslint-plugin-import-x@^4.2.1` for performance and better support.
|
|
17
|
+
|
|
3
18
|
## 4.0.3
|
|
4
19
|
|
|
5
20
|
- Allow `^8.56 || ^9.12` for the ESLint version range. But v9 is completely untested.
|
|
@@ -35,6 +50,15 @@
|
|
|
35
50
|
- Bumped `eslint-plugin-react` to `^7.37.1`
|
|
36
51
|
- Added dependency on `@eslint/compat` and `eslint-config-flat-gitignore`
|
|
37
52
|
|
|
53
|
+
## 3.2.0
|
|
54
|
+
|
|
55
|
+
- Migrated from `eslint-plugin-import` to `eslint-plugin-import-x@^4.2.1` for performance and better support.
|
|
56
|
+
- This also forces `eslint` to version `8.57` or above
|
|
57
|
+
|
|
58
|
+
## 3.1.4
|
|
59
|
+
|
|
60
|
+
- Pinned `eslint-plugin-unicorn` to `>=49.0 && <57`
|
|
61
|
+
|
|
38
62
|
## 3.1.3
|
|
39
63
|
|
|
40
64
|
- Bumped `"@typescript-eslint` to `^8.15.0`
|
package/eslint.config.mjs
CHANGED
|
@@ -47,7 +47,7 @@ export default tseslint.config(
|
|
|
47
47
|
"@stylistic/indent": "off",
|
|
48
48
|
|
|
49
49
|
// We're using typescript (tsconfig) for that
|
|
50
|
-
"import/no-unresolved": "off",
|
|
50
|
+
"import-x/no-unresolved": "off",
|
|
51
51
|
|
|
52
52
|
// TODO: Remove these config once we're no longer using the pre-flat-config compatibility layer
|
|
53
53
|
"no-shadow": [
|
package/extra-strict.mjs
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
import tseslint from "typescript-eslint"
|
|
5
5
|
|
|
6
6
|
import { jestFilePatterns, resolveModuleLocation } from "./lib/utils.mjs"
|
|
7
|
-
import { restrictTemplateExpressionsConfig } from "./typescript.mjs"
|
|
7
|
+
import { noFloatingPromisesKnownSafeCalls, restrictTemplateExpressionsConfig } from "./typescript.mjs"
|
|
8
8
|
|
|
9
9
|
// These extra strict configs are not only for Angular. User may be using a different framework
|
|
10
10
|
const hasAngularEslintTemplate = !!resolveModuleLocation("@angular-eslint/eslint-plugin-template")
|
|
@@ -56,6 +56,13 @@ export default tseslint.config(
|
|
|
56
56
|
],
|
|
57
57
|
"@typescript-eslint/no-unsafe-type-assertion": "error",
|
|
58
58
|
|
|
59
|
+
"@typescript-eslint/no-floating-promises": [
|
|
60
|
+
"error",
|
|
61
|
+
{
|
|
62
|
+
"ignoreVoid": false, // Don't even ignore voided promises. Force a comment explaining.
|
|
63
|
+
"allowForKnownSafeCalls": noFloatingPromisesKnownSafeCalls
|
|
64
|
+
}
|
|
65
|
+
],
|
|
59
66
|
"@typescript-eslint/related-getter-setter-pairs": "error",
|
|
60
67
|
"@typescript-eslint/restrict-template-expressions": [
|
|
61
68
|
"error",
|
package/javascript.mjs
CHANGED
|
@@ -8,7 +8,7 @@ import restrictedGlobals from "confusing-browser-globals"
|
|
|
8
8
|
import gitignore from "eslint-config-flat-gitignore"
|
|
9
9
|
import autofix from "eslint-plugin-autofix"
|
|
10
10
|
import extraRules from "eslint-plugin-extra-rules"
|
|
11
|
-
import
|
|
11
|
+
import * as pluginImportX from "eslint-plugin-import-x"
|
|
12
12
|
import noAutofix from "eslint-plugin-no-autofix"
|
|
13
13
|
import noRelativeImportPaths from "eslint-plugin-no-relative-import-paths"
|
|
14
14
|
import preferArrow from "eslint-plugin-prefer-arrow"
|
|
@@ -179,7 +179,7 @@ export default tseslint.config(
|
|
|
179
179
|
sonarjs.configs.recommended,
|
|
180
180
|
unicorn.configs["flat/all"],
|
|
181
181
|
regexp.configs["flat/recommended"],
|
|
182
|
-
|
|
182
|
+
pluginImportX.flatConfigs.recommended,
|
|
183
183
|
comments.recommended,
|
|
184
184
|
{
|
|
185
185
|
"plugins": {
|
|
@@ -330,30 +330,30 @@ export default tseslint.config(
|
|
|
330
330
|
/*
|
|
331
331
|
* import settings (https://github.com/import-js/eslint-plugin-import#rules)
|
|
332
332
|
*/
|
|
333
|
-
"import/consistent-type-specifier-style": [
|
|
333
|
+
"import-x/consistent-type-specifier-style": [
|
|
334
334
|
"error",
|
|
335
335
|
"prefer-top-level"
|
|
336
336
|
],
|
|
337
|
-
"import/newline-after-import": [
|
|
337
|
+
"import-x/newline-after-import": [
|
|
338
338
|
"error",
|
|
339
339
|
{
|
|
340
340
|
"exactCount": true,
|
|
341
341
|
"considerComments": true
|
|
342
342
|
}
|
|
343
343
|
],
|
|
344
|
-
"import/no-duplicates": [
|
|
344
|
+
"import-x/no-duplicates": [
|
|
345
345
|
"error",
|
|
346
346
|
{ "considerQueryString": true }
|
|
347
347
|
],
|
|
348
|
-
"import/no-empty-named-blocks": "error",
|
|
349
|
-
"import/no-named-as-default": "error",
|
|
350
|
-
"import/no-named-as-default-member": "error",
|
|
348
|
+
"import-x/no-empty-named-blocks": "error",
|
|
349
|
+
"import-x/no-named-as-default": "error",
|
|
350
|
+
"import-x/no-named-as-default-member": "error",
|
|
351
351
|
// Extracted restricted import into its own rule so it's easier for projects to override/ignore
|
|
352
352
|
"no-autofix/no-relative-import-paths/no-relative-import-paths": [
|
|
353
353
|
"error",
|
|
354
354
|
{ "allowSameFolder": true }
|
|
355
355
|
],
|
|
356
|
-
"import/no-unresolved": [
|
|
356
|
+
"import-x/no-unresolved": [
|
|
357
357
|
"error",
|
|
358
358
|
// https://github.com/import-js/eslint-plugin-import/issues/3140
|
|
359
359
|
{ "ignore": ["typescript-eslint"] }
|
|
@@ -723,7 +723,7 @@ export default tseslint.config(
|
|
|
723
723
|
"no-constant-binary-expression": "error",
|
|
724
724
|
"no-constructor-return": "error",
|
|
725
725
|
"no-dupe-else-if": "error",
|
|
726
|
-
// Obsoleted by import/no-duplicates
|
|
726
|
+
// Obsoleted by import-x/no-duplicates
|
|
727
727
|
"no-duplicate-imports": "off",
|
|
728
728
|
"no-extend-native": "error",
|
|
729
729
|
"no-implied-eval": "error",
|
package/node-js.mjs
CHANGED
|
@@ -20,6 +20,11 @@ export default tseslint.config(
|
|
|
20
20
|
// @ts-expect-error: TODO: Raise upstream
|
|
21
21
|
n.configs["flat/recommended-script"],
|
|
22
22
|
{
|
|
23
|
+
"settings": {
|
|
24
|
+
"import-x/resolver": {
|
|
25
|
+
"node": true
|
|
26
|
+
}
|
|
27
|
+
},
|
|
23
28
|
"languageOptions": {
|
|
24
29
|
"ecmaVersion": "latest", // Will be default in ESLint 9
|
|
25
30
|
"sourceType": "module", // Will be default in ESLint 9
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-config-beslogic",
|
|
3
|
-
"version": "4.0
|
|
3
|
+
"version": "4.2.0",
|
|
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",
|
|
7
7
|
"scripts": {
|
|
8
8
|
"eslint": "set TIMING=1 && eslint .",
|
|
9
9
|
"lint": "dprint check && npm run eslint",
|
|
10
|
-
"lint:fix": "
|
|
10
|
+
"lint:fix": "npm run eslint -- --fix && dprint fmt",
|
|
11
11
|
"upgrade": "npx npm-check-updates -u & npm i",
|
|
12
12
|
"yalc": "yalc publish",
|
|
13
13
|
"prepack": "type .gitignore* > .npmignore",
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
"eslint-plugin-autofix": "^1.1 || ^2.0",
|
|
56
56
|
"eslint-plugin-etc": "^2.0",
|
|
57
57
|
"eslint-plugin-extra-rules": "^0.0.0-development",
|
|
58
|
-
"eslint-plugin-import": "^2.
|
|
58
|
+
"eslint-plugin-import-x": "^4.2.1",
|
|
59
59
|
"eslint-plugin-jest": "^28.7",
|
|
60
60
|
"eslint-plugin-jest-formatting": "^3.1",
|
|
61
61
|
"eslint-plugin-no-autofix": "^2.0",
|
package/typescript.mjs
CHANGED
|
@@ -7,7 +7,8 @@ import { fileURLToPath } from "node:url"
|
|
|
7
7
|
import { fixupConfigRules } from "@eslint/compat"
|
|
8
8
|
import { FlatCompat } from "@eslint/eslintrc"
|
|
9
9
|
import js from "@eslint/js"
|
|
10
|
-
import
|
|
10
|
+
import tsParser from "@typescript-eslint/parser"
|
|
11
|
+
import * as pluginImportX from "eslint-plugin-import-x"
|
|
11
12
|
import globals from "globals"
|
|
12
13
|
import tseslint from "typescript-eslint"
|
|
13
14
|
|
|
@@ -15,8 +16,6 @@ import { maxParams, noMagicNumbersConfig as noMagicNumbersConfigJS, noRestricted
|
|
|
15
16
|
import beslogicJest from "./jest.mjs"
|
|
16
17
|
import { jestFilePatterns, jestNoRestrictedSyntax } from "./lib/utils.mjs"
|
|
17
18
|
|
|
18
|
-
// import tsParser from "@typescript-eslint/parser"
|
|
19
|
-
|
|
20
19
|
const __filename = fileURLToPath(import.meta.url)
|
|
21
20
|
const __dirname = path.dirname(__filename)
|
|
22
21
|
const compat = new FlatCompat({
|
|
@@ -65,6 +64,11 @@ export const restrictTemplateExpressionsConfig = {
|
|
|
65
64
|
// ]
|
|
66
65
|
}
|
|
67
66
|
|
|
67
|
+
export const noFloatingPromisesKnownSafeCalls = [
|
|
68
|
+
// Doesn't throw and already console.warn itself
|
|
69
|
+
{ "from": "package", "package": "i18next", "name": "changeLanguage" }
|
|
70
|
+
]
|
|
71
|
+
|
|
68
72
|
export default tseslint.config(
|
|
69
73
|
{
|
|
70
74
|
"files": [
|
|
@@ -75,10 +79,10 @@ export default tseslint.config(
|
|
|
75
79
|
...tseslint.configs.all,
|
|
76
80
|
// https://github.com/cartant/eslint-plugin-etc/issues/74
|
|
77
81
|
fixupConfigRules(compat.extends("plugin:etc/recommended")),
|
|
78
|
-
|
|
82
|
+
pluginImportX.flatConfigs.typescript
|
|
79
83
|
],
|
|
80
84
|
"languageOptions": {
|
|
81
|
-
|
|
85
|
+
"parser": tsParser,
|
|
82
86
|
"parserOptions": {
|
|
83
87
|
"project": ["tsconfig?(.*).json"],
|
|
84
88
|
// "useProjectService": true,
|
|
@@ -98,7 +102,7 @@ export default tseslint.config(
|
|
|
98
102
|
}
|
|
99
103
|
},
|
|
100
104
|
"settings": {
|
|
101
|
-
"import/resolver": {
|
|
105
|
+
"import-x/resolver": {
|
|
102
106
|
"typescript": {
|
|
103
107
|
// Recommended by eslint-import-resolver-typescript
|
|
104
108
|
// Always try to resolve types under `<root>@types` directory even it doesn't contain any source code, like `@types/unist`
|
|
@@ -111,25 +115,25 @@ export default tseslint.config(
|
|
|
111
115
|
]
|
|
112
116
|
}
|
|
113
117
|
},
|
|
114
|
-
"import/parsers": {
|
|
118
|
+
"import-x/parsers": {
|
|
115
119
|
"@typescript-eslint/parser": [
|
|
116
120
|
".ts",
|
|
117
121
|
".tsx"
|
|
118
122
|
]
|
|
119
123
|
},
|
|
120
|
-
// Required even with plugin:import/typescript
|
|
121
|
-
"import/extensions": [
|
|
124
|
+
// Required even with plugin:import-x/typescript
|
|
125
|
+
"import-x/extensions": [
|
|
122
126
|
".ts",
|
|
123
127
|
".tsx"
|
|
124
128
|
]
|
|
125
129
|
},
|
|
126
130
|
"rules": {
|
|
127
131
|
// Slow and not as useful with TypeScript: https://github.com/import-js/eslint-plugin-import/issues/2340
|
|
128
|
-
"import/namespace": "off",
|
|
132
|
+
"import-x/namespace": "off",
|
|
129
133
|
// TypeScript already ensures imports resolve
|
|
130
|
-
"import/no-unresolved": "off",
|
|
134
|
+
"import-x/no-unresolved": "off",
|
|
131
135
|
// Already checked by @typescript-eslint/no-import-type-side-effects
|
|
132
|
-
"import/consistent-type-specifier-style": "off",
|
|
136
|
+
"import-x/consistent-type-specifier-style": "off",
|
|
133
137
|
|
|
134
138
|
/*
|
|
135
139
|
* Cartant's etc rules
|
|
@@ -197,6 +201,10 @@ export default tseslint.config(
|
|
|
197
201
|
"import-x/no-deprecated": "off",
|
|
198
202
|
"import/no-deprecated": "off",
|
|
199
203
|
"sonarjs/deprecation": "off",
|
|
204
|
+
"@typescript-eslint/no-floating-promises": [
|
|
205
|
+
"error",
|
|
206
|
+
{ "allowForKnownSafeCalls": noFloatingPromisesKnownSafeCalls }
|
|
207
|
+
],
|
|
200
208
|
// Explicit types rules complicates things uselessly and are redundant
|
|
201
209
|
"@typescript-eslint/explicit-function-return-type": "off",
|
|
202
210
|
"@typescript-eslint/explicit-member-accessibility": [
|
|
@@ -234,6 +242,12 @@ export default tseslint.config(
|
|
|
234
242
|
"error",
|
|
235
243
|
{ "checksVoidReturn": false }
|
|
236
244
|
],
|
|
245
|
+
// Still a handful of false-positives and I couldn't get the configuration working.
|
|
246
|
+
// Especially annoying with autogenerated API when spreading class instance
|
|
247
|
+
// with readonly properties as its contructor object.
|
|
248
|
+
// ie: `new Myclass({...someInstance, overwritten_prop: "foo"})`
|
|
249
|
+
// NOTE: If fixed, we'd still only want this in extra-strict config.
|
|
250
|
+
"@typescript-eslint/no-misused-spread": "off",
|
|
237
251
|
"@typescript-eslint/no-restricted-imports": [
|
|
238
252
|
"error",
|
|
239
253
|
{
|