Memos is an open-source, self-hosted note-taking app that brings your everyday thoughts together in a personal timeline. Your data stays yours, and you choose what to keep private or share.
Go dockerfossgomarkdownmemomicroblognote-takingnotesopen-sourceown-your-datareactself-hostedsqlitetimeline
chore: disallow destructuring 't' from useTranslation (#1973)
Ajay Kumbhare4ac63ba1f082
diff --git a/web/.eslintrc.json b/web/.eslintrc.jsonindex 8f59145e6..209b39ad0 100644--- a/web/.eslintrc.json+++ b/web/.eslintrc.json@@ -25,11 +25,26 @@"@typescript-eslint/no-unused-vars": "error","@typescript-eslint/no-explicit-any": ["off"],"react/react-in-jsx-scope": "off",- "react/jsx-no-target-blank": "off"+ "react/jsx-no-target-blank": "off",+ "no-restricted-syntax": [+ "error",+ {+ "selector": "VariableDeclarator[init.callee.name='useTranslation'] > ObjectPattern > Property[key.name='t']:not([parent.declarations.0.init.callee.object.name='i18n'])",+ "message": "Destructuring 't' from useTranslation is not allowed. Please use the 'useTranslate' hook from '@/utils/i18n'."+ }+ ]},"settings": {"react": {"version": "detect"}- }+ },+ "overrides": [+ {+ "files": ["src/utils/i18n.ts"],+ "rules": {+ "no-restricted-syntax": "off"+ }+ }+ ]}diff --git a/web/src/components/MemoChat/ChatInput.tsx b/web/src/components/MemoChat/ChatInput.tsxindex b33c518a9..cbb97f74d 100644--- a/web/src/components/MemoChat/ChatInput.tsx+++ b/web/src/components/MemoChat/ChatInput.tsx@@ -1,6 +1,6 @@import Icon from "@/components/Icon";import Textarea from "@mui/joy/Textarea/Textarea";-import { useTranslation } from "react-i18next";+import { useTranslate } from "@/utils/i18n";interface Props {question: string;@@ -11,7 +11,7 @@ interface Props {}const ChatInput = ({ question, handleQuestionTextareaChange, setIsInIME, handleKeyDown, handleSendQuestionButtonClick }: Props) => {- const { t } = useTranslation();+ const t = useTranslate();return (<div className="w-full relative mt-4">diff --git a/web/src/components/MemoEditor/MemoEditorDialog.tsx b/web/src/components/MemoEditor/MemoEditorDialog.tsxindex eec3e8ff5..c2a51672a 100644--- a/web/src/components/MemoEditor/MemoEditorDialog.tsx+++ b/web/src/components/MemoEditor/MemoEditorDialog.tsx@@ -1,7 +1,7 @@import { generateDialog } from "../Dialog";import Icon from "../Icon";import MemoEditor from ".";-import { useTranslation } from "react-i18next";+import { useTranslate } from "@/utils/i18n";interface Props extends DialogProps {memoId?: MemoId;@@ -12,7 +12,7 @@ const MemoEditorDialog: React.FC<Props> = ({ memoId, relationList, destroy }: Prconst handleCloseBtnClick = () => {destroy();};- const { t } = useTranslation();+ const t = useTranslate();return (<>diff --git a/web/src/pages/MemoChat.tsx b/web/src/pages/MemoChat.tsxindex f25378ed0..dab59aef4 100644--- a/web/src/pages/MemoChat.tsx+++ b/web/src/pages/MemoChat.tsx@@ -2,7 +2,7 @@ import { Button, Stack } from "@mui/joy";import { head } from "lodash-es";import React, { useEffect, useState } from "react";import { toast } from "react-hot-toast";-import { useTranslation } from "react-i18next";+import { useTranslate } from "@/utils/i18n";import * as api from "@/helpers/api";import useLoading from "@/hooks/useLoading";import { useMessageStore } from "@/store/zustand/message";@@ -16,7 +16,7 @@ import ConversationTab from "@/components/MemoChat/ConversationTab";import Empty from "@/components/Empty";const MemoChat = () => {- const { t } = useTranslation();+ const t = useTranslate();const fetchingState = useLoading(false);const [isEnabled, setIsEnabled] = useState<boolean>(true);const [isInIME, setIsInIME] = useState(false);@@ -174,7 +174,7 @@ const MemoChat = () => {)}{!isEnabled && (<div className="w-full flex flex-col justify-center items-center mt-4 space-y-2">- <p>{t("memo-chat.not_enabled")}</p>+ <p>{t("memo-chat.not-enabled")}</p><Button onClick={() => handleGotoSystemSetting()}>{t("memo-chat.go-to-settings")}</Button></div>)}