eslint-config-beslogic 4.0.2 → 4.1.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 +53 -1
- package/README.md +1 -1
- package/eslint.config.mjs +7 -7
- package/javascript.mjs +14 -11
- package/lib/patch-dependencies.mjs +0 -1
- package/lib/utils.mjs +0 -1
- package/node-js.mjs +5 -0
- package/package.json +9 -7
- package/tsconfig.json +1 -1
- package/typescript.mjs +13 -12
package/CHANGELOG.md
CHANGED
|
@@ -1,9 +1,32 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 4.1.0
|
|
4
|
+
|
|
5
|
+
- Migrated from `eslint-plugin-import` to `eslint-plugin-import-x@^4.2.1` for performance and better support.
|
|
6
|
+
|
|
7
|
+
## 4.0.3
|
|
8
|
+
|
|
9
|
+
- Allow `^8.56 || ^9.12` for the ESLint version range. But v9 is completely untested.
|
|
10
|
+
|
|
3
11
|
## 4.0.2
|
|
4
12
|
|
|
5
|
-
|
|
13
|
+
### Important migration notes
|
|
14
|
+
|
|
15
|
+
- You'll have to migrate your configs to use Flat Config
|
|
16
|
+
- We recommend `eslint.config.mjs` to use configs as ES Modules and be explicit about it.
|
|
17
|
+
- The README has been updated with basic configuration examples
|
|
18
|
+
- See <https://eslint.org/docs/latest/use/configure/migration-guide> for further help
|
|
19
|
+
- You can remove `--ignore-path .gitignore` from your lint command.
|
|
6
20
|
- `angular-eslint` won't work on HTML files on ESLint v8 due to parser configuration issues.
|
|
21
|
+
- Nested configuration files autodiscovery won't work until [ESLint v9.12](https://github.com/eslint/eslint/pull/18742).\
|
|
22
|
+
In the mean time, you can extend your child configs in your parent with a `files` restriction.
|
|
23
|
+
- `@eslint-community/eslint-comments/no-unused-disable` does not currently work with Flat Configs,
|
|
24
|
+
so unused disable comments are no longer reported.
|
|
25
|
+
See <https://github.com/eslint-community/eslint-plugin-eslint-comments/issues/244>
|
|
26
|
+
|
|
27
|
+
### Rest of the changes
|
|
28
|
+
|
|
29
|
+
- Initial support for Flat Configs. v4 will only support Flat Configs (`eslint.config.js`), please use v3 for Legacy Configs (`.eslintrc`).
|
|
7
30
|
- Autodetection of `.gitignore` using `eslint-config-flat-gitignore`
|
|
8
31
|
- Updated dependencies:
|
|
9
32
|
- Using the combined `typescript-eslint` package instead of `@typescript-eslint/eslint-plugin` + `@typescript-eslint/parser`
|
|
@@ -16,6 +39,35 @@
|
|
|
16
39
|
- Bumped `eslint-plugin-react` to `^7.37.1`
|
|
17
40
|
- Added dependency on `@eslint/compat` and `eslint-config-flat-gitignore`
|
|
18
41
|
|
|
42
|
+
## 3.2.0
|
|
43
|
+
|
|
44
|
+
- Migrated from `eslint-plugin-import` to `eslint-plugin-import-x@^4.2.1` for performance and better support.
|
|
45
|
+
- This also forces `eslint` to version `8.57` or above
|
|
46
|
+
|
|
47
|
+
## 3.1.4
|
|
48
|
+
|
|
49
|
+
- Pinned `eslint-plugin-unicorn` to `>=49.0 && <57`
|
|
50
|
+
|
|
51
|
+
## 3.1.3
|
|
52
|
+
|
|
53
|
+
- Bumped `"@typescript-eslint` to `^8.15.0`
|
|
54
|
+
- Disabled `sonarjs/fixme-tag`
|
|
55
|
+
- Disabled `@typescript-eslint/no-unsafe-type-assertion` and `@typescript-eslint/related-getter-setter-pairs` in non-`extra-strict` presets.
|
|
56
|
+
- Added `"checkTypePredicates": true` to `@typescript-eslint/no-unnecessary-condition`
|
|
57
|
+
- Configured `@typescript-eslint/prefer-nullish-coalescing` as
|
|
58
|
+
<!-- markdownlint-disable-next-line MD031 -->
|
|
59
|
+
```js
|
|
60
|
+
[
|
|
61
|
+
"error",
|
|
62
|
+
{
|
|
63
|
+
// > If you're looking to enforce stricter conditional tests,
|
|
64
|
+
// > you should consider using the strict-boolean-expressions rule.
|
|
65
|
+
"ignoreConditionalTests": true,
|
|
66
|
+
"ignoreBooleanCoercion": true
|
|
67
|
+
}
|
|
68
|
+
],
|
|
69
|
+
```
|
|
70
|
+
|
|
19
71
|
## 3.1.2
|
|
20
72
|
|
|
21
73
|
- Removed `globalThis` from `no-restricted-globals` as the adoption is now much wider (no more IE11) and it conflicts with `unicorn/prefer-global-this`
|
package/README.md
CHANGED
|
@@ -6,7 +6,7 @@ Run `npm i --save-dev eslint-config-beslogic`
|
|
|
6
6
|
|
|
7
7
|
Depending on your needs, you will need to also install other peer dependencies for linting.
|
|
8
8
|
|
|
9
|
-
In your `eslint.config.[cm]?js` file, simply [extend](https://typescript-eslint.io/
|
|
9
|
+
In your `eslint.config.[cm]?js` file, simply [extend](https://typescript-eslint.io/packages/typescript-eslint#config) our [presets](#presets) appropriate for your project.
|
|
10
10
|
|
|
11
11
|
For stylistic rules, it is highly recommended to use a dedicated formatter over ESLint. Read more here: <https://typescript-eslint.io/docs/linting/troubleshooting/formatting/>\
|
|
12
12
|
We assume [dprint](https://dprint.dev/) and don't enable any rules it covers by default. If you're not using a formatter, a [stylistic.mjs](#stylisticmjs) configuration is offered below.
|
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": [
|
|
@@ -71,10 +71,10 @@ export default tseslint.config(
|
|
|
71
71
|
},
|
|
72
72
|
// We need to explicitely set these paths because
|
|
73
73
|
// ESLint flat configs doesn't do automated config lookup until 9.12
|
|
74
|
-
{ "files": ["static-tests/*"], "extends":
|
|
75
|
-
{ "files": ["static-tests/angular/**"], "extends":
|
|
76
|
-
{ "files": ["static-tests/javascript/**"], "extends":
|
|
77
|
-
{ "files": ["static-tests/react-typescript/**"], "extends":
|
|
78
|
-
{ "files": ["static-tests/storybook/**"], "extends":
|
|
79
|
-
{ "files": ["static-tests/typescript/**"], "extends":
|
|
74
|
+
{ "files": ["static-tests/*"], "extends": staticTestsRoot },
|
|
75
|
+
{ "files": ["static-tests/angular/**"], "extends": staticTestsAngular },
|
|
76
|
+
{ "files": ["static-tests/javascript/**"], "extends": staticTestsJavascript },
|
|
77
|
+
{ "files": ["static-tests/react-typescript/**"], "extends": staticTestsReactTypeScript },
|
|
78
|
+
{ "files": ["static-tests/storybook/**"], "extends": staticTestsStorybook },
|
|
79
|
+
{ "files": ["static-tests/typescript/**"], "extends": staticTestsTypeScript }
|
|
80
80
|
)
|
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 eslintPluginImportX 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"
|
|
@@ -118,7 +118,8 @@ export const noRestrictedImportsConfig = {
|
|
|
118
118
|
"default",
|
|
119
119
|
"React"
|
|
120
120
|
],
|
|
121
|
-
"message": "Please don't use the default React import."
|
|
121
|
+
"message": "Please don't use the default React import. "
|
|
122
|
+
+ "You can configure `\"compilerOptions.jsx\": \"react-jsx\"` in tsconfig.json instead."
|
|
122
123
|
},
|
|
123
124
|
{
|
|
124
125
|
// From https://github.com/angular-eslint/angular-eslint/blob/master/packages/eslint-plugin/src/configs/recommended--extra.json
|
|
@@ -178,7 +179,9 @@ export default tseslint.config(
|
|
|
178
179
|
sonarjs.configs.recommended,
|
|
179
180
|
unicorn.configs["flat/all"],
|
|
180
181
|
regexp.configs["flat/recommended"],
|
|
181
|
-
|
|
182
|
+
/* eslint-disable-next-line import-x/no-named-as-default-member
|
|
183
|
+
-- https://github.com/un-ts/eslint-plugin-import-x/issues/285 */
|
|
184
|
+
eslintPluginImportX.flatConfigs.recommended,
|
|
182
185
|
comments.recommended,
|
|
183
186
|
{
|
|
184
187
|
"plugins": {
|
|
@@ -329,30 +332,30 @@ export default tseslint.config(
|
|
|
329
332
|
/*
|
|
330
333
|
* import settings (https://github.com/import-js/eslint-plugin-import#rules)
|
|
331
334
|
*/
|
|
332
|
-
"import/consistent-type-specifier-style": [
|
|
335
|
+
"import-x/consistent-type-specifier-style": [
|
|
333
336
|
"error",
|
|
334
337
|
"prefer-top-level"
|
|
335
338
|
],
|
|
336
|
-
"import/newline-after-import": [
|
|
339
|
+
"import-x/newline-after-import": [
|
|
337
340
|
"error",
|
|
338
341
|
{
|
|
339
342
|
"exactCount": true,
|
|
340
343
|
"considerComments": true
|
|
341
344
|
}
|
|
342
345
|
],
|
|
343
|
-
"import/no-duplicates": [
|
|
346
|
+
"import-x/no-duplicates": [
|
|
344
347
|
"error",
|
|
345
348
|
{ "considerQueryString": true }
|
|
346
349
|
],
|
|
347
|
-
"import/no-empty-named-blocks": "error",
|
|
348
|
-
"import/no-named-as-default": "error",
|
|
349
|
-
"import/no-named-as-default-member": "error",
|
|
350
|
+
"import-x/no-empty-named-blocks": "error",
|
|
351
|
+
"import-x/no-named-as-default": "error",
|
|
352
|
+
"import-x/no-named-as-default-member": "error",
|
|
350
353
|
// Extracted restricted import into its own rule so it's easier for projects to override/ignore
|
|
351
354
|
"no-autofix/no-relative-import-paths/no-relative-import-paths": [
|
|
352
355
|
"error",
|
|
353
356
|
{ "allowSameFolder": true }
|
|
354
357
|
],
|
|
355
|
-
"import/no-unresolved": [
|
|
358
|
+
"import-x/no-unresolved": [
|
|
356
359
|
"error",
|
|
357
360
|
// https://github.com/import-js/eslint-plugin-import/issues/3140
|
|
358
361
|
{ "ignore": ["typescript-eslint"] }
|
|
@@ -722,7 +725,7 @@ export default tseslint.config(
|
|
|
722
725
|
"no-constant-binary-expression": "error",
|
|
723
726
|
"no-constructor-return": "error",
|
|
724
727
|
"no-dupe-else-if": "error",
|
|
725
|
-
// Obsoleted by import/no-duplicates
|
|
728
|
+
// Obsoleted by import-x/no-duplicates
|
|
726
729
|
"no-duplicate-imports": "off",
|
|
727
730
|
"no-extend-native": "error",
|
|
728
731
|
"no-implied-eval": "error",
|
package/lib/utils.mjs
CHANGED
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.1.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",
|
|
@@ -49,13 +49,13 @@
|
|
|
49
49
|
"@types/eslint": "^8.56",
|
|
50
50
|
"confusing-browser-globals": "^1.0",
|
|
51
51
|
"dprint": "^0.40.2",
|
|
52
|
-
"eslint": "^8.56",
|
|
52
|
+
"eslint": "^8.56 || ^9.12",
|
|
53
53
|
"eslint-config-flat-gitignore": "^1.0.0",
|
|
54
54
|
"eslint-import-resolver-typescript": "^3.2.6",
|
|
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",
|
|
@@ -84,20 +84,22 @@
|
|
|
84
84
|
"eslint-plugin-storybook": "^0.10"
|
|
85
85
|
},
|
|
86
86
|
"// jest": "Don't install it, so that we test failure to specify jest version",
|
|
87
|
+
"// eslint": "v9 support is untested",
|
|
87
88
|
"devDependencies": {
|
|
88
89
|
"@angular/core": ">=18.0",
|
|
89
90
|
"@types/node": "^18.0",
|
|
91
|
+
"@types/react": "^18.3.3",
|
|
90
92
|
"eslint-plugin-eslint-plugin": "^6.0",
|
|
91
93
|
"react": "^18.3.1",
|
|
92
94
|
"yalc": "^1.0.0-pre.53"
|
|
93
95
|
},
|
|
94
|
-
"//
|
|
96
|
+
"// eslint overrides": "Deps that declare themselves as ESLint 9 compatible only, but we need it for flat config compat",
|
|
95
97
|
"overrides": {
|
|
96
98
|
"@eslint/compat": {
|
|
97
|
-
"eslint": "^8.56"
|
|
99
|
+
"eslint": "^8.56 || ^9.12"
|
|
98
100
|
},
|
|
99
101
|
"eslint-config-flat-gitignore": {
|
|
100
|
-
"eslint": "^8.56"
|
|
102
|
+
"eslint": "^8.56 || ^9.12"
|
|
101
103
|
}
|
|
102
104
|
}
|
|
103
105
|
}
|
package/tsconfig.json
CHANGED
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 eslintPluginImportX 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({
|
|
@@ -75,10 +74,12 @@ export default tseslint.config(
|
|
|
75
74
|
...tseslint.configs.all,
|
|
76
75
|
// https://github.com/cartant/eslint-plugin-etc/issues/74
|
|
77
76
|
fixupConfigRules(compat.extends("plugin:etc/recommended")),
|
|
78
|
-
|
|
77
|
+
/* eslint-disable-next-line import-x/no-named-as-default-member
|
|
78
|
+
-- https://github.com/un-ts/eslint-plugin-import-x/issues/285 */
|
|
79
|
+
eslintPluginImportX.flatConfigs.typescript
|
|
79
80
|
],
|
|
80
81
|
"languageOptions": {
|
|
81
|
-
|
|
82
|
+
"parser": tsParser,
|
|
82
83
|
"parserOptions": {
|
|
83
84
|
"project": ["tsconfig?(.*).json"],
|
|
84
85
|
// "useProjectService": true,
|
|
@@ -98,7 +99,7 @@ export default tseslint.config(
|
|
|
98
99
|
}
|
|
99
100
|
},
|
|
100
101
|
"settings": {
|
|
101
|
-
"import/resolver": {
|
|
102
|
+
"import-x/resolver": {
|
|
102
103
|
"typescript": {
|
|
103
104
|
// Recommended by eslint-import-resolver-typescript
|
|
104
105
|
// Always try to resolve types under `<root>@types` directory even it doesn't contain any source code, like `@types/unist`
|
|
@@ -111,25 +112,25 @@ export default tseslint.config(
|
|
|
111
112
|
]
|
|
112
113
|
}
|
|
113
114
|
},
|
|
114
|
-
"import/parsers": {
|
|
115
|
+
"import-x/parsers": {
|
|
115
116
|
"@typescript-eslint/parser": [
|
|
116
117
|
".ts",
|
|
117
118
|
".tsx"
|
|
118
119
|
]
|
|
119
120
|
},
|
|
120
|
-
// Required even with plugin:import/typescript
|
|
121
|
-
"import/extensions": [
|
|
121
|
+
// Required even with plugin:import-x/typescript
|
|
122
|
+
"import-x/extensions": [
|
|
122
123
|
".ts",
|
|
123
124
|
".tsx"
|
|
124
125
|
]
|
|
125
126
|
},
|
|
126
127
|
"rules": {
|
|
127
128
|
// Slow and not as useful with TypeScript: https://github.com/import-js/eslint-plugin-import/issues/2340
|
|
128
|
-
"import/namespace": "off",
|
|
129
|
+
"import-x/namespace": "off",
|
|
129
130
|
// TypeScript already ensures imports resolve
|
|
130
|
-
"import/no-unresolved": "off",
|
|
131
|
+
"import-x/no-unresolved": "off",
|
|
131
132
|
// Already checked by @typescript-eslint/no-import-type-side-effects
|
|
132
|
-
"import/consistent-type-specifier-style": "off",
|
|
133
|
+
"import-x/consistent-type-specifier-style": "off",
|
|
133
134
|
|
|
134
135
|
/*
|
|
135
136
|
* Cartant's etc rules
|