Skip to content

Commit 048148e

Browse files
renovate[bot]Ole Martin Handeland
andauthored
chore(deps): update dependency eslint-plugin-react-hooks to v6 (#3774)
* chore(deps): update dependency eslint-plugin-react-hooks to v6 * Getting rid of this undefined class reference * Migrating to new flat/recommended * Renaming our own polyfill useEffectEvent(), since the official one is arriving in React 19.2 and now has eslint rules that break for us --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Ole Martin Handeland <[email protected]>
1 parent ceeba32 commit 048148e

File tree

10 files changed

+41
-20
lines changed

10 files changed

+41
-20
lines changed

eslint.config.mjs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import noRelativeImportPaths from 'eslint-plugin-no-relative-import-paths';
66
import preferredImportPath from 'eslint-plugin-preferred-import-path';
77
import reactPlugin from 'eslint-plugin-react';
88
import reactCompiler from 'eslint-plugin-react-compiler';
9+
import reactHooks from 'eslint-plugin-react-hooks';
910
import simpleImportSort from 'eslint-plugin-simple-import-sort';
1011
import sonarjs from 'eslint-plugin-sonarjs';
1112
import testingLibrary from 'eslint-plugin-testing-library';
@@ -37,10 +38,10 @@ export default tseslint.config(
3738
'plugin:import/typescript',
3839
'plugin:jsx-a11y/recommended',
3940
'plugin:react/recommended',
40-
'plugin:react-hooks/recommended',
4141
'plugin:prettier/recommended',
4242
),
4343
),
44+
reactHooks.configs['flat/recommended'],
4445
{
4546
ignores: [
4647
'**/node_modules',

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@
9292
"eslint-plugin-prettier": "5.5.4",
9393
"eslint-plugin-react": "7.37.5",
9494
"eslint-plugin-react-compiler": "19.1.0-rc.2",
95-
"eslint-plugin-react-hooks": "5.2.0",
95+
"eslint-plugin-react-hooks": "6.1.1",
9696
"eslint-plugin-simple-import-sort": "12.1.1",
9797
"eslint-plugin-sonarjs": "3.0.5",
9898
"eslint-plugin-testing-library": "7.11.0",

src/features/payment/PaymentProvider.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ import { PaymentStatus } from 'src/features/payment/types';
1010
import { usePerformPayActionMutation } from 'src/features/payment/usePerformPaymentMutation';
1111
import { useIsPayment } from 'src/features/payment/utils';
1212
import { useNavigationParam } from 'src/hooks/navigation';
13-
import { useEffectEvent } from 'src/hooks/useEffectEvent';
1413
import { useIsPdf } from 'src/hooks/useIsPdf';
14+
import { useOurEffectEvent } from 'src/hooks/useOurEffectEvent';
1515
import { useShallowMemo } from 'src/hooks/useShallowMemo';
1616

1717
type PaymentContextProps = {
@@ -38,8 +38,8 @@ export const PaymentProvider: React.FC<PaymentContextProvider> = ({ children })
3838

3939
const isLoading = isPaymentPending || isConfirmPending;
4040

41-
const performPayment = useEffectEvent(() => mutateAsync());
42-
const skipPayment = useEffectEvent(() => processConfirm());
41+
const performPayment = useOurEffectEvent(() => mutateAsync());
42+
const skipPayment = useOurEffectEvent(() => processConfirm());
4343

4444
const contextValue = useShallowMemo({ performPayment, skipPayment, paymentError });
4545

src/features/validation/callbacks/onFormSubmitValidation.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { ValidationMask } from '..';
44

55
import { ContextNotProvided } from 'src/core/contexts/context';
66
import { Validation } from 'src/features/validation/validationContext';
7-
import { useEffectEvent } from 'src/hooks/useEffectEvent';
7+
import { useOurEffectEvent } from 'src/hooks/useOurEffectEvent';
88
import { NodesInternal } from 'src/utils/layout/NodesContext';
99

1010
/**
@@ -20,7 +20,7 @@ export function useOnFormSubmitValidation() {
2020
const setNodeVisibility = NodesInternal.useLaxSetNodeVisibility();
2121
const getNodesWithErrors = NodesInternal.useGetNodesWithErrors();
2222

23-
const callback = useEffectEvent((includeNonIncrementalValidations: boolean): boolean => {
23+
const callback = useOurEffectEvent((includeNonIncrementalValidations: boolean): boolean => {
2424
if (validation.current === ContextNotProvided || setNodeVisibility === ContextNotProvided) {
2525
// If the validation context or nodes context is not provided, we cannot validate
2626
return false;

src/features/validation/callbacks/onGroupCloseValidation.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { useLayoutLookups } from 'src/features/form/layout/LayoutsContext';
22
import { getVisibilityMask } from 'src/features/validation/utils';
33
import { Validation } from 'src/features/validation/validationContext';
44
import { getRecursiveValidations, makeComponentIdIndex } from 'src/features/validation/ValidationStorePlugin';
5-
import { useEffectEvent } from 'src/hooks/useEffectEvent';
5+
import { useOurEffectEvent } from 'src/hooks/useOurEffectEvent';
66
import { useComponentIdMutator } from 'src/utils/layout/DataModelLocation';
77
import { NodesInternal } from 'src/utils/layout/NodesContext';
88
import type { NodeRefValidation } from 'src/features/validation';
@@ -20,7 +20,7 @@ export function useOnGroupCloseValidation() {
2020
const idMutator = useComponentIdMutator(true);
2121

2222
/* Ensures the callback will have the latest state */
23-
const callback = useEffectEvent(
23+
const callback = useOurEffectEvent(
2424
(baseComponentId: string, restriction: number | undefined, masks: AllowedValidationMasks): boolean => {
2525
const mask = getVisibilityMask(masks);
2626
const state = nodeStore.getState();

src/features/validation/callbacks/onPageNavigationValidation.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ import { useCallback } from 'react';
33
import { useRefetchInitialValidations } from 'src/features/validation/backendValidation/backendValidationQuery';
44
import { getVisibilityMask } from 'src/features/validation/utils';
55
import { Validation } from 'src/features/validation/validationContext';
6-
import { useEffectEvent } from 'src/hooks/useEffectEvent';
76
import { usePageOrder } from 'src/hooks/useNavigatePage';
7+
import { useOurEffectEvent } from 'src/hooks/useOurEffectEvent';
88
import { NodesInternal } from 'src/utils/layout/NodesContext';
99
import type { PageValidation } from 'src/layout/common.generated';
1010

@@ -22,7 +22,7 @@ export function useOnPageNavigationValidation() {
2222
const refetchInitialValidations = useRefetchInitialValidations();
2323

2424
/* Ensures the callback will have the latest state */
25-
const callback = useEffectEvent(async (currentPage: string, config: PageValidation): Promise<boolean> => {
25+
const callback = useOurEffectEvent(async (currentPage: string, config: PageValidation): Promise<boolean> => {
2626
const pageConfig = config.page ?? 'current';
2727
const masks = config.show;
2828
const mask = getVisibilityMask(masks);

src/hooks/useEffectEvent.ts renamed to src/hooks/useOurEffectEvent.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { useCallback, useInsertionEffect, useRef } from 'react';
66
* @see https://react.dev/learn/separating-events-from-effects#declaring-an-effect-event
77
*/
88
// eslint-disable-next-line @typescript-eslint/no-explicit-any
9-
export function useEffectEvent<T extends (...args: any[]) => any>(event: T) {
9+
export function useOurEffectEvent<T extends (...args: any[]) => any>(event: T) {
1010
const ref = useRef(event);
1111
useInsertionEffect(() => {
1212
ref.current = event;

src/layout/Address/AddressComponent.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import { useBindingValidationsFor } from 'src/features/validation/selectors/bind
1515
import { useComponentValidationsFor } from 'src/features/validation/selectors/componentValidationsForNode';
1616
import { hasValidationErrors } from 'src/features/validation/utils';
1717
import { usePostPlaceQuery } from 'src/hooks/queries/usePostPlaceQuery';
18-
import { useEffectEvent } from 'src/hooks/useEffectEvent';
18+
import { useOurEffectEvent } from 'src/hooks/useOurEffectEvent';
1919
import classes from 'src/layout/Address/AddressComponent.module.css';
2020
import { useItemWhenType } from 'src/utils/layout/useNodeItem';
2121
import type { PropsFromGenericComponent } from 'src/layout';
@@ -48,7 +48,7 @@ export function AddressComponent({ baseComponentId }: PropsFromGenericComponent<
4848
const debounce = FD.useDebounceImmediately();
4949
const { address, careOf, postPlace, zipCode, houseNumber } = formData;
5050

51-
const updatePostPlace = useEffectEvent((newPostPlace) => {
51+
const updatePostPlace = useOurEffectEvent((newPostPlace) => {
5252
if (newPostPlace != null && newPostPlace != postPlace) {
5353
setValue('postPlace', newPostPlace);
5454
}

src/layout/List/ListComponent.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,6 @@ export const ListComponent = ({ baseComponentId }: PropsFromGenericComponent<'Li
298298
<Table.Row
299299
key={JSON.stringify(row)}
300300
onClick={!readOnly ? () => handleRowClick(row) : undefined}
301-
className={cn({ [classes.readOnlyRow]: readOnly })}
302301
>
303302
{!readOnly && (
304303
<Table.Cell

yarn.lock

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5649,7 +5649,7 @@ __metadata:
56495649
eslint-plugin-prettier: "npm:5.5.4"
56505650
eslint-plugin-react: "npm:7.37.5"
56515651
eslint-plugin-react-compiler: "npm:19.1.0-rc.2"
5652-
eslint-plugin-react-hooks: "npm:5.2.0"
5652+
eslint-plugin-react-hooks: "npm:6.1.1"
56535653
eslint-plugin-simple-import-sort: "npm:12.1.1"
56545654
eslint-plugin-sonarjs: "npm:3.0.5"
56555655
eslint-plugin-testing-library: "npm:7.11.0"
@@ -9057,12 +9057,17 @@ __metadata:
90579057
languageName: node
90589058
linkType: hard
90599059

9060-
"eslint-plugin-react-hooks@npm:5.2.0":
9061-
version: 5.2.0
9062-
resolution: "eslint-plugin-react-hooks@npm:5.2.0"
9060+
"eslint-plugin-react-hooks@npm:6.1.1":
9061+
version: 6.1.1
9062+
resolution: "eslint-plugin-react-hooks@npm:6.1.1"
9063+
dependencies:
9064+
"@babel/core": "npm:^7.24.4"
9065+
"@babel/parser": "npm:^7.24.4"
9066+
zod: "npm:^3.22.4 || ^4.0.0"
9067+
zod-validation-error: "npm:^3.0.3 || ^4.0.0"
90639068
peerDependencies:
90649069
eslint: ^3.0.0 || ^4.0.0 || ^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0-0 || ^9.0.0
9065-
checksum: 10c0/1c8d50fa5984c6dea32470651807d2922cc3934cf3425e78f84a24c2dfd972e7f019bee84aefb27e0cf2c13fea0ac1d4473267727408feeb1c56333ca1489385
9070+
checksum: 10c0/579be053bc89c995a6c03996f9ee3f6bac88946b4b1c8b891b42f981e7c05a9c5de46324bbd2a33199855c0a602820c0e3eeb7f840730301b77a9ba3dc7a0ae2
90669071
languageName: node
90679072
linkType: hard
90689073

@@ -18696,6 +18701,15 @@ __metadata:
1869618701
languageName: node
1869718702
linkType: hard
1869818703

18704+
"zod-validation-error@npm:^3.0.3 || ^4.0.0":
18705+
version: 4.0.2
18706+
resolution: "zod-validation-error@npm:4.0.2"
18707+
peerDependencies:
18708+
zod: ^3.25.0 || ^4.0.0
18709+
checksum: 10c0/0ccfec48c46de1be440b719cd02044d4abb89ed0e14c13e637cd55bf29102f67ccdba373f25def0fc7130e5f15025be4d557a7edcc95d5a3811599aade689e1b
18710+
languageName: node
18711+
linkType: hard
18712+
1869918713
"zod@npm:4.1.11":
1870018714
version: 4.1.11
1870118715
resolution: "zod@npm:4.1.11"
@@ -18710,6 +18724,13 @@ __metadata:
1871018724
languageName: node
1871118725
linkType: hard
1871218726

18727+
"zod@npm:^3.22.4 || ^4.0.0":
18728+
version: 4.1.12
18729+
resolution: "zod@npm:4.1.12"
18730+
checksum: 10c0/b64c1feb19e99d77075261eaf613e0b2be4dfcd3551eff65ad8b4f2a079b61e379854d066f7d447491fcf193f45babd8095551a9d47973d30b46b6d8e2c46774
18731+
languageName: node
18732+
linkType: hard
18733+
1871318734
"zustand@npm:5.0.8":
1871418735
version: 5.0.8
1871518736
resolution: "zustand@npm:5.0.8"

0 commit comments

Comments
 (0)