@msobiecki/eslint-config 8.38.2 → 8.39.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 +31 -56
- package/README.md +73 -58
- package/eslint.config.js +209 -0
- package/jest.config.js +7 -5
- package/package.json +32 -33
- package/rules/base.js +582 -0
- package/rules/imports.js +273 -0
- package/rules/node.js +12 -0
- package/{__tests__ → tests}/base.test.js +15 -10
- package/tests/eslint.config.js +13 -0
- package/tests/test-cases/base/array-callback-return.js +2 -0
- package/tests/test-cases/base/block-scoped-var.js +40 -0
- package/tests/test-cases/base/consistent-return.js +4 -0
- package/tests/test-cases/base/curly.js +9 -0
- package/tests/test-cases/base/default-case.js +7 -0
- package/tests/test-cases/base/guard-for-in.js +4 -0
- package/tests/test-cases/base/no-alert.js +2 -0
- package/tests/test-cases/base/no-else-return.js +38 -0
- package/tests/test-cases/base/no-empty-function.js +44 -0
- package/tests/test-cases/base/no-extend-native.js +2 -0
- package/tests/test-cases/base/no-fallthrough.js +9 -0
- package/tests/test-cases/base/no-new.js +2 -0
- package/tests/test-cases/base/no-param-reassign.js +4 -0
- package/tests/test-cases/base/no-proto.js +2 -0
- package/tests/test-cases/base/no-redeclare.js +15 -0
- package/tests/test-cases/base/no-return-assign.js +4 -0
- package/tests/test-cases/base/no-script-url.js +2 -0
- package/tests/test-cases/base/no-self-compare.js +3 -0
- package/tests/test-cases/base/no-sequences.js +2 -0
- package/tests/test-cases/base/no-useless-concat.js +8 -0
- package/{__tests__ → tests}/test-cases/base/no-var.js +1 -1
- package/tests/test-cases/base/no-void.js +4 -0
- package/tests/test-cases/base/radix.js +2 -0
- package/tests/test-cases/base/yoda.js +29 -0
- package/utils/get-ts-config.js +16 -9
- package/.eslintrc.json +0 -3
- package/__tests__/.eslintrc.json +0 -3
- package/__tests__/test-cases/base/comma-dangle.js +0 -2
- package/best-practice-next.js +0 -3
- package/best-practice-react.js +0 -3
- package/best-practice.js +0 -3
- package/index.js +0 -3
- package/jest-dom.js +0 -3
- package/jest-react.js +0 -3
- package/jest.js +0 -3
- package/next.js +0 -3
- package/node.js +0 -3
- package/presets/base/base.js +0 -26
- package/presets/best-practice/best-practice-next.js +0 -12
- package/presets/best-practice/best-practice-react.js +0 -37
- package/presets/best-practice/best-practice.js +0 -38
- package/presets/jest/jest-base.js +0 -8
- package/presets/jest/jest-dom.js +0 -9
- package/presets/jest/jest-react.js +0 -8
- package/presets/next/next.js +0 -13
- package/presets/node/node.js +0 -3
- package/presets/react/react-jsx.js +0 -3
- package/presets/react/react.js +0 -35
- package/react-jsx.js +0 -3
- package/react.js +0 -3
- /package/{__tests__ → tests}/test-cases/base/camelcase.js +0 -0
- /package/{__tests__ → tests}/test-cases/base/eqeqeq.js +0 -0
- /package/{__tests__ → tests}/test-cases/base/no-console.js +0 -0
- /package/{__tests__ → tests}/test-cases/base/no-eval.js +0 -0
- /package/{__tests__ → tests}/test-cases/base/no-undef.js +0 -0
- /package/{__tests__ → tests}/test-cases/base/no-unused-vars.js +0 -0
- /package/{__tests__ → tests}/test-cases/base/prefer-const.js +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
# [8.39.0](https://github.com/msobiecki/eslint-config/compare/v8.38.2...v8.39.0) (2025-10-18)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* update Eslin9 ([#272](https://github.com/msobiecki/eslint-config/issues/272)) ([2d2763f](https://github.com/msobiecki/eslint-config/commit/2d2763f22deee8239a5aac9b67137a4adb07a685))
|
|
7
|
+
|
|
1
8
|
## [8.38.2](https://github.com/msobiecki/eslint-config/compare/v8.38.1...v8.38.2) (2025-09-09)
|
|
2
9
|
|
|
3
10
|
|
|
@@ -7,182 +14,150 @@
|
|
|
7
14
|
|
|
8
15
|
## [8.38.1](https://github.com/msobiecki/eslint-config/compare/v8.38.0...v8.38.1) (2025-09-09)
|
|
9
16
|
|
|
10
|
-
|
|
11
17
|
### Bug Fixes
|
|
12
18
|
|
|
13
|
-
|
|
19
|
+
- change glob ([1be2349](https://github.com/msobiecki/eslint-config/commit/1be234927643c4acb093919919fedaad6c811127))
|
|
14
20
|
|
|
15
21
|
# [8.38.0](https://github.com/msobiecki/eslint-config/compare/v8.37.0...v8.38.0) (2025-09-09)
|
|
16
22
|
|
|
17
|
-
|
|
18
23
|
### Features
|
|
19
24
|
|
|
20
|
-
|
|
25
|
+
- update ([b1636ab](https://github.com/msobiecki/eslint-config/commit/b1636abae3b4f7c733bb077c594b491f04f4e301))
|
|
21
26
|
|
|
22
27
|
# [8.37.0](https://github.com/msobiecki/eslint-config/compare/v8.36.0...v8.37.0) (2025-09-08)
|
|
23
28
|
|
|
24
|
-
|
|
25
29
|
### Features
|
|
26
30
|
|
|
27
|
-
|
|
31
|
+
- update ([d6861a5](https://github.com/msobiecki/eslint-config/commit/d6861a563b8afbe85960a182b1a94add76b8413e))
|
|
28
32
|
|
|
29
33
|
# [8.36.0](https://github.com/msobiecki/eslint-config/compare/v8.35.0...v8.36.0) (2025-09-08)
|
|
30
34
|
|
|
31
|
-
|
|
32
35
|
### Features
|
|
33
36
|
|
|
34
|
-
|
|
37
|
+
- update ([73f979d](https://github.com/msobiecki/eslint-config/commit/73f979dbdd1c72faf21ca409dd0434c992d04bdc))
|
|
35
38
|
|
|
36
39
|
# [8.35.0](https://github.com/msobiecki/eslint-config/compare/v8.34.0...v8.35.0) (2025-09-08)
|
|
37
40
|
|
|
38
|
-
|
|
39
41
|
### Features
|
|
40
42
|
|
|
41
|
-
|
|
43
|
+
- update ([7b2ff0c](https://github.com/msobiecki/eslint-config/commit/7b2ff0cf977199f972c350861e8c8deaafa45785))
|
|
42
44
|
|
|
43
45
|
# [8.34.0](https://github.com/msobiecki/eslint-config/compare/v8.33.0...v8.34.0) (2025-09-08)
|
|
44
46
|
|
|
45
|
-
|
|
46
47
|
### Features
|
|
47
48
|
|
|
48
|
-
|
|
49
|
+
- update ([bcabb68](https://github.com/msobiecki/eslint-config/commit/bcabb68efa5d1f695174d7d6359dd19dd475990e))
|
|
49
50
|
|
|
50
51
|
# [8.33.0](https://github.com/msobiecki/eslint-config/compare/v8.32.0...v8.33.0) (2025-09-07)
|
|
51
52
|
|
|
52
|
-
|
|
53
53
|
### Features
|
|
54
54
|
|
|
55
|
-
|
|
55
|
+
- update ([a4f4ea1](https://github.com/msobiecki/eslint-config/commit/a4f4ea1ed091fd32d0a75635afcced56230613a3))
|
|
56
56
|
|
|
57
57
|
# [8.32.0](https://github.com/msobiecki/eslint-config/compare/v8.31.0...v8.32.0) (2025-09-07)
|
|
58
58
|
|
|
59
|
-
|
|
60
59
|
### Features
|
|
61
60
|
|
|
62
|
-
|
|
61
|
+
- update ([50a2325](https://github.com/msobiecki/eslint-config/commit/50a2325144abaede053a3c221b350c4ffca9a744))
|
|
63
62
|
|
|
64
63
|
# [8.31.0](https://github.com/msobiecki/eslint-config/compare/v8.30.0...v8.31.0) (2025-09-01)
|
|
65
64
|
|
|
66
|
-
|
|
67
65
|
### Features
|
|
68
66
|
|
|
69
|
-
|
|
67
|
+
- update ([1e31f82](https://github.com/msobiecki/eslint-config/commit/1e31f82f515e932e529d8e5e00e5933c2fe839e0))
|
|
70
68
|
|
|
71
69
|
# [8.30.0](https://github.com/msobiecki/eslint-config/compare/v8.29.0...v8.30.0) (2025-09-01)
|
|
72
70
|
|
|
73
|
-
|
|
74
71
|
### Features
|
|
75
72
|
|
|
76
|
-
|
|
73
|
+
- update ([8160f97](https://github.com/msobiecki/eslint-config/commit/8160f97c8a671c8375bbfd2d5dfdb0158e2d777a))
|
|
77
74
|
|
|
78
75
|
# [8.29.0](https://github.com/msobiecki/eslint-config/compare/v8.28.0...v8.29.0) (2025-08-25)
|
|
79
76
|
|
|
80
|
-
|
|
81
77
|
### Features
|
|
82
78
|
|
|
83
|
-
|
|
79
|
+
- update react-hooks ([8eb3c50](https://github.com/msobiecki/eslint-config/commit/8eb3c503b160330df62d6bfa630adbf9d28943f5))
|
|
84
80
|
|
|
85
81
|
# [8.28.0](https://github.com/msobiecki/eslint-config/compare/v8.27.0...v8.28.0) (2025-08-25)
|
|
86
82
|
|
|
87
|
-
|
|
88
83
|
### Features
|
|
89
84
|
|
|
90
|
-
|
|
85
|
+
- update react-hooks ([d0fcd8b](https://github.com/msobiecki/eslint-config/commit/d0fcd8be9ecc90655035206c0b93772e79cc2604))
|
|
91
86
|
|
|
92
87
|
# [8.27.0](https://github.com/msobiecki/eslint-config/compare/v8.26.0...v8.27.0) (2025-08-25)
|
|
93
88
|
|
|
94
|
-
|
|
95
89
|
### Features
|
|
96
90
|
|
|
97
|
-
|
|
91
|
+
- update react-hooks ([08572f4](https://github.com/msobiecki/eslint-config/commit/08572f4f094ce493f5c0ff35ad7260d47b8b7ec9))
|
|
98
92
|
|
|
99
93
|
# [8.26.0](https://github.com/msobiecki/eslint-config/compare/v8.25.0...v8.26.0) (2025-07-22)
|
|
100
94
|
|
|
101
|
-
|
|
102
95
|
### Features
|
|
103
96
|
|
|
104
|
-
|
|
97
|
+
- improve semantic release ([3d1db76](https://github.com/msobiecki/eslint-config/commit/3d1db768e1c460eb54c89ba3678f0c44a80b0fa7))
|
|
105
98
|
|
|
106
99
|
# [8.25.0](https://github.com/msobiecki/eslint-config/compare/v8.24.0...v8.25.0) (2025-07-22)
|
|
107
100
|
|
|
108
|
-
|
|
109
101
|
### Features
|
|
110
102
|
|
|
111
|
-
|
|
103
|
+
- improve semantic release ([458c515](https://github.com/msobiecki/eslint-config/commit/458c515226fc614e74f04b8fe2531bfd7791eb35))
|
|
112
104
|
|
|
113
105
|
# [8.24.0](https://github.com/msobiecki/eslint-config/compare/v8.23.0...v8.24.0) (2025-07-22)
|
|
114
106
|
|
|
115
|
-
|
|
116
107
|
### Features
|
|
117
108
|
|
|
118
|
-
|
|
109
|
+
- improve semantic release ([2575914](https://github.com/msobiecki/eslint-config/commit/25759149e2f9207505dc0d4199892dcd25913aa8))
|
|
119
110
|
|
|
120
111
|
# [8.23.0](https://github.com/msobiecki/eslint-config/compare/v8.22.0...v8.23.0) (2025-07-22)
|
|
121
112
|
|
|
122
|
-
|
|
123
113
|
### Features
|
|
124
114
|
|
|
125
|
-
|
|
115
|
+
- improve semantic release ([e0b05f5](https://github.com/msobiecki/eslint-config/commit/e0b05f58685886be477524e1fc9dbbb4c1c68b54))
|
|
126
116
|
|
|
127
117
|
# [8.22.0](https://github.com/msobiecki/eslint-config/compare/v8.21.0...v8.22.0) (2025-07-22)
|
|
128
118
|
|
|
129
|
-
|
|
130
119
|
### Features
|
|
131
120
|
|
|
132
|
-
|
|
121
|
+
- improve semantic release ([58ce928](https://github.com/msobiecki/eslint-config/commit/58ce928d03d21bf046ecb12eae60d3e1290c4322))
|
|
133
122
|
|
|
134
123
|
# [8.21.0](https://github.com/msobiecki/eslint-config/compare/v8.20.0...v8.21.0) (2025-07-22)
|
|
135
124
|
|
|
136
|
-
|
|
137
125
|
### Features
|
|
138
126
|
|
|
139
|
-
|
|
127
|
+
- improve semantic release ([0476e97](https://github.com/msobiecki/eslint-config/commit/0476e9753096fb0e57ba5fa87ae8ab5cc81a2336))
|
|
140
128
|
|
|
141
129
|
# [8.20.0](https://github.com/msobiecki/eslint-config/compare/v8.19.0...v8.20.0) (2025-07-22)
|
|
142
130
|
|
|
143
|
-
|
|
144
131
|
### Features
|
|
145
132
|
|
|
146
|
-
|
|
133
|
+
- improve semantic release ([4e083b7](https://github.com/msobiecki/eslint-config/commit/4e083b7dfa197c3a470f355dfd195e19eb45ccb4))
|
|
147
134
|
|
|
148
135
|
# [8.19.0](https://github.com/msobiecki/eslint-config/compare/v8.18.0...v8.19.0) (2025-07-22)
|
|
149
136
|
|
|
150
|
-
|
|
151
137
|
### Features
|
|
152
138
|
|
|
153
|
-
|
|
139
|
+
- improve semantic release ([5073232](https://github.com/msobiecki/eslint-config/commit/507323224c21f0b8afe7f6249db810bd51f5d070))
|
|
154
140
|
|
|
155
141
|
# [8.18.0](https://github.com/msobiecki/eslint-config/compare/v8.17.3...v8.18.0) (2025-07-22)
|
|
156
142
|
|
|
157
|
-
|
|
158
143
|
### Features
|
|
159
144
|
|
|
160
|
-
|
|
145
|
+
- improve semantic release ([3456386](https://github.com/msobiecki/eslint-config/commit/3456386d602734f21c4b92bd0d3c5903c7965142))
|
|
161
146
|
|
|
162
147
|
## [8.17.3](https://github.com/msobiecki/eslint-config/compare/v8.17.2...v8.17.3) (2025-07-21)
|
|
163
148
|
|
|
164
|
-
|
|
165
|
-
|
|
166
149
|
## [8.17.2](https://github.com/msobiecki/eslint-config/compare/v8.17.1...v8.17.2) (2025-06-04)
|
|
167
150
|
|
|
168
|
-
|
|
169
|
-
|
|
170
151
|
## [8.17.1](https://github.com/msobiecki/eslint-config/compare/v8.17.0...v8.17.1) (2025-06-04)
|
|
171
152
|
|
|
172
|
-
|
|
173
|
-
|
|
174
153
|
# [8.17.0](https://github.com/msobiecki/eslint-config/compare/v8.16.0...v8.17.0) (2025-04-17)
|
|
175
154
|
|
|
176
|
-
|
|
177
155
|
### Features
|
|
178
156
|
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
157
|
+
- update ([b3498f4](https://github.com/msobiecki/eslint-config/commit/b3498f4a5bfad1562ec73c034e7da34304c917cd))
|
|
182
158
|
|
|
183
159
|
# [8.16.0](https://github.com/msobiecki/eslint-config/compare/v8.15.0...v8.16.0) (2025-04-17)
|
|
184
160
|
|
|
185
|
-
|
|
186
161
|
### Features
|
|
187
162
|
|
|
188
|
-
|
|
163
|
+
- update ([746ae64](https://github.com/msobiecki/eslint-config/commit/746ae6488763bbad5302e7d223448f1559a1fdec))
|
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
[](https://github.com/msobiecki/eslint-config/blob/master/LICENSE)
|
|
4
4
|
|
|
5
|
-
Custom ESLint configuration for projects. It extends popular
|
|
5
|
+
Custom ESLint configuration for projects. It extends popular configs in one place.
|
|
6
6
|
|
|
7
7
|
## Table of Contents
|
|
8
8
|
|
|
@@ -19,94 +19,109 @@ npm install --save-dev @msobiecki/eslint-config
|
|
|
19
19
|
Make sure to install the necessary peer dependencies as well:
|
|
20
20
|
|
|
21
21
|
```bash
|
|
22
|
-
npm install --save-dev eslint prettier
|
|
22
|
+
npm install --save-dev eslint prettier typescript
|
|
23
23
|
```
|
|
24
24
|
|
|
25
25
|
## Usage
|
|
26
26
|
|
|
27
|
-
To use this ESLint configuration, you need to extend it in your project's
|
|
27
|
+
To use this ESLint configuration, you need to extend it in your project's `eslint.config.js` file:
|
|
28
28
|
|
|
29
29
|
### base javascript/typescript configuration
|
|
30
30
|
|
|
31
|
-
```
|
|
32
|
-
{
|
|
33
|
-
|
|
34
|
-
|
|
31
|
+
```javascript
|
|
32
|
+
import { defineConfig } from "eslint/config";
|
|
33
|
+
import { basePreset } from "@msobiecki/eslint-config";
|
|
34
|
+
|
|
35
|
+
export default defineConfig([
|
|
36
|
+
basePreset,
|
|
37
|
+
...
|
|
38
|
+
]);
|
|
35
39
|
```
|
|
36
40
|
|
|
37
|
-
### react javascript/typescript configuration
|
|
38
41
|
|
|
39
|
-
|
|
40
|
-
{
|
|
41
|
-
"extends": [
|
|
42
|
-
"@msobiecki/eslint-config/react",
|
|
43
|
-
"@msobiecki/eslint-config/react-jsx"
|
|
44
|
-
]
|
|
45
|
-
}
|
|
46
|
-
```
|
|
42
|
+
### best practice configuration
|
|
47
43
|
|
|
48
|
-
|
|
44
|
+
```javascript
|
|
45
|
+
import { defineConfig } from "eslint/config";
|
|
46
|
+
import { bestPracticePreset } from "@msobiecki/eslint-config";
|
|
49
47
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
48
|
+
export default defineConfig([
|
|
49
|
+
...,
|
|
50
|
+
bestPracticePreset,
|
|
51
|
+
]);
|
|
54
52
|
```
|
|
55
53
|
|
|
56
|
-
###
|
|
54
|
+
### import configuration
|
|
55
|
+
|
|
56
|
+
```javascript
|
|
57
|
+
import { defineConfig } from "eslint/config";
|
|
58
|
+
import { importPreset } from "@msobiecki/eslint-config";
|
|
57
59
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
60
|
+
export default defineConfig([
|
|
61
|
+
...,
|
|
62
|
+
importPreset,
|
|
63
|
+
]);
|
|
62
64
|
```
|
|
63
65
|
|
|
64
|
-
###
|
|
66
|
+
### react javascript/typescript configuration
|
|
65
67
|
|
|
66
|
-
|
|
68
|
+
```javascript
|
|
69
|
+
import { defineConfig } from "eslint/config";
|
|
70
|
+
import { reactPreset } from "@msobiecki/eslint-config";
|
|
67
71
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
+
export default defineConfig([
|
|
73
|
+
...,
|
|
74
|
+
reactPreset
|
|
75
|
+
]);
|
|
72
76
|
```
|
|
73
77
|
|
|
74
|
-
|
|
78
|
+
### next configuration
|
|
79
|
+
|
|
80
|
+
```javascript
|
|
81
|
+
import { defineConfig } from "eslint/config";
|
|
82
|
+
import { nextPreset } from "@msobiecki/eslint-config";
|
|
75
83
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
"@msobiecki/eslint-config/jest-dom"
|
|
81
|
-
]
|
|
82
|
-
}
|
|
84
|
+
export default defineConfig([
|
|
85
|
+
...,
|
|
86
|
+
nextPreset
|
|
87
|
+
]);
|
|
83
88
|
```
|
|
84
89
|
|
|
85
|
-
|
|
90
|
+
### node configuration
|
|
86
91
|
|
|
87
|
-
```
|
|
88
|
-
{
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
92
|
+
```javascript
|
|
93
|
+
import { defineConfig } from "eslint/config";
|
|
94
|
+
import { node } from "@msobiecki/eslint-config";
|
|
95
|
+
|
|
96
|
+
export default defineConfig([
|
|
97
|
+
...,
|
|
98
|
+
node
|
|
99
|
+
]);
|
|
94
100
|
```
|
|
95
101
|
|
|
96
|
-
###
|
|
102
|
+
### jest configuration
|
|
103
|
+
|
|
104
|
+
```javascript
|
|
105
|
+
import { defineConfig } from "eslint/config";
|
|
106
|
+
import { jestPreset } from "@msobiecki/eslint-config";
|
|
97
107
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
108
|
+
export default defineConfig([
|
|
109
|
+
...,
|
|
110
|
+
jestPreset
|
|
111
|
+
]);
|
|
102
112
|
```
|
|
103
113
|
|
|
104
|
-
If you have an existing ESLint configuration, you can merge it with this configuration using the `extends` property:
|
|
105
114
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
}
|
|
115
|
+
### storybook configuration
|
|
116
|
+
|
|
117
|
+
```javascript
|
|
118
|
+
import { defineConfig } from "eslint/config";
|
|
119
|
+
import { storybookPreset } from "@msobiecki/eslint-config";
|
|
120
|
+
|
|
121
|
+
export default defineConfig([
|
|
122
|
+
...,
|
|
123
|
+
storybookPreset,
|
|
124
|
+
]);
|
|
110
125
|
```
|
|
111
126
|
|
|
112
127
|
## License
|
package/eslint.config.js
ADDED
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
import eslint from "@eslint/js";
|
|
2
|
+
import tseslint from "typescript-eslint";
|
|
3
|
+
|
|
4
|
+
import reactBasePlugin from "eslint-plugin-react";
|
|
5
|
+
import reactHooksPlugin from "eslint-plugin-react-hooks";
|
|
6
|
+
import nPlugin from "eslint-plugin-n";
|
|
7
|
+
import nextPlugin from "@next/eslint-plugin-next";
|
|
8
|
+
import jestPlugin from "eslint-plugin-jest";
|
|
9
|
+
import jestDomPlugin from "eslint-plugin-jest-dom";
|
|
10
|
+
import testingLibraryPlugin from "eslint-plugin-testing-library";
|
|
11
|
+
import prettierPlugin from "eslint-plugin-prettier";
|
|
12
|
+
import eslintCommentsPlugin from "eslint-plugin-eslint-comments";
|
|
13
|
+
import unicornPlugin from "eslint-plugin-unicorn";
|
|
14
|
+
import promisePlugin from "eslint-plugin-promise";
|
|
15
|
+
import securityPlugin from "eslint-plugin-security";
|
|
16
|
+
import jsdocPlugin from "eslint-plugin-jsdoc";
|
|
17
|
+
import compatPlugin from "eslint-plugin-compat";
|
|
18
|
+
import jsxA11yPlugin from "eslint-plugin-jsx-a11y";
|
|
19
|
+
import importPlugin from "eslint-plugin-import";
|
|
20
|
+
import storybookPlugin from "eslint-plugin-storybook";
|
|
21
|
+
|
|
22
|
+
import getTsConfig from "./utils/get-ts-config.js";
|
|
23
|
+
|
|
24
|
+
import baseCustomRules from "./rules/base.js";
|
|
25
|
+
import nodeRules from "./rules/node.js";
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Base / best-practice preset
|
|
29
|
+
*/
|
|
30
|
+
export const basePreset = [
|
|
31
|
+
{
|
|
32
|
+
name: "Base JavaScript",
|
|
33
|
+
files: ["**/*.{js,jsx,cjs,mjs,ts,tsx,cts,mts}"],
|
|
34
|
+
rules: {
|
|
35
|
+
...eslint.configs.recommended.rules,
|
|
36
|
+
// Custom best-practice rules
|
|
37
|
+
...baseCustomRules,
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
name: "Base TypeScript",
|
|
42
|
+
files: ["**/*.{ts,tsx,cts,mts}"],
|
|
43
|
+
languageOptions: {
|
|
44
|
+
sourceType: "module",
|
|
45
|
+
parser: tseslint.parser,
|
|
46
|
+
parserOptions: { project: getTsConfig(), ecmaFeatures: { jsx: true } },
|
|
47
|
+
},
|
|
48
|
+
plugins: { "@typescript-eslint": tseslint.plugin },
|
|
49
|
+
rules: {
|
|
50
|
+
...tseslint.configs?.strict?.[2]?.rules,
|
|
51
|
+
...tseslint.configs?.stylistic?.[2]?.rules,
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
];
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Best-practice preset
|
|
58
|
+
*/
|
|
59
|
+
export const bestPracticePreset = [
|
|
60
|
+
{
|
|
61
|
+
name: "Best Practices",
|
|
62
|
+
files: ["**/*.{js,ts,mjs,mts,cjs,cts,jsx,tsx}"],
|
|
63
|
+
plugins: {
|
|
64
|
+
prettier: prettierPlugin,
|
|
65
|
+
"eslint-comments": eslintCommentsPlugin,
|
|
66
|
+
unicorn: unicornPlugin,
|
|
67
|
+
promise: promisePlugin,
|
|
68
|
+
security: securityPlugin,
|
|
69
|
+
jsdoc: jsdocPlugin,
|
|
70
|
+
compat: compatPlugin,
|
|
71
|
+
},
|
|
72
|
+
rules: {
|
|
73
|
+
...jsdocPlugin.configs?.["flat/recommended-mixed"]?.rules,
|
|
74
|
+
...eslintCommentsPlugin.configs?.recommended?.rules,
|
|
75
|
+
...promisePlugin.configs?.recommended?.rules,
|
|
76
|
+
...securityPlugin.configs?.recommended?.rules,
|
|
77
|
+
...compatPlugin.configs?.recommended?.rules,
|
|
78
|
+
...unicornPlugin.configs?.recommended?.rules,
|
|
79
|
+
...prettierPlugin.configs?.recommended?.rules,
|
|
80
|
+
|
|
81
|
+
"unicorn/no-array-for-each": "off",
|
|
82
|
+
},
|
|
83
|
+
},
|
|
84
|
+
];
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* React preset
|
|
88
|
+
*/
|
|
89
|
+
export const reactPreset = [
|
|
90
|
+
{
|
|
91
|
+
name: "React",
|
|
92
|
+
files: ["**/*.{js,jsx,ts,tsx}"],
|
|
93
|
+
plugins: {
|
|
94
|
+
react: reactBasePlugin,
|
|
95
|
+
"react-hooks": reactHooksPlugin,
|
|
96
|
+
"jsx-a11y": jsxA11yPlugin,
|
|
97
|
+
},
|
|
98
|
+
languageOptions: {
|
|
99
|
+
parserOptions: { ecmaFeatures: { jsx: true } },
|
|
100
|
+
},
|
|
101
|
+
rules: {
|
|
102
|
+
...reactBasePlugin.configs?.recommended?.rules,
|
|
103
|
+
...reactHooksPlugin.configs?.flat?.recommended?.rules,
|
|
104
|
+
...jsxA11yPlugin.configs?.recommended?.rules,
|
|
105
|
+
},
|
|
106
|
+
settings: { react: { version: "detect" } },
|
|
107
|
+
},
|
|
108
|
+
];
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Node preset
|
|
112
|
+
*/
|
|
113
|
+
export const nodePreset = [
|
|
114
|
+
{
|
|
115
|
+
name: "Node.js",
|
|
116
|
+
files: ["**/*.{js,mjs,cjs}"],
|
|
117
|
+
plugins: { n: nPlugin },
|
|
118
|
+
rules: { ...nPlugin.configs?.["flat/recommended"]?.rules, ...nodeRules },
|
|
119
|
+
},
|
|
120
|
+
];
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Next.js preset
|
|
124
|
+
*/
|
|
125
|
+
export const nextPreset = [
|
|
126
|
+
{
|
|
127
|
+
name: "Next.js",
|
|
128
|
+
files: ["**/*.{js,ts,jsx,tsx}"],
|
|
129
|
+
plugins: { "@next/next": nextPlugin },
|
|
130
|
+
rules: { ...nextPlugin.configs?.recommended?.rules },
|
|
131
|
+
},
|
|
132
|
+
];
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Import plugin preset
|
|
136
|
+
*/
|
|
137
|
+
export const importPreset = [
|
|
138
|
+
{
|
|
139
|
+
name: "Import plugin",
|
|
140
|
+
files: ["**/*.{js,jsx,mjs,cjs}"],
|
|
141
|
+
plugins: { import: importPlugin },
|
|
142
|
+
rules: {
|
|
143
|
+
...importPlugin.configs?.recommended?.rules,
|
|
144
|
+
},
|
|
145
|
+
},
|
|
146
|
+
{
|
|
147
|
+
name: "Import plugin TypeScript",
|
|
148
|
+
files: ["**/*.{ts,tsx,mts,cts}"],
|
|
149
|
+
plugins: { import: importPlugin },
|
|
150
|
+
rules: {
|
|
151
|
+
...importPlugin.configs?.["recommended-typescript"]?.rules,
|
|
152
|
+
},
|
|
153
|
+
},
|
|
154
|
+
];
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* Jest preset
|
|
158
|
+
*/
|
|
159
|
+
export const jestPreset = [
|
|
160
|
+
{
|
|
161
|
+
name: "Jest",
|
|
162
|
+
files: ["**/__tests__/**/*.[jt]s?(x)", "**/?(*.)+(spec|test).[jt]s?(x)"],
|
|
163
|
+
languageOptions: {
|
|
164
|
+
globals: {
|
|
165
|
+
...jestPlugin.configs?.["flat/recommended"]?.languageOptions?.globals,
|
|
166
|
+
process: "readonly",
|
|
167
|
+
},
|
|
168
|
+
},
|
|
169
|
+
plugins: { jest: jestPlugin },
|
|
170
|
+
rules: {
|
|
171
|
+
...jestPlugin.configs?.["flat/recommended"]?.rules,
|
|
172
|
+
...jestPlugin.configs?.style?.rules,
|
|
173
|
+
},
|
|
174
|
+
},
|
|
175
|
+
{
|
|
176
|
+
name: "Jest DOM & Testing Library",
|
|
177
|
+
files: ["**/__tests__/**/*.[jt]s?(x)", "**/?(*.)+(spec|test).[jt]s?(x)"],
|
|
178
|
+
plugins: {
|
|
179
|
+
"jest-dom": jestDomPlugin,
|
|
180
|
+
"testing-library": testingLibraryPlugin,
|
|
181
|
+
},
|
|
182
|
+
rules: {
|
|
183
|
+
...jestDomPlugin.configs?.recommended?.rules,
|
|
184
|
+
...testingLibraryPlugin.configs?.dom?.rules,
|
|
185
|
+
},
|
|
186
|
+
},
|
|
187
|
+
{
|
|
188
|
+
name: "Testing Library React",
|
|
189
|
+
files: ["**/__tests__/**/*.[jt]s?(x)", "**/?(*.)+(spec|test).[jt]s?(x)"],
|
|
190
|
+
plugins: { "testing-library": testingLibraryPlugin },
|
|
191
|
+
rules: { ...testingLibraryPlugin.configs?.react?.rules },
|
|
192
|
+
},
|
|
193
|
+
];
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
* Storybook preset
|
|
197
|
+
*/
|
|
198
|
+
export const storybookPreset = [
|
|
199
|
+
{
|
|
200
|
+
name: "Storybook",
|
|
201
|
+
files: ["**/*.stories.{js,ts,jsx,tsx}"],
|
|
202
|
+
plugins: { storybook: storybookPlugin },
|
|
203
|
+
rules: {
|
|
204
|
+
...storybookPlugin?.configs?.["flat/recommended"]?.rules,
|
|
205
|
+
},
|
|
206
|
+
},
|
|
207
|
+
];
|
|
208
|
+
|
|
209
|
+
export default [...basePreset, ...bestPracticePreset];
|
package/jest.config.js
CHANGED
|
@@ -83,6 +83,8 @@ const config = {
|
|
|
83
83
|
// "cjs",
|
|
84
84
|
// "jsx",
|
|
85
85
|
// "ts",
|
|
86
|
+
// "mts",
|
|
87
|
+
// "cts",
|
|
86
88
|
// "tsx",
|
|
87
89
|
// "json",
|
|
88
90
|
// "node"
|
|
@@ -155,12 +157,12 @@ const config = {
|
|
|
155
157
|
|
|
156
158
|
// The glob patterns Jest uses to detect test files
|
|
157
159
|
// testMatch: [
|
|
158
|
-
// "**/__tests__
|
|
159
|
-
// "**/?(*.)+(spec|test)
|
|
160
|
+
// "**/__tests__/**/*.?([mc])[jt]s?(x)",
|
|
161
|
+
// "**/?(*.)+(spec|test).?([mc])[jt]s?(x)"
|
|
160
162
|
// ],
|
|
161
163
|
|
|
162
164
|
// An array of regexp pattern strings that are matched against all test paths, matched tests are skipped
|
|
163
|
-
testPathIgnorePatterns: ["/
|
|
165
|
+
// testPathIgnorePatterns: ["/node_modules/"],
|
|
164
166
|
|
|
165
167
|
// The regexp pattern or array of patterns that Jest uses to detect test files
|
|
166
168
|
// testRegex: [],
|
|
@@ -172,7 +174,7 @@ const config = {
|
|
|
172
174
|
// testRunner: "jest-circus/runner",
|
|
173
175
|
|
|
174
176
|
// A map from regular expressions to paths to transformers
|
|
175
|
-
transform: {
|
|
177
|
+
// transform: {},
|
|
176
178
|
|
|
177
179
|
// An array of regexp pattern strings that are matched against all source file paths, matched files will skip transformation
|
|
178
180
|
// transformIgnorePatterns: [
|
|
@@ -193,4 +195,4 @@ const config = {
|
|
|
193
195
|
// watchman: true,
|
|
194
196
|
};
|
|
195
197
|
|
|
196
|
-
|
|
198
|
+
export default config;
|