@foray1010/eslint-config 6.2.0 → 6.4.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 +23 -0
- package/package.json +3 -3
- package/presets/base.js +5 -1
- package/presets/react.js +20 -11
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,29 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [6.4.0](https://github.com/foray1010/common-presets/compare/@foray1010/eslint-config@6.3.1...@foray1010/eslint-config@6.4.0) (2022-04-25)
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
- **eslint-config:** add more rules for jest ([9e7b466](https://github.com/foray1010/common-presets/commit/9e7b466c332d90d56e5d41d4a006147148c3ae32))
|
|
11
|
+
|
|
12
|
+
### [6.3.1](https://github.com/foray1010/common-presets/compare/@foray1010/eslint-config@6.3.0...@foray1010/eslint-config@6.3.1) (2022-04-25)
|
|
13
|
+
|
|
14
|
+
### Bug Fixes
|
|
15
|
+
|
|
16
|
+
- allow unnecessary fragment for single expression ([3208164](https://github.com/foray1010/common-presets/commit/320816415a3554c96a71275b0f36444bc9495259))
|
|
17
|
+
|
|
18
|
+
## [6.3.0](https://github.com/foray1010/common-presets/compare/@foray1010/eslint-config@6.2.0...@foray1010/eslint-config@6.3.0) (2022-04-25)
|
|
19
|
+
|
|
20
|
+
### Features
|
|
21
|
+
|
|
22
|
+
- enable testing-library/no-global-regexp-flag-in-query ([6343da2](https://github.com/foray1010/common-presets/commit/6343da2038fca9c5ef03aa2ae02129f42ff00b82))
|
|
23
|
+
- reenable testing-library/no-await-sync-events for fire events only ([966eb24](https://github.com/foray1010/common-presets/commit/966eb24ad9c3f7b15cb3c856de61516dace2075b))
|
|
24
|
+
|
|
25
|
+
### Bug Fixes
|
|
26
|
+
|
|
27
|
+
- **eslint-config:** use jsx-runtime config from react plugin ([806e1ab](https://github.com/foray1010/common-presets/commit/806e1ab25ac42b0bb5a269e01eef659bc12aa616))
|
|
28
|
+
|
|
6
29
|
## [6.2.0](https://github.com/foray1010/common-presets/compare/@foray1010/eslint-config@6.1.3...@foray1010/eslint-config@6.2.0) (2022-04-05)
|
|
7
30
|
|
|
8
31
|
### Features
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/package",
|
|
3
3
|
"name": "@foray1010/eslint-config",
|
|
4
|
-
"version": "6.
|
|
4
|
+
"version": "6.4.0",
|
|
5
5
|
"homepage": "https://github.com/foray1010/common-presets/tree/master/packages/eslint-config#readme",
|
|
6
6
|
"bugs": "https://github.com/foray1010/common-presets/issues",
|
|
7
7
|
"repository": {
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"eslint-plugin-react": "^7.23.2",
|
|
37
37
|
"eslint-plugin-react-hooks": "^4.2.0",
|
|
38
38
|
"eslint-plugin-simple-import-sort": "^7.0.0",
|
|
39
|
-
"eslint-plugin-testing-library": "^5.
|
|
39
|
+
"eslint-plugin-testing-library": "^5.3.1"
|
|
40
40
|
},
|
|
41
41
|
"peerDependencies": {
|
|
42
42
|
"eslint": ">=7.28.0 <9",
|
|
@@ -48,5 +48,5 @@
|
|
|
48
48
|
"publishConfig": {
|
|
49
49
|
"access": "public"
|
|
50
50
|
},
|
|
51
|
-
"gitHead": "
|
|
51
|
+
"gitHead": "d6a5e814c1bccdcdd2a8a6c5de9036ca14cac6d4"
|
|
52
52
|
}
|
package/presets/base.js
CHANGED
|
@@ -124,8 +124,12 @@ module.exports = {
|
|
|
124
124
|
},
|
|
125
125
|
{
|
|
126
126
|
files: testFileGlobs,
|
|
127
|
-
extends: ['plugin:jest/recommended'],
|
|
127
|
+
extends: ['plugin:jest/recommended', 'plugin:jest/style'],
|
|
128
128
|
plugins: ['eslint-plugin-jest'],
|
|
129
|
+
rules: {
|
|
130
|
+
// make sure lifecycle hooks on the top for readability
|
|
131
|
+
'jest/prefer-hooks-on-top': 'error',
|
|
132
|
+
},
|
|
129
133
|
},
|
|
130
134
|
// typescript plugins are depended on `typescript` package
|
|
131
135
|
...(hasDep('typescript')
|
package/presets/react.js
CHANGED
|
@@ -3,7 +3,11 @@
|
|
|
3
3
|
const { testFileGlobs } = require('./utils/testUtil')
|
|
4
4
|
|
|
5
5
|
module.exports = {
|
|
6
|
-
extends: [
|
|
6
|
+
extends: [
|
|
7
|
+
'plugin:react/recommended',
|
|
8
|
+
'plugin:react/jsx-runtime',
|
|
9
|
+
'eslint-config-prettier',
|
|
10
|
+
],
|
|
7
11
|
parserOptions: {
|
|
8
12
|
sourceType: 'module',
|
|
9
13
|
ecmaFeatures: {
|
|
@@ -17,7 +21,13 @@ module.exports = {
|
|
|
17
21
|
},
|
|
18
22
|
},
|
|
19
23
|
rules: {
|
|
20
|
-
'react/jsx-no-useless-fragment':
|
|
24
|
+
'react/jsx-no-useless-fragment': [
|
|
25
|
+
'error',
|
|
26
|
+
{
|
|
27
|
+
// allow unnecessary fragment for single expression to bypass some typescript errors (e.g. do not allow string and only allow react element)
|
|
28
|
+
allowExpressions: true,
|
|
29
|
+
},
|
|
30
|
+
],
|
|
21
31
|
'react/jsx-sort-props': [
|
|
22
32
|
'error',
|
|
23
33
|
{
|
|
@@ -32,8 +42,6 @@ module.exports = {
|
|
|
32
42
|
],
|
|
33
43
|
// rely on typescript instead, and it does not work well with types that are imported from elsewhere
|
|
34
44
|
'react/prop-types': 'off',
|
|
35
|
-
// because we are using automatic react runtime
|
|
36
|
-
'react/react-in-jsx-scope': 'off',
|
|
37
45
|
'react-hooks/rules-of-hooks': 'error',
|
|
38
46
|
'react-hooks/exhaustive-deps': [
|
|
39
47
|
'error',
|
|
@@ -51,15 +59,16 @@ module.exports = {
|
|
|
51
59
|
plugins: ['eslint-plugin-jest-dom', 'eslint-plugin-testing-library'],
|
|
52
60
|
rules: {
|
|
53
61
|
// avoid using unnecessary `await` as workaround for `not wrapped in act(...)` warnings
|
|
54
|
-
'testing-library/no-
|
|
55
|
-
|
|
56
|
-
|
|
62
|
+
'testing-library/no-await-sync-events': [
|
|
63
|
+
'error',
|
|
64
|
+
{
|
|
65
|
+
eventModules: ['fire-event'],
|
|
66
|
+
},
|
|
67
|
+
],
|
|
68
|
+
// global flag /g holds state and might cause false-positives while querying for elements
|
|
69
|
+
'testing-library/no-global-regexp-flag-in-query': 'error',
|
|
57
70
|
// explicitly assert the element to prevent reader missed the test cases
|
|
58
71
|
'testing-library/prefer-explicit-assert': 'error',
|
|
59
|
-
// better error message
|
|
60
|
-
'testing-library/prefer-presence-queries': 'error',
|
|
61
|
-
// using `screen` to avoid name collision
|
|
62
|
-
'testing-library/prefer-screen-queries': 'error',
|
|
63
72
|
// prefer @testing-library/user-event over fireEvent
|
|
64
73
|
'testing-library/prefer-user-event': 'error',
|
|
65
74
|
// as `wait` is deprecated
|