Skip to content

Commit 1f2fe14

Browse files
authored
Merge branch 'main' into update-react-refresh-builtin-hooks
2 parents a498588 + 95ec128 commit 1f2fe14

File tree

107 files changed

+5378
-2926
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

107 files changed

+5378
-2926
lines changed

.github/ISSUE_TEMPLATE/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
contact_links:
22
- name: 📃 Documentation Issue
3-
url: https://github.com/reactjs/reactjs.org/issues/new
3+
url: https://github.com/reactjs/react.dev/issues/new/choose
44
about: This issue tracker is not for documentation issues. Please file documentation issues here.
55
- name: 🤔 Questions and Help
66
url: https://reactjs.org/community/support.html

fixtures/dom/src/__tests__/nested-act-test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ describe('unmocked scheduler', () => {
2020
beforeEach(() => {
2121
jest.resetModules();
2222
React = require('react');
23-
DOMAct = React.unstable_act;
23+
DOMAct = React.act;
2424
TestRenderer = require('react-test-renderer');
2525
TestAct = TestRenderer.act;
2626
});
@@ -61,7 +61,7 @@ describe('mocked scheduler', () => {
6161
require.requireActual('scheduler/unstable_mock')
6262
);
6363
React = require('react');
64-
DOMAct = React.unstable_act;
64+
DOMAct = React.act;
6565
TestRenderer = require('react-test-renderer');
6666
TestAct = TestRenderer.act;
6767
});

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

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7747,6 +7747,33 @@ const testsTypescript = {
77477747
}
77487748
`,
77497749
},
7750+
{
7751+
code: normalizeIndent`
7752+
function App(props) {
7753+
React.useEffect(() => {
7754+
console.log(props.test);
7755+
}, [props.test] as const);
7756+
}
7757+
`,
7758+
},
7759+
{
7760+
code: normalizeIndent`
7761+
function App(props) {
7762+
React.useEffect(() => {
7763+
console.log(props.test);
7764+
}, [props.test] as any);
7765+
}
7766+
`,
7767+
},
7768+
{
7769+
code: normalizeIndent`
7770+
function App(props) {
7771+
React.useEffect((() => {
7772+
console.log(props.test);
7773+
}) as any, [props.test]);
7774+
}
7775+
`,
7776+
},
77507777
],
77517778
invalid: [
77527779
{

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

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -618,7 +618,12 @@ export default {
618618

619619
const declaredDependencies = [];
620620
const externalDependencies = new Set();
621-
if (declaredDependenciesNode.type !== 'ArrayExpression') {
621+
const isArrayExpression =
622+
declaredDependenciesNode.type === 'ArrayExpression';
623+
const isTSAsArrayExpression =
624+
declaredDependenciesNode.type === 'TSAsExpression' &&
625+
declaredDependenciesNode.expression.type === 'ArrayExpression';
626+
if (!isArrayExpression && !isTSAsArrayExpression) {
622627
// If the declared dependencies are not an array expression then we
623628
// can't verify that the user provided the correct dependencies. Tell
624629
// the user this in an error.
@@ -631,7 +636,11 @@ export default {
631636
'dependencies.',
632637
});
633638
} else {
634-
declaredDependenciesNode.elements.forEach(declaredDependencyNode => {
639+
const arrayExpression = isTSAsArrayExpression
640+
? declaredDependenciesNode.expression
641+
: declaredDependenciesNode;
642+
643+
arrayExpression.elements.forEach(declaredDependencyNode => {
635644
// Skip elided elements.
636645
if (declaredDependencyNode === null) {
637646
return;
@@ -1214,6 +1223,15 @@ export default {
12141223
isEffect,
12151224
);
12161225
return; // Handled
1226+
case 'TSAsExpression':
1227+
visitFunctionWithDependencies(
1228+
callback.expression,
1229+
declaredDependenciesNode,
1230+
reactiveHook,
1231+
reactiveHookName,
1232+
isEffect,
1233+
);
1234+
return; // Handled
12171235
case 'Identifier':
12181236
if (!declaredDependenciesNode) {
12191237
// No deps, no problems.

0 commit comments

Comments
 (0)