@leancodepl/eslint-config 9.7.2 → 9.7.3
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 +12 -0
- package/README.md +29 -0
- package/package.json +7 -5
- package/project.json +0 -7
- package/src/index.js +4 -6
- package/src/lib/a11y.js +2 -4
- package/src/lib/base-react.js +4 -6
- package/src/lib/base.js +84 -8
- package/src/lib/imports.js +22 -17
- package/jest.config.js +0 -8
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,18 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See
|
|
4
4
|
[Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [9.7.3](https://github.com/leancodepl/js_corelibrary/compare/v9.7.2...v9.7.3) (2026-02-10)
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
- add eslint unicorn rules
|
|
11
|
+
([0c821f2](https://github.com/leancodepl/js_corelibrary/commit/0c821f20f0f7e667c1616161a173e7501baa94cb))
|
|
12
|
+
|
|
13
|
+
# Change Log
|
|
14
|
+
|
|
15
|
+
All notable changes to this project will be documented in this file. See
|
|
16
|
+
[Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
17
|
+
|
|
6
18
|
## [9.7.2](https://github.com/leancodepl/js_corelibrary/compare/v9.7.1...v9.7.2) (2026-01-20)
|
|
7
19
|
|
|
8
20
|
**Note:** Version bump only for package @leancodepl/eslint-config
|
package/README.md
CHANGED
|
@@ -45,3 +45,32 @@ export default [
|
|
|
45
45
|
},
|
|
46
46
|
]
|
|
47
47
|
```
|
|
48
|
+
|
|
49
|
+
## Migration from CommonJS to ES Modules
|
|
50
|
+
|
|
51
|
+
Starting from 10.0.0 version, the package is built as an ES Module. If your ESLint configuration currently uses CommonJS
|
|
52
|
+
syntax, follow these steps to migrate:
|
|
53
|
+
|
|
54
|
+
- Rename `eslint.config.js` to `eslint.config.mjs` (if your `package.json` does not have `"type": "module"`)
|
|
55
|
+
- Convert `require` statements to `import` syntax
|
|
56
|
+
- Replace CommonJS variables like `__dirname` with ES Module equivalents:
|
|
57
|
+
|
|
58
|
+
```javascript
|
|
59
|
+
import { dirname } from "node:path"
|
|
60
|
+
import { fileURLToPath } from "node:url"
|
|
61
|
+
|
|
62
|
+
const __filename = fileURLToPath(import.meta.url)
|
|
63
|
+
const __dirname = dirname(__filename)
|
|
64
|
+
|
|
65
|
+
// or
|
|
66
|
+
|
|
67
|
+
const __filename = import.meta.filename
|
|
68
|
+
const __dirname = import.meta.dirname
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
- If importing a CommonJS package with named imports fails, import the default export and destructure separately:
|
|
72
|
+
|
|
73
|
+
```javascript
|
|
74
|
+
import commonjsPackage from "commonjs-package"
|
|
75
|
+
const { someExport } = commonjsPackage
|
|
76
|
+
```
|
package/package.json
CHANGED
|
@@ -1,20 +1,22 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leancodepl/eslint-config",
|
|
3
|
-
"version": "9.7.
|
|
3
|
+
"version": "9.7.3",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
|
+
"type": "module",
|
|
5
6
|
"main": "src/index.js",
|
|
6
7
|
"dependencies": {
|
|
7
|
-
"@leancodepl/eslint-plugin": "9.7.
|
|
8
|
+
"@leancodepl/eslint-plugin": "9.7.3",
|
|
8
9
|
"eslint-plugin-import": ">=2.31.0",
|
|
9
10
|
"eslint-plugin-jsx-a11y": ">=6.10.0",
|
|
10
|
-
"eslint-plugin-perfectionist": ">=
|
|
11
|
+
"eslint-plugin-perfectionist": ">=5.0.0",
|
|
11
12
|
"eslint-plugin-react-hooks": ">=5.2.0",
|
|
13
|
+
"eslint-plugin-unicorn": ">=62.0.0",
|
|
12
14
|
"eslint-plugin-unused-imports": ">=4.1.0",
|
|
13
15
|
"globals": ">=15.0.0"
|
|
14
16
|
},
|
|
15
17
|
"peerDependencies": {
|
|
16
18
|
"@types/eslint-plugin-jsx-a11y": ">=6.10.0",
|
|
17
|
-
"eslint": ">=
|
|
19
|
+
"eslint": ">=9.20.0",
|
|
18
20
|
"eslint-config-prettier": ">=9.1.0",
|
|
19
21
|
"eslint-plugin-react": ">=7.34.1",
|
|
20
22
|
"prettier": ">=3.0.0",
|
|
@@ -25,7 +27,7 @@
|
|
|
25
27
|
"registry": "https://registry.npmjs.org/"
|
|
26
28
|
},
|
|
27
29
|
"engines": {
|
|
28
|
-
"node": ">=
|
|
30
|
+
"node": ">=22.0.0"
|
|
29
31
|
},
|
|
30
32
|
"repository": {
|
|
31
33
|
"type": "git",
|
package/project.json
CHANGED
|
@@ -19,13 +19,6 @@
|
|
|
19
19
|
"publish": {
|
|
20
20
|
"command": "node tools/scripts/publish.mjs @leancodepl/eslint-config {args.registry} {args.ver} {args.tag}",
|
|
21
21
|
"dependsOn": ["build"]
|
|
22
|
-
},
|
|
23
|
-
"test": {
|
|
24
|
-
"executor": "@nx/jest:jest",
|
|
25
|
-
"outputs": ["{workspaceRoot}/coverage/{projectRoot}"],
|
|
26
|
-
"options": {
|
|
27
|
-
"jestConfig": "packages/linters/eslint-config/jest.config.js"
|
|
28
|
-
}
|
|
29
22
|
}
|
|
30
23
|
}
|
|
31
24
|
}
|
package/src/index.js
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
module.exports = { a11y, base, baseReact, imports }
|
|
1
|
+
export { a11y } from "./lib/a11y.js"
|
|
2
|
+
export { baseReact } from "./lib/base-react.js"
|
|
3
|
+
export { base } from "./lib/base.js"
|
|
4
|
+
export { imports } from "./lib/imports.js"
|
package/src/lib/a11y.js
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
import jsxA11y from "eslint-plugin-jsx-a11y"
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* @typedef {import('@typescript-eslint/utils').TSESLint.FlatConfig.Config} Config
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
/** @type {Config[]} */
|
|
8
|
-
const a11y = [jsxA11y.flatConfigs.recommended]
|
|
9
|
-
|
|
10
|
-
module.exports = { a11y }
|
|
8
|
+
export const a11y = [jsxA11y.flatConfigs.recommended]
|
package/src/lib/base-react.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import react from "eslint-plugin-react"
|
|
2
|
+
import reactHooks from "eslint-plugin-react-hooks"
|
|
3
|
+
import globals from "globals"
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* @typedef {import('@typescript-eslint/utils').TSESLint.FlatConfig.Config} Config
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
/** @type {Config[]} */
|
|
10
|
-
const baseReact = [
|
|
10
|
+
export const baseReact = [
|
|
11
11
|
{
|
|
12
12
|
plugins: {
|
|
13
13
|
react,
|
|
@@ -49,5 +49,3 @@ const baseReact = [
|
|
|
49
49
|
},
|
|
50
50
|
},
|
|
51
51
|
]
|
|
52
|
-
|
|
53
|
-
module.exports = { baseReact }
|
package/src/lib/base.js
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import eslintConfigPrettier from "eslint-config-prettier"
|
|
2
|
+
import perfectionist from "eslint-plugin-perfectionist"
|
|
3
|
+
import eslintPluginUnicorn from "eslint-plugin-unicorn"
|
|
4
|
+
import globals from "globals"
|
|
5
|
+
import tseslint from "typescript-eslint"
|
|
6
|
+
import { leancodePlugin } from "@leancodepl/eslint-plugin"
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
9
|
* @typedef {import('@typescript-eslint/utils').TSESLint.FlatConfig.Config} Config
|
|
9
10
|
*/
|
|
10
11
|
|
|
11
12
|
/** @type {Config[]} */
|
|
12
|
-
const base = [
|
|
13
|
+
export const base = [
|
|
13
14
|
{
|
|
14
15
|
languageOptions: {
|
|
15
16
|
parser: tseslint.parser,
|
|
@@ -72,7 +73,82 @@ const base = [
|
|
|
72
73
|
],
|
|
73
74
|
},
|
|
74
75
|
},
|
|
76
|
+
{
|
|
77
|
+
languageOptions: {
|
|
78
|
+
globals: globals.builtin,
|
|
79
|
+
},
|
|
80
|
+
plugins: {
|
|
81
|
+
unicorn: eslintPluginUnicorn,
|
|
82
|
+
},
|
|
83
|
+
rules: {
|
|
84
|
+
"unicorn/better-regex": "error",
|
|
85
|
+
"unicorn/catch-error-name": "error",
|
|
86
|
+
"unicorn/consistent-destructuring": "error",
|
|
87
|
+
"unicorn/consistent-existence-index-check": "error",
|
|
88
|
+
"unicorn/custom-error-definition": "error",
|
|
89
|
+
"unicorn/error-message": "error",
|
|
90
|
+
"unicorn/expiring-todo-comments": "error",
|
|
91
|
+
"unicorn/no-array-method-this-argument": "error",
|
|
92
|
+
"unicorn/no-array-reverse": "error",
|
|
93
|
+
"unicorn/no-array-sort": "error",
|
|
94
|
+
"unicorn/no-await-expression-member": "error",
|
|
95
|
+
"unicorn/no-await-in-promise-methods": "error",
|
|
96
|
+
"unicorn/no-document-cookie": "error",
|
|
97
|
+
"unicorn/no-immediate-mutation": "error",
|
|
98
|
+
"unicorn/no-instanceof-builtins": "error",
|
|
99
|
+
"unicorn/no-lonely-if": "error",
|
|
100
|
+
"unicorn/no-magic-array-flat-depth": "error",
|
|
101
|
+
"unicorn/no-negation-in-equality-check": "error",
|
|
102
|
+
"unicorn/no-nested-ternary": "error",
|
|
103
|
+
"unicorn/no-new-buffer": "error",
|
|
104
|
+
"unicorn/no-single-promise-in-promise-methods": "error",
|
|
105
|
+
"unicorn/no-static-only-class": "error",
|
|
106
|
+
"unicorn/no-unnecessary-array-flat-depth": "error",
|
|
107
|
+
"unicorn/no-useless-collection-argument": "error",
|
|
108
|
+
"unicorn/no-useless-fallback-in-spread": "error",
|
|
109
|
+
"unicorn/no-useless-promise-resolve-reject": "error",
|
|
110
|
+
"unicorn/no-useless-switch-case": "error",
|
|
111
|
+
"unicorn/no-useless-undefined": ["error", { checkArguments: false }],
|
|
112
|
+
"unicorn/no-zero-fractions": "error",
|
|
113
|
+
"unicorn/numeric-separators-style": [
|
|
114
|
+
"error",
|
|
115
|
+
{
|
|
116
|
+
number: {
|
|
117
|
+
minimumDigits: 6,
|
|
118
|
+
},
|
|
119
|
+
},
|
|
120
|
+
],
|
|
121
|
+
"unicorn/prefer-array-flat-map": "error",
|
|
122
|
+
"unicorn/prefer-array-index-of": "error",
|
|
123
|
+
"unicorn/prefer-array-some": "error",
|
|
124
|
+
"unicorn/prefer-at": "error",
|
|
125
|
+
"unicorn/prefer-default-parameters": "error",
|
|
126
|
+
"unicorn/prefer-export-from": "error",
|
|
127
|
+
"unicorn/prefer-global-this": "error",
|
|
128
|
+
"unicorn/prefer-includes": "error",
|
|
129
|
+
"unicorn/prefer-logical-operator-over-ternary": "error",
|
|
130
|
+
"unicorn/prefer-math-min-max": "error",
|
|
131
|
+
"unicorn/prefer-negative-index": "error",
|
|
132
|
+
"unicorn/prefer-node-protocol": "error",
|
|
133
|
+
"unicorn/prefer-number-properties": "error",
|
|
134
|
+
"unicorn/prefer-object-from-entries": "error",
|
|
135
|
+
"unicorn/prefer-optional-catch-binding": "error",
|
|
136
|
+
"unicorn/prefer-regexp-test": "error",
|
|
137
|
+
"unicorn/prefer-set-has": "error",
|
|
138
|
+
"unicorn/prefer-set-size": "error",
|
|
139
|
+
"unicorn/prefer-single-call": "error",
|
|
140
|
+
"unicorn/prefer-spread": "error",
|
|
141
|
+
"unicorn/prefer-string-raw": "error",
|
|
142
|
+
"unicorn/prefer-string-replace-all": "error",
|
|
143
|
+
"unicorn/prefer-string-slice": "error",
|
|
144
|
+
"unicorn/prefer-structured-clone": "error",
|
|
145
|
+
"unicorn/prefer-switch": "error",
|
|
146
|
+
"unicorn/prefer-type-error": "error",
|
|
147
|
+
"unicorn/require-array-join-separator": "error",
|
|
148
|
+
"unicorn/require-number-to-fixed-digits-argument": "error",
|
|
149
|
+
"unicorn/template-indent": "error",
|
|
150
|
+
"unicorn/throw-new-error": "error",
|
|
151
|
+
},
|
|
152
|
+
},
|
|
75
153
|
eslintConfigPrettier,
|
|
76
154
|
]
|
|
77
|
-
|
|
78
|
-
module.exports = { base }
|
package/src/lib/imports.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import importsPlugin from "eslint-plugin-import"
|
|
2
|
+
import unusedImports from "eslint-plugin-unused-imports"
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* @typedef {import('@typescript-eslint/utils').TSESLint.FlatConfig.Config} Config
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
/** @type {Config[]} */
|
|
9
|
-
const imports = [
|
|
9
|
+
export const imports = [
|
|
10
10
|
{
|
|
11
11
|
plugins: {
|
|
12
12
|
"unused-imports": unusedImports,
|
|
@@ -34,25 +34,32 @@ const imports = [
|
|
|
34
34
|
order: "asc",
|
|
35
35
|
groups: [
|
|
36
36
|
"client-server-only",
|
|
37
|
+
"type-import",
|
|
37
38
|
"react",
|
|
38
|
-
["builtin", "external"],
|
|
39
|
-
["internal
|
|
40
|
-
["parent", "sibling", "index"],
|
|
41
|
-
["
|
|
39
|
+
["value-builtin", "value-external"],
|
|
40
|
+
["type-internal", "value-internal"],
|
|
41
|
+
["type-parent", "type-sibling", "type-index"],
|
|
42
|
+
["value-parent", "value-sibling", "value-index"],
|
|
42
43
|
"side-effect",
|
|
43
44
|
"style",
|
|
44
45
|
"unknown",
|
|
45
46
|
],
|
|
46
|
-
customGroups:
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
47
|
+
customGroups: [
|
|
48
|
+
{
|
|
49
|
+
selector: "type",
|
|
50
|
+
groupName: "react",
|
|
51
|
+
elementNamePattern: "^react$",
|
|
50
52
|
},
|
|
51
|
-
|
|
52
|
-
|
|
53
|
+
{
|
|
54
|
+
groupName: "react",
|
|
55
|
+
elementNamePattern: ["^react$", "^react-.+"],
|
|
53
56
|
},
|
|
54
|
-
|
|
55
|
-
|
|
57
|
+
{
|
|
58
|
+
groupName: "client-server-only",
|
|
59
|
+
elementNamePattern: ["^client-only$", "^server-only$"],
|
|
60
|
+
},
|
|
61
|
+
],
|
|
62
|
+
newlinesBetween: 0,
|
|
56
63
|
internalPattern: ["^@leancodepl/.+"],
|
|
57
64
|
},
|
|
58
65
|
],
|
|
@@ -76,5 +83,3 @@ const imports = [
|
|
|
76
83
|
},
|
|
77
84
|
},
|
|
78
85
|
]
|
|
79
|
-
|
|
80
|
-
module.exports = { imports }
|
package/jest.config.js
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
module.exports = {
|
|
2
|
-
displayName: "@leancodepl/eslint-config",
|
|
3
|
-
moduleFileExtensions: ["js"],
|
|
4
|
-
testEnvironment: "node",
|
|
5
|
-
coverageDirectory: "../../../coverage/packages/linters/eslint-config",
|
|
6
|
-
testMatch: ["<rootDir>/src/**/__tests__/**/*.spec.js"],
|
|
7
|
-
transform: {},
|
|
8
|
-
}
|