Skip to content

A local-first personal finance app

Add back eslint useDispatch and useSelector rules (#4123)

Joel Jeremy Marquez6bcccaa94349
diff --git a/eslint.config.mjs b/eslint.config.mjs
index ec4ccb3a36..202b3986d5 100644
--- a/eslint.config.mjs
+++ b/eslint.config.mjs
@@ -628,11 +628,38 @@ export default [
'no-restricted-imports': [
'warn',
{
- patterns: [
+ paths: [
{
- group: ['react-router-dom'],
+ name: 'react-router-dom',
importNames: ['useNavigate'],
- message: "Please use Actual's useNavigate() hook instead.",
+ message:
+ "Please import Actual's useNavigate() hook from `src/hooks` instead.",
+ },
+ ],
+ },
+ ],
+ },
+ },
+ {
+ files: ['packages/desktop-client/**/*', 'packages/loot-core/**/*'],
+ ignores: ['packages/desktop-client/src/redux/index.{ts,tsx}'],
+
+ rules: {
+ 'no-restricted-imports': [
+ 'warn',
+ {
+ paths: [
+ {
+ name: 'react-redux',
+ importNames: ['useDispatch'],
+ message:
+ "Please import Actual's useDispatch() hook from `src/redux` instead.",
+ },
+ {
+ name: 'react-redux',
+ importNames: ['useSelector'],
+ message:
+ "Please import Actual's useSelector() hook from `src/redux` instead.",
},
],
},
diff --git a/packages/desktop-client/src/components/admin/UserAccess/UserAccess.tsx b/packages/desktop-client/src/components/admin/UserAccess/UserAccess.tsx
index 61c89c97a1..736daad12e 100644
--- a/packages/desktop-client/src/components/admin/UserAccess/UserAccess.tsx
+++ b/packages/desktop-client/src/components/admin/UserAccess/UserAccess.tsx
@@ -9,7 +9,6 @@ import React, {
type CSSProperties,
} from 'react';
import { Trans, useTranslation } from 'react-i18next';
-import { useDispatch } from 'react-redux';
import { addNotification, pushModal } from 'loot-core/client/actions';
import { send } from 'loot-core/src/platform/client/fetch';
@@ -21,6 +20,7 @@ import { type UserAccessEntity } from 'loot-core/types/models/userAccess';
import { useMetadataPref } from '../../../hooks/useMetadataPref';
import { SvgLockOpen } from '../../../icons/v1';
import { SvgLockClosed } from '../../../icons/v2';
+import { useDispatch } from '../../../redux';
import { theme } from '../../../style';
import { Button } from '../../common/Button2';
import { Link } from '../../common/Link';
diff --git a/packages/desktop-client/src/components/admin/UserDirectory/UserDirectory.tsx b/packages/desktop-client/src/components/admin/UserDirectory/UserDirectory.tsx
index 711b7baebf..f1464abe25 100644
--- a/packages/desktop-client/src/components/admin/UserDirectory/UserDirectory.tsx
+++ b/packages/desktop-client/src/components/admin/UserDirectory/UserDirectory.tsx
@@ -9,7 +9,6 @@ import {
type CSSProperties,
} from 'react';
import { Trans, useTranslation } from 'react-i18next';
-import { useDispatch } from 'react-redux';
import { pushModal } from 'loot-core/src/client/actions/modals';
import { send } from 'loot-core/src/platform/client/fetch';
@@ -21,6 +20,7 @@ import {
import { useActions } from '../../../hooks/useActions';
import { SelectedProvider, useSelected } from '../../../hooks/useSelected';
+import { useDispatch } from '../../../redux';
import { theme } from '../../../style';
import { Button } from '../../common/Button2';
import { Link } from '../../common/Link';
diff --git a/upcoming-release-notes/4123.md b/upcoming-release-notes/4123.md
new file mode 100644
index 0000000000..71dbc64dd0
--- /dev/null
+++ b/upcoming-release-notes/4123.md
@@ -0,0 +1,6 @@
+---
+category: Maintenance
+authors: [joel-jeremy]
+---
+
+Add eslint rule for useDispatch and useSelector
\ No newline at end of file