Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
canifa_note
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Vũ Hoàng Anh
canifa_note
Commits
4ac63ba1
Unverified
Commit
4ac63ba1
authored
Jul 16, 2023
by
Ajay Kumbhare
Committed by
GitHub
Jul 16, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
chore: disallow destructuring 't' from useTranslation (#1973)
parent
589b1046
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
24 additions
and
9 deletions
+24
-9
.eslintrc.json
web/.eslintrc.json
+17
-2
ChatInput.tsx
web/src/components/MemoChat/ChatInput.tsx
+2
-2
MemoEditorDialog.tsx
web/src/components/MemoEditor/MemoEditorDialog.tsx
+2
-2
MemoChat.tsx
web/src/pages/MemoChat.tsx
+3
-3
No files found.
web/.eslintrc.json
View file @
4ac63ba1
...
...
@@ -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"
}
}
]
}
web/src/components/MemoChat/ChatInput.tsx
View file @
4ac63ba1
import
Icon
from
"@/components/Icon"
;
import
Textarea
from
"@mui/joy/Textarea/Textarea"
;
import
{
useTranslat
ion
}
from
"react-i18next
"
;
import
{
useTranslat
e
}
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"
>
...
...
web/src/components/MemoEditor/MemoEditorDialog.tsx
View file @
4ac63ba1
import
{
generateDialog
}
from
"../Dialog"
;
import
Icon
from
"../Icon"
;
import
MemoEditor
from
"."
;
import
{
useTranslat
ion
}
from
"react-i18next
"
;
import
{
useTranslat
e
}
from
"@/utils/i18n
"
;
interface
Props
extends
DialogProps
{
memoId
?:
MemoId
;
...
...
@@ -12,7 +12,7 @@ const MemoEditorDialog: React.FC<Props> = ({ memoId, relationList, destroy }: Pr
const
handleCloseBtnClick
=
()
=>
{
destroy
();
};
const
{
t
}
=
useTranslation
();
const
t
=
useTranslate
();
return
(
<>
...
...
web/src/pages/MemoChat.tsx
View file @
4ac63ba1
...
...
@@ -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
{
useTranslat
ion
}
from
"react-i18next
"
;
import
{
useTranslat
e
}
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
>
)
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment