Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enable react-hooks lint rules #11511

Merged
merged 24 commits into from
Jun 12, 2024
Merged
Changes from 1 commit
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
2d5f02f
enable `react-hooks` lint rules
phryneas Jan 22, 2024
913ea1f
Merge remote-tracking branch 'origin/main' into pr/lint-hooks
phryneas May 16, 2024
9e786aa
Clean up Prettier, Size-limit, and Api-Extractor
phryneas May 16, 2024
d757781
update eslint rule
phryneas May 16, 2024
0e5e3cb
different type casting to not break lint rule parsing
phryneas May 16, 2024
6ad1b0e
fix up useMutation + lifecycle test
phryneas May 16, 2024
172f26c
Clean up Prettier, Size-limit, and Api-Extractor
phryneas May 16, 2024
c5a5d28
avoid reading/writing ref in render
phryneas May 16, 2024
6070945
fix up useLazyQuery
phryneas May 16, 2024
9c78b5c
Clean up Prettier, Size-limit, and Api-Extractor
phryneas May 16, 2024
8a33815
fix up another test doing a mutation in render
phryneas May 17, 2024
1aeb9ff
more useQuery cleanup
phryneas May 17, 2024
c34a48c
Clean up Prettier, Size-limit, and Api-Extractor
phryneas May 17, 2024
34ef7d8
ignore rule of hook for context access
phryneas May 17, 2024
c5bb497
undo changes that were moved into separate PRs
phryneas May 17, 2024
8cdba15
Clean up Prettier, Size-limit, and Api-Extractor
phryneas May 17, 2024
2e751e1
almost full rewrite of the `useSubscription` hook
phryneas May 17, 2024
d70b45e
Clean up Prettier, Size-limit, and Api-Extractor
phryneas May 17, 2024
0c813a1
ignore any rule violation lint warnings in useSubscription and useQuery
phryneas May 22, 2024
e9c247b
changeset
phryneas May 22, 2024
619b188
rename patch
phryneas May 22, 2024
7743e0b
Merge remote-tracking branch 'origin/main' into pr/lint-hooks
phryneas May 27, 2024
694452f
also add "eslint-plugin-react-compiler" rules
phryneas May 27, 2024
9eaa883
Merge branch 'main' into pr/lint-hooks
phryneas Jun 12, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
different type casting to not break lint rule parsing
  • Loading branch information
phryneas committed May 16, 2024
commit 0e5e3cb5681d2cf7d0dc2076cf56db6923f45eb0
18 changes: 7 additions & 11 deletions src/react/hooks/useSuspenseQuery.ts
Original file line number Diff line number Diff line change
@@ -251,22 +251,18 @@ function _useSuspenseQuery<
}, [queryRef.result]);

const result = fetchPolicy === "standby" ? skipResult : __use(promise);
// eslint incorrectly reports
// React Hook useCallback received a function whose dependencies are unknown. Pass an inline function instead.
// seems to be a parsing error because of the `satisfies as`
// eslint-disable-next-line react-hooks/exhaustive-deps
const fetchMore = React.useCallback(
((options) => {

const fetchMore = React.useCallback<
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The lint rule had massive problems parsing the satisfies ... as pattern, but this works.

FetchMoreFunction<unknown, OperationVariables>
>(
(options) => {
const promise = queryRef.fetchMore(options);
setPromise([queryRef.key, queryRef.promise]);

return promise;
}) satisfies FetchMoreFunction<
unknown,
OperationVariables
> as FetchMoreFunction<TData | undefined, TVariables>,
},
[queryRef]
);
) as FetchMoreFunction<TData | undefined, TVariables>;

const refetch: RefetchFunction<TData, TVariables> = React.useCallback(
(variables) => {