Skip to content

Commit 976efdb

Browse files
committed
Sync from oss-experimental, not oss-stable (#26401)
## Overview To test useEffectEvent, we need the experimental build of the lint plugin. DiffTrain build for [21f6dba](21f6dba)
1 parent 923bb20 commit 976efdb

File tree

2 files changed

+15
-11
lines changed

2 files changed

+15
-11
lines changed

compiled/facebook-www/REVISION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
99aa082be0a2a62fef8ed747348ddf85c5641902
1+
21f6dba6a71f16b56a96182233c897468324cf99

compiled/facebook-www/eslint-plugin-react-hooks.js

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,9 @@ function _createForOfIteratorHelper(o, allowArrayLike) {
9191
/* global BigInt */
9292

9393
function isHookName(s) {
94-
95-
return /^use[A-Z0-9]/.test(s);
94+
{
95+
return s === 'use' || /^use[A-Z0-9]/.test(s);
96+
}
9697
}
9798
/**
9899
* We consider hooks to be a hook name identifier or a member expression
@@ -164,13 +165,15 @@ function isInsideComponentOrHook(node) {
164165
}
165166

166167
function isUseEffectEventIdentifier$1(node) {
167-
168-
return false;
168+
{
169+
return node.type === 'Identifier' && node.name === 'useEffectEvent';
170+
}
169171
}
170172

171173
function isUseIdentifier(node) {
172-
173-
return false;
174+
{
175+
return node.type === 'Identifier' && node.name === 'use';
176+
}
174177
}
175178

176179
var RulesOfHooks = {
@@ -707,7 +710,7 @@ var RulesOfHooks = {
707710
// another useEffectEvent
708711

709712

710-
if (node.callee.type === 'Identifier' && (node.callee.name === 'useEffect' || isUseEffectEventIdentifier$1()) && node.arguments.length > 0) {
713+
if (node.callee.type === 'Identifier' && (node.callee.name === 'useEffect' || isUseEffectEventIdentifier$1(node.callee)) && node.arguments.length > 0) {
711714
// Denote that we have traversed into a useEffect call, and stash the CallExpr for
712715
// comparison later when we exit
713716
lastEffect = node;
@@ -995,7 +998,7 @@ var ExhaustiveDeps = {
995998
if (name === 'useRef' && id.type === 'Identifier') {
996999
// useRef() return value is stable.
9971000
return true;
998-
} else if (isUseEffectEventIdentifier() && id.type === 'Identifier') {
1001+
} else if (isUseEffectEventIdentifier(callee) && id.type === 'Identifier') {
9991002
var _iterator = _createForOfIteratorHelper(resolved.references),
10001003
_step;
10011004

@@ -2558,8 +2561,9 @@ function isAncestorNodeOf(a, b) {
25582561
}
25592562

25602563
function isUseEffectEventIdentifier(node) {
2561-
2562-
return false;
2564+
{
2565+
return node.type === 'Identifier' && node.name === 'useEffectEvent';
2566+
}
25632567
}
25642568

25652569
var configs = {

0 commit comments

Comments
 (0)