Skip to content

Commit 0c0d1dd

Browse files
feat(eslint-plugin-react-hooks): support ESLint 8.x (#22248)
1 parent 380284a commit 0c0d1dd

File tree

7 files changed

+116
-5
lines changed

7 files changed

+116
-5
lines changed

.eslintrc.js

+12
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,18 @@ module.exports = {
182182
'jsx-a11y/tabindex-no-positive': OFF,
183183
},
184184
},
185+
{
186+
files: ['packages/eslint-plugin-react-hooks/src/*.js'],
187+
plugins: ['eslint-plugin'],
188+
rules: {
189+
'eslint-plugin/prefer-object-rule': ERROR,
190+
'eslint-plugin/require-meta-fixable': [
191+
ERROR,
192+
{catchNoFixerButFixableProperty: true},
193+
],
194+
'eslint-plugin/require-meta-has-suggestions': ERROR,
195+
},
196+
},
185197
{
186198
files: [
187199
'packages/react-native-renderer/**/*.js',

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
"eslint-config-fbjs": "^3.1.1",
5454
"eslint-config-prettier": "^6.9.0",
5555
"eslint-plugin-babel": "^5.3.0",
56+
"eslint-plugin-eslint-plugin": "^3.5.3",
5657
"eslint-plugin-flowtype": "^2.25.0",
5758
"eslint-plugin-jest": "^22.15.0",
5859
"eslint-plugin-jsx-a11y": "^6.3.1",

packages/eslint-plugin-react-hooks/__tests__/ESLintRuleExhaustiveDeps-test.js

+14
Original file line numberDiff line numberDiff line change
@@ -8146,4 +8146,18 @@ describe('react-hooks', () => {
81468146
...testsTypescriptEslintParser.invalid,
81478147
],
81488148
});
8149+
8150+
new ESLintTester({
8151+
parser: require.resolve('@typescript-eslint/parser-v5'),
8152+
parserOptions,
8153+
}).run('parser: @typescript-eslint/parser@^5.0.0-0', ReactHooksESLintRule, {
8154+
valid: [
8155+
...testsTypescriptEslintParserV4.valid,
8156+
...testsTypescriptEslintParser.valid,
8157+
],
8158+
invalid: [
8159+
...testsTypescriptEslintParserV4.invalid,
8160+
...testsTypescriptEslintParser.invalid,
8161+
],
8162+
});
81498163
});

packages/eslint-plugin-react-hooks/package.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,12 @@
2929
},
3030
"homepage": "https://reactjs.org/",
3131
"peerDependencies": {
32-
"eslint": "^3.0.0 || ^4.0.0 || ^5.0.0 || ^6.0.0 || ^7.0.0"
32+
"eslint": "^3.0.0 || ^4.0.0 || ^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0-0"
3333
},
3434
"devDependencies": {
3535
"@typescript-eslint/parser-v2": "npm:@typescript-eslint/parser@^2.26.0",
3636
"@typescript-eslint/parser-v3": "npm:@typescript-eslint/parser@^3.10.0",
37-
"@typescript-eslint/parser-v4": "npm:@typescript-eslint/parser@^4.1.0"
37+
"@typescript-eslint/parser-v4": "npm:@typescript-eslint/parser@^4.1.0",
38+
"@typescript-eslint/parser-v5": "npm:@typescript-eslint/parser@^5.0.0-0"
3839
}
3940
}

packages/eslint-plugin-react-hooks/src/ExhaustiveDeps.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@ export default {
1515
docs: {
1616
description:
1717
'verifies the list of dependencies for Hooks like useEffect and similar',
18-
category: 'Best Practices',
1918
recommended: true,
2019
url: 'https://github.com/facebook/react/issues/14920',
2120
},
2221
fixable: 'code',
22+
hasSuggestions: true,
2323
schema: [
2424
{
2525
type: 'object',

packages/eslint-plugin-react-hooks/src/RulesOfHooks.js

-1
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,6 @@ export default {
109109
type: 'problem',
110110
docs: {
111111
description: 'enforces the Rules of Hooks',
112-
category: 'Possible Errors',
113112
recommended: true,
114113
url: 'https://reactjs.org/docs/hooks-rules.html',
115114
},

yarn.lock

+85-1
Original file line numberDiff line numberDiff line change
@@ -2367,6 +2367,16 @@
23672367
"@typescript-eslint/typescript-estree" "4.1.0"
23682368
debug "^4.1.1"
23692369

2370+
"@typescript-eslint/parser-v5@npm:@typescript-eslint/parser@^5.0.0-0":
2371+
version "5.0.0-alpha.25"
2372+
resolved "https://registry.yarnpkg.com/@typescript-eslint/parser/-/parser-5.0.0-alpha.25.tgz#d966eb8b2cf97f0134a5589791017e0a720bb995"
2373+
integrity sha512-e0Q2fWVXle8l9pCCV2K/pQrn0Wyp8nV/Gp8AbEUqP6xLfgrOxejzcERP9y5x1rnwrp7pPXZhticsNLjqljhh6w==
2374+
dependencies:
2375+
"@typescript-eslint/scope-manager" "5.0.0-alpha.25+faf2d1d2"
2376+
"@typescript-eslint/types" "5.0.0-alpha.25+faf2d1d2"
2377+
"@typescript-eslint/typescript-estree" "5.0.0-alpha.25+faf2d1d2"
2378+
debug "^4.3.1"
2379+
23702380
"@typescript-eslint/scope-manager@4.1.0":
23712381
version "4.1.0"
23722382
resolved "https://registry.yarnpkg.com/@typescript-eslint/scope-manager/-/scope-manager-4.1.0.tgz#9e389745ee9cfe12252ed1e9958808abd6b3a683"
@@ -2375,6 +2385,14 @@
23752385
"@typescript-eslint/types" "4.1.0"
23762386
"@typescript-eslint/visitor-keys" "4.1.0"
23772387

2388+
"@typescript-eslint/scope-manager@5.0.0-alpha.25+faf2d1d2":
2389+
version "5.0.0-alpha.25"
2390+
resolved "https://registry.yarnpkg.com/@typescript-eslint/scope-manager/-/scope-manager-5.0.0-alpha.25.tgz#eb90cb682f6a3a14ba9afc4bd7c1f66cf362e1b0"
2391+
integrity sha512-tZumo5HziFbOI+unwQ7Xgimn4FHltg20TCxVCU2tl7YyFhiQl1WxnmhU7/1MUNWXzK9RA88MRKvUON1lgK1FLw==
2392+
dependencies:
2393+
"@typescript-eslint/types" "5.0.0-alpha.25+faf2d1d2"
2394+
"@typescript-eslint/visitor-keys" "5.0.0-alpha.25+faf2d1d2"
2395+
23782396
"@typescript-eslint/types@3.10.1":
23792397
version "3.10.1"
23802398
resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-3.10.1.tgz#1d7463fa7c32d8a23ab508a803ca2fe26e758727"
@@ -2385,6 +2403,11 @@
23852403
resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-4.1.0.tgz#edbd3fec346f34e13ce7aa176b03b497a32c496a"
23862404
integrity sha512-rkBqWsO7m01XckP9R2YHVN8mySOKKY2cophGM8K5uDK89ArCgahItQYdbg/3n8xMxzu2elss+an1TphlUpDuJw==
23872405

2406+
"@typescript-eslint/types@5.0.0-alpha.25+faf2d1d2":
2407+
version "5.0.0-alpha.25"
2408+
resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-5.0.0-alpha.25.tgz#2c5aaaee8d41d08fbb91193cc6df482374700b2e"
2409+
integrity sha512-M9PZ+m1vD+UaBt+9hJ1bXTA94s4fvY3fOQkwYxrtreqqdzaiNcW8F5GAO3dthzmS+6II+XAsWfCQzCoBvoiOrw==
2410+
23882411
"@typescript-eslint/typescript-estree@1.13.0":
23892412
version "1.13.0"
23902413
resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-1.13.0.tgz#8140f17d0f60c03619798f1d628b8434913dc32e"
@@ -2434,6 +2457,19 @@
24342457
semver "^7.3.2"
24352458
tsutils "^3.17.1"
24362459

2460+
"@typescript-eslint/typescript-estree@5.0.0-alpha.25+faf2d1d2":
2461+
version "5.0.0-alpha.25"
2462+
resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-5.0.0-alpha.25.tgz#1e9ad3464c93fffb1b17d8cc3e2523ae6add930b"
2463+
integrity sha512-EIEX4TSWGIBBi9DMZd8FZoI52Ua6hkHj2T8ah83BEBVMS9wCJDZyryuw0PHTesA2ZB5yiQbtNQrrODLJxz1hAw==
2464+
dependencies:
2465+
"@typescript-eslint/types" "5.0.0-alpha.25+faf2d1d2"
2466+
"@typescript-eslint/visitor-keys" "5.0.0-alpha.25+faf2d1d2"
2467+
debug "^4.3.1"
2468+
globby "^11.0.3"
2469+
is-glob "^4.0.1"
2470+
semver "^7.3.5"
2471+
tsutils "^3.21.0"
2472+
24372473
"@typescript-eslint/visitor-keys@3.10.1":
24382474
version "3.10.1"
24392475
resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-3.10.1.tgz#cd4274773e3eb63b2e870ac602274487ecd1e931"
@@ -2449,6 +2485,14 @@
24492485
"@typescript-eslint/types" "4.1.0"
24502486
eslint-visitor-keys "^2.0.0"
24512487

2488+
"@typescript-eslint/visitor-keys@5.0.0-alpha.25+faf2d1d2":
2489+
version "5.0.0-alpha.25"
2490+
resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-5.0.0-alpha.25.tgz#0b4a909d4020094e638dee1ff72e12d24783c94b"
2491+
integrity sha512-vh5AIlr3wxkhFMreop5Y1Wi5Sc9oK03J8+SiyKMEEAqwWmk6e2ryHr1001oWRuK4e6d/CjVNa73omERCWcTXTg==
2492+
dependencies:
2493+
"@typescript-eslint/types" "5.0.0-alpha.25+faf2d1d2"
2494+
eslint-visitor-keys "^3.0.0"
2495+
24522496
"@vercel/build-utils@2.5.1":
24532497
version "2.5.1"
24542498
resolved "https://registry.yarnpkg.com/@vercel/build-utils/-/build-utils-2.5.1.tgz#2f687c2d82464dd85e0ed8130bc01e5dac9b11a4"
@@ -5485,6 +5529,13 @@ debug@^3.1.0, debug@^3.1.1, debug@^3.2.5, debug@^3.2.6:
54855529
dependencies:
54865530
ms "^2.1.1"
54875531

5532+
debug@^4.3.1:
5533+
version "4.3.2"
5534+
resolved "https://registry.yarnpkg.com/debug/-/debug-4.3.2.tgz#f0a49c18ac8779e31d4a0c6029dfb76873c7428b"
5535+
integrity sha512-mOp8wKcvj7XxC78zLgw/ZA+6TSgkoE2C/ienthhRD298T7UNwAg9diBpLRxC0mOezLl4B0xV7M0cCO6P/O0Xhw==
5536+
dependencies:
5537+
ms "2.1.2"
5538+
54885539
debuglog@^1.0.1:
54895540
version "1.0.1"
54905541
resolved "https://registry.yarnpkg.com/debuglog/-/debuglog-1.0.1.tgz#aa24ffb9ac3df9a2351837cfb2d279360cd78492"
@@ -6341,6 +6392,13 @@ eslint-plugin-babel@^5.3.0:
63416392
dependencies:
63426393
eslint-rule-composer "^0.3.0"
63436394

6395+
eslint-plugin-eslint-plugin@^3.5.3:
6396+
version "3.5.3"
6397+
resolved "https://registry.yarnpkg.com/eslint-plugin-eslint-plugin/-/eslint-plugin-eslint-plugin-3.5.3.tgz#6cac958e944b820962a4cf9e65cc32a2e0415eaf"
6398+
integrity sha512-8LnYyjIOLS0gqh3QFVBkahYzkFd5UaMZkkeEvqReSjIBgajYyZaMElU8szHhqDrqr0rWkkZk33j9e4qnFN3x2A==
6399+
dependencies:
6400+
eslint-utils "^2.1.0"
6401+
63446402
eslint-plugin-flowtype@^2.25.0:
63456403
version "2.50.3"
63466404
resolved "https://registry.yarnpkg.com/eslint-plugin-flowtype/-/eslint-plugin-flowtype-2.50.3.tgz#61379d6dce1d010370acd6681740fd913d68175f"
@@ -6464,6 +6522,11 @@ eslint-visitor-keys@^2.0.0:
64646522
resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-2.0.0.tgz#21fdc8fbcd9c795cc0321f0563702095751511a8"
64656523
integrity sha512-QudtT6av5WXels9WjIM7qz1XD1cWGvX4gGXvp/zBn9nXG02D0utdU3Em2m/QjTnrsk6bBjmCygl3rmj118msQQ==
64666524

6525+
eslint-visitor-keys@^3.0.0:
6526+
version "3.0.0"
6527+
resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-3.0.0.tgz#e32e99c6cdc2eb063f204eda5db67bfe58bb4186"
6528+
integrity sha512-mJOZa35trBTb3IyRmo8xmKBZlxf+N7OnUl4+ZhJHs/r+0770Wh/LEACE2pqMGMe27G/4y8P2bYGk4J70IC5k1Q==
6529+
64676530
eslint@5.16.0:
64686531
version "5.16.0"
64696532
resolved "https://registry.yarnpkg.com/eslint/-/eslint-5.16.0.tgz#a1e3ac1aae4a3fbd8296fcf8f7ab7314cbb6abea"
@@ -10548,6 +10611,13 @@ lru-cache@^5.1.1:
1054810611
dependencies:
1054910612
yallist "^3.0.2"
1055010613

10614+
lru-cache@^6.0.0:
10615+
version "6.0.0"
10616+
resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-6.0.0.tgz#6d6fe6570ebd96aaf90fcad1dafa3b2566db3a94"
10617+
integrity sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==
10618+
dependencies:
10619+
yallist "^4.0.0"
10620+
1055110621
macos-release@^2.2.0:
1055210622
version "2.3.0"
1055310623
resolved "https://registry.yarnpkg.com/macos-release/-/macos-release-2.3.0.tgz#eb1930b036c0800adebccd5f17bc4c12de8bb71f"
@@ -11049,7 +11119,7 @@ ms@2.1.1:
1104911119
resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.1.tgz#30a5864eb3ebb0a66f2ebe6d727af06a09d86e0a"
1105011120
integrity sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg==
1105111121

11052-
ms@^2.0.0, ms@^2.1.1:
11122+
ms@2.1.2, ms@^2.0.0, ms@^2.1.1:
1105311123
version "2.1.2"
1105411124
resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.2.tgz#d09d1f357b443f493382a8eb3ccd183872ae6009"
1105511125
integrity sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==
@@ -13841,6 +13911,13 @@ semver@^7.0.0, semver@^7.1.1:
1384113911
resolved "https://registry.yarnpkg.com/semver/-/semver-7.1.1.tgz#29104598a197d6cbe4733eeecbe968f7b43a9667"
1384213912
integrity sha512-WfuG+fl6eh3eZ2qAf6goB7nhiCd7NPXhmyFxigB/TOkQyeLP8w8GsVehvtGNtnNmyboz4TgeK40B1Kbql/8c5A==
1384313913

13914+
semver@^7.3.5:
13915+
version "7.3.5"
13916+
resolved "https://registry.yarnpkg.com/semver/-/semver-7.3.5.tgz#0b621c879348d8998e4b0e4be94b3f12e6018ef7"
13917+
integrity sha512-PoeGJYh8HK4BTO/a9Tf6ZG3veo/A7ZVsYrSA6J8ny9nb3B1VrpkuN+z9OE5wfE5p6H4LchYZsegiQgbJD94ZFQ==
13918+
dependencies:
13919+
lru-cache "^6.0.0"
13920+
1384413921
send@0.17.1:
1384513922
version "0.17.1"
1384613923
resolved "https://registry.yarnpkg.com/send/-/send-0.17.1.tgz#c1d8b059f7900f7466dd4938bdc44e11ddb376c8"
@@ -15215,6 +15292,13 @@ tsutils@^3.17.1:
1521515292
dependencies:
1521615293
tslib "^1.8.1"
1521715294

15295+
tsutils@^3.21.0:
15296+
version "3.21.0"
15297+
resolved "https://registry.yarnpkg.com/tsutils/-/tsutils-3.21.0.tgz#b48717d394cea6c1e096983eed58e9d61715b623"
15298+
integrity sha512-mHKK3iUXL+3UF6xL5k0PEhKRUBKPBCv/+RkEOpjRWxxx27KKRBmmA60A9pgOUvMi8GKhRMPEmjBRPzs2W7O1OA==
15299+
dependencies:
15300+
tslib "^1.8.1"
15301+
1521815302
tty-browserify@0.0.0:
1521915303
version "0.0.0"
1522015304
resolved "https://registry.yarnpkg.com/tty-browserify/-/tty-browserify-0.0.0.tgz#a157ba402da24e9bf957f9aa69d524eed42901a6"

0 commit comments

Comments
 (0)