From 295917036bc893e5597e014a59cec565c18c535c Mon Sep 17 00:00:00 2001 From: Joel Jeremy Marquez Date: Tue, 9 Jan 2024 13:03:09 -0800 Subject: [PATCH] ESLint to enforce Actual's useNavigate hook (#2208) * ESLint to enforce Actual's useNavigate hook * Release notes --------- Co-authored-by: Matiss Janis Aboltins --- .eslintrc.js | 20 +++++++++++++++++++ .../src/components/FinancesApp.tsx | 2 +- upcoming-release-notes/2208.md | 6 ++++++ 3 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 upcoming-release-notes/2208.md diff --git a/.eslintrc.js b/.eslintrc.js index 9a4412f665e..64ff7f047c9 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -201,6 +201,26 @@ module.exports = { ], }, }, + { + files: ['./packages/desktop-client/**/*'], + excludedFiles: [ + './packages/desktop-client/src/hooks/useNavigate.{ts,tsx}', + ], + rules: { + 'no-restricted-imports': [ + 'warn', + { + patterns: [ + { + group: ['react-router-dom'], + importNames: ['useNavigate'], + message: 'Please use Actual’s useNavigate() hook instead.', + }, + ], + }, + ], + }, + }, { files: ['./packages/loot-core/src/**/*'], rules: { diff --git a/packages/desktop-client/src/components/FinancesApp.tsx b/packages/desktop-client/src/components/FinancesApp.tsx index 823cfd7e7b3..60ca0d8fbe5 100644 --- a/packages/desktop-client/src/components/FinancesApp.tsx +++ b/packages/desktop-client/src/components/FinancesApp.tsx @@ -5,7 +5,6 @@ import { Route, Routes, Navigate, - useNavigate, BrowserRouter, useLocation, useHref, @@ -20,6 +19,7 @@ import { checkForUpdateNotification } from 'loot-core/src/client/update-notifica import * as undo from 'loot-core/src/platform/client/undo'; import { useActions } from '../hooks/useActions'; +import { useNavigate } from '../hooks/useNavigate'; import { useResponsive } from '../ResponsiveProvider'; import { theme } from '../style'; import { ExposeNavigate } from '../util/router-tools'; diff --git a/upcoming-release-notes/2208.md b/upcoming-release-notes/2208.md new file mode 100644 index 00000000000..f34ec8acf62 --- /dev/null +++ b/upcoming-release-notes/2208.md @@ -0,0 +1,6 @@ +--- +category: Maintenance +authors: [joel-jeremy] +--- + +ESLint to enforce Actual's useNavigate hook