Skip to content

Commit 7cb3eb6

Browse files
authored
chore: split eslint ignore react-compiler directives (#44686)
## **Description** When an ESLint ignore directive raises a `react-compiler/react-compiler` error and it's ignored in the same line, ESlint v9 will incorrectly report it as an unused ignore directive. This has been worked around by moving the ESLint ignore directive for `react-compiler/react-compiler` to a separate line. This kinda makes more sense anyway, since the directive below it is what's causing the error. This helps unblock the ESLint v9 upgrade. ## **Changelog** CHANGELOG entry: null ## **Related issues** N/A ## **Manual testing steps** The CI lint step should be sufficient to test that this change has not broken anything. The ESLint v9 upgrade PR will be the final test of whether all such errors have been avoided. This has been tested to work on a working branch for the update, which you can see here for reference: https://github.com/MetaMask/metamask-extension/compare/main...update-eslint-v9?w=1 ## **Screenshots/Recordings** N/A ## **Pre-merge author checklist** - [x] I've followed [MetaMask Contributor Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Extension Coding Standards](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/CODING_GUIDELINES.md). - [x] I've completed the PR template to the best of my ability - [x] I’ve included tests if applicable - [x] I’ve documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [x] I’ve applied the right labels on the PR (see [labeling guidelines](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/LABELING_GUIDELINES.md)). Not required for external contributors. ## **Pre-merge reviewer checklist** - [ ] I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed). - [ ] I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots. <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Low Risk** > Comment-only ESLint directive formatting with no logic or dependency-array changes. > > **Overview** > Splits combined `eslint-disable-next-line` comments so **`react-compiler/react-compiler`** sits on its own line, with **`react-hooks/exhaustive-deps`** (or **`react-hooks/rules-of-hooks`**) on the line below. > > This avoids ESLint v9 treating the react-compiler suppression as an **unused ignore** when both rules were disabled on one line. **Runtime behavior is unchanged**—only comment formatting across UI components and hardware-wallet hooks. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 2aab092. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY -->
1 parent 14c8155 commit 7cb3eb6

8 files changed

Lines changed: 36 additions & 18 deletions

File tree

ui/components/app/api-error-handler/api-error-handler.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ const ApiErrorHandler = ({
3737
errorMessage: error?.message || 'Unknown error',
3838
location,
3939
});
40-
// eslint-disable-next-line react-compiler/react-compiler,react-hooks/exhaustive-deps -- we only want to capture the event once when the component is mounted
40+
// eslint-disable-next-line react-compiler/react-compiler
41+
// eslint-disable-next-line react-hooks/exhaustive-deps -- we only want to capture the event once when the component is mounted
4142
}, []);
4243

4344
return (

ui/components/app/currency-input/hooks/useProcessNewDecimalValue.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@ export default function useProcessNewDecimalValue(
5858

5959
return { newFiatDecimalValue, newTokenDecimalValue };
6060
},
61-
// eslint-disable-next-line react-compiler/react-compiler,react-hooks/exhaustive-deps -- `tokenToFiatConversionRate` intentionally excluded; re-renders only triggered when conversion rate value actually changes
61+
// eslint-disable-next-line react-compiler/react-compiler
62+
// eslint-disable-next-line react-hooks/exhaustive-deps -- `tokenToFiatConversionRate` intentionally excluded; re-renders only triggered when conversion rate value actually changes
6263
[tokenToFiatConversionRateToString, isTokenPrimary, assetDecimals],
6364
);
6465
}

ui/components/app/modals/qr-scanner/qr-scanner.component.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,8 @@ export default function QRCodeScanner({ hideModal, qrCodeDetected }) {
176176
(async () => {
177177
await checkEnvironment();
178178
})();
179-
// eslint-disable-next-line react-compiler/react-compiler,react-hooks/exhaustive-deps -- only runs on component mount and unmount
179+
// eslint-disable-next-line react-compiler/react-compiler
180+
// eslint-disable-next-line react-hooks/exhaustive-deps -- only runs on component mount and unmount
180181
}, []);
181182

182183
useEffect(() => {

ui/components/app/name/name.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,8 @@ const Name = memo(
9090
})
9191
.build(),
9292
);
93-
// eslint-disable-next-line react-compiler/react-compiler,react-hooks/exhaustive-deps -- only want to call `trackEvent` on the initial render
93+
// eslint-disable-next-line react-compiler/react-compiler
94+
// eslint-disable-next-line react-hooks/exhaustive-deps -- only want to call `trackEvent` on the initial render
9495
}, []);
9596

9697
const handleClick = useCallback(() => {

ui/contexts/hardware-wallets/useHardwareWalletConnection.ts

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ export const useHardwareWalletConnection = ({
4545
refs.adapterRef.current = null;
4646
}
4747
},
48-
// eslint-disable-next-line react-compiler/react-compiler, react-hooks/exhaustive-deps
48+
// eslint-disable-next-line react-compiler/react-compiler
49+
// eslint-disable-next-line react-hooks/exhaustive-deps
4950
[],
5051
);
5152

@@ -70,7 +71,8 @@ export const useHardwareWalletConnection = ({
7071

7172
return abortController.signal;
7273
},
73-
// eslint-disable-next-line react-compiler/react-compiler, react-hooks/exhaustive-deps
74+
// eslint-disable-next-line react-compiler/react-compiler
75+
// eslint-disable-next-line react-hooks/exhaustive-deps
7476
[],
7577
);
7678

@@ -140,7 +142,8 @@ export const useHardwareWalletConnection = ({
140142

141143
updateConnectionState(ConnectionState.connected());
142144
},
143-
// eslint-disable-next-line react-compiler/react-compiler, react-hooks/exhaustive-deps
145+
// eslint-disable-next-line react-compiler/react-compiler
146+
// eslint-disable-next-line react-hooks/exhaustive-deps
144147
[handleDeviceEvent, handleDisconnect, updateConnectionState],
145148
);
146149

@@ -176,7 +179,8 @@ export const useHardwareWalletConnection = ({
176179
}
177180
}
178181
},
179-
// eslint-disable-next-line react-compiler/react-compiler, react-hooks/exhaustive-deps
182+
// eslint-disable-next-line react-compiler/react-compiler
183+
// eslint-disable-next-line react-hooks/exhaustive-deps
180184
[updateConnectionState],
181185
);
182186

@@ -239,7 +243,8 @@ export const useHardwareWalletConnection = ({
239243

240244
return connectionPromise;
241245
},
242-
// eslint-disable-next-line react-compiler/react-compiler, react-hooks/exhaustive-deps
246+
// eslint-disable-next-line react-compiler/react-compiler
247+
// eslint-disable-next-line react-hooks/exhaustive-deps
243248
[
244249
beginConnectionAttempt,
245250
connectWithAdapter,
@@ -253,7 +258,8 @@ export const useHardwareWalletConnection = ({
253258
() => {
254259
refs.connectRef.current = connect;
255260
},
256-
// eslint-disable-next-line react-compiler/react-compiler, react-hooks/exhaustive-deps
261+
// eslint-disable-next-line react-compiler/react-compiler
262+
// eslint-disable-next-line react-hooks/exhaustive-deps
257263
[connect],
258264
);
259265

@@ -294,7 +300,8 @@ export const useHardwareWalletConnection = ({
294300
}
295301
}
296302
},
297-
// eslint-disable-next-line react-compiler/react-compiler, react-hooks/exhaustive-deps
303+
// eslint-disable-next-line react-compiler/react-compiler
304+
// eslint-disable-next-line react-hooks/exhaustive-deps
298305
[updateConnectionState],
299306
);
300307

@@ -310,7 +317,8 @@ export const useHardwareWalletConnection = ({
310317
updateConnectionState(ConnectionState.disconnected());
311318
}
312319
},
313-
// eslint-disable-next-line react-compiler/react-compiler, react-hooks/exhaustive-deps
320+
// eslint-disable-next-line react-compiler/react-compiler
321+
// eslint-disable-next-line react-hooks/exhaustive-deps
314322
[updateConnectionState],
315323
);
316324

@@ -423,7 +431,8 @@ export const useHardwareWalletConnection = ({
423431

424432
return ensurePromise;
425433
},
426-
// eslint-disable-next-line react-compiler/react-compiler, react-hooks/exhaustive-deps
434+
// eslint-disable-next-line react-compiler/react-compiler
435+
// eslint-disable-next-line react-hooks/exhaustive-deps
427436
[connect, updateConnectionState],
428437
);
429438

ui/contexts/hardware-wallets/useHardwareWalletPermissions.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,11 @@ export const useHardwareWalletPermissions = ({
6161
return () => {
6262
// We intentionally want the current ref values at cleanup time
6363
// to abort whatever is currently running
64-
// eslint-disable-next-line react-compiler/react-compiler, react-hooks/exhaustive-deps
64+
// eslint-disable-next-line react-compiler/react-compiler
65+
// eslint-disable-next-line react-hooks/exhaustive-deps
6566
checkAbortControllerRef.current?.abort();
66-
// eslint-disable-next-line react-compiler/react-compiler, react-hooks/exhaustive-deps
67+
// eslint-disable-next-line react-compiler/react-compiler
68+
// eslint-disable-next-line react-hooks/exhaustive-deps
6769
requestAbortControllerRef.current?.abort();
6870
};
6971
}, []);
@@ -99,7 +101,8 @@ export const useHardwareWalletPermissions = ({
99101

100102
return () => {
101103
// We intentionally want the current ref value at cleanup time
102-
// eslint-disable-next-line react-compiler/react-compiler, react-hooks/exhaustive-deps
104+
// eslint-disable-next-line react-compiler/react-compiler
105+
// eslint-disable-next-line react-hooks/exhaustive-deps
103106
checkAbortControllerRef.current?.abort();
104107
};
105108
// Adding eslint ignore to exclude ref from dependencies

ui/pages/confirmations/components/confirm/info/hooks/useNestedTransactionLabels.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ export function useNestedTransactionLabels({
1717
const { data, to } = nestedTransaction;
1818
// It's safe to call useFourByte here because the length of nestedTransactions
1919
// remains stable throughout the component's lifecycle.
20-
// eslint-disable-next-line react-compiler/react-compiler, react-hooks/rules-of-hooks
20+
// eslint-disable-next-line react-compiler/react-compiler
21+
// eslint-disable-next-line react-hooks/rules-of-hooks
2122
const methodData = useFourByte({ data, to });
2223
const functionName = methodData?.name;
2324

ui/pages/snap-account-transaction-loading-screen/snap-account-transaction-loading-screen.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ const SnapAccountTransactionLoadingScreen = ({
4141
})
4242
.build(),
4343
);
44-
// eslint-disable-next-line react-compiler/react-compiler,react-hooks/exhaustive-deps -- only track on initial render
44+
// eslint-disable-next-line react-compiler/react-compiler
45+
// eslint-disable-next-line react-hooks/exhaustive-deps -- only track on initial render
4546
}, []);
4647

4748
return <span>{t('loadingScreenSnapMessage')}</span>;

0 commit comments

Comments
 (0)