From 333d7c5961cdcb3ed04043cc6bccd7e030579f33 Mon Sep 17 00:00:00 2001 From: Untone Date: Sun, 4 Feb 2024 20:40:15 +0300 Subject: [PATCH] no-actions-context-value --- biome.json | 1 + gen/context/new/context.ejs.t | 5 +- src/components/Article/Comment/Comment.tsx | 17 ++---- .../Article/CommentRatingControl.tsx | 13 ++-- src/components/Article/CommentsTree.tsx | 6 +- src/components/Article/FullArticle.tsx | 22 ++----- src/components/Article/ShoutRatingControl.tsx | 12 +--- .../Author/AuthorBadge/AuthorBadge.tsx | 8 +-- .../Author/AuthorCard/AuthorCard.tsx | 13 ++-- .../Author/AuthorLink/AuthorLink.tsx | 2 +- src/components/Discours/Donate.tsx | 4 +- src/components/Draft/Draft.tsx | 9 +-- src/components/Editor/Editor.tsx | 9 +-- src/components/Editor/Panel/Panel.tsx | 14 +---- src/components/Editor/SimplifiedEditor.tsx | 4 +- .../Editor/TextBubbleMenu/TextBubbleMenu.tsx | 2 +- .../Editor/VideoUploader/VideoUploader.tsx | 4 +- .../Feed/ArticleCard/ArticleCard.tsx | 59 +++++++++---------- .../Nav/AuthModal/ChangePasswordForm.tsx | 4 +- .../Nav/AuthModal/ForgotPasswordForm.tsx | 4 +- src/components/Nav/AuthModal/LoginForm.tsx | 34 ++++------- src/components/Nav/AuthModal/RegisterForm.tsx | 8 +-- .../Nav/AuthModal/SocialProviders.tsx | 4 +- src/components/Nav/AuthModal/index.tsx | 1 - .../Nav/ConfirmModal/ConfirmModal.tsx | 6 +- src/components/Nav/Header/Header.tsx | 12 +--- src/components/Nav/HeaderAuth.tsx | 11 +--- src/components/Nav/ProfilePopup.tsx | 6 +- .../NotificationView/NotificationGroup.tsx | 4 +- .../NotificationsPanel/NotificationsPanel.tsx | 4 +- .../ProfileSettings/ProfileSettings.tsx | 20 ++----- src/components/Topic/Card.tsx | 14 ++--- src/components/Topic/Full.tsx | 4 +- .../Topic/TopicBadge/TopicBadge.tsx | 4 +- src/components/Views/AllAuthors.tsx | 36 ++--------- .../Views/DraftsView/DraftsView.tsx | 4 +- src/components/Views/Edit.tsx | 11 ++-- src/components/Views/Feed/Feed.tsx | 7 +-- src/components/Views/Inbox/Inbox.tsx | 8 +-- .../Views/PublishSettings/PublishSettings.tsx | 5 +- .../_shared/DarkModeToggle/DarkModeToggle.tsx | 2 +- .../_shared/InviteMembers/InviteMembers.tsx | 5 +- .../_shared/ShareLinks/ShareLinks.tsx | 5 +- .../_shared/SolidSwiper/EditorSwiper.tsx | 4 +- .../_shared/Subscribe/Subscribe.tsx | 4 +- src/context/confirm.tsx | 20 +++---- src/context/editor.tsx | 32 +++++----- src/context/inbox.tsx | 16 +++-- src/context/notifications.tsx | 16 +++-- src/context/profile.tsx | 16 ++--- src/context/reactions.tsx | 28 ++++----- src/context/session.tsx | 46 +++++++-------- src/context/snackbar.tsx | 18 ++---- src/pages/article.page.tsx | 2 +- src/utils/cyrillic.ts | 5 -- src/utils/getImageUrl.ts | 2 +- src/utils/translate.ts | 39 ++++++++++++ 57 files changed, 250 insertions(+), 425 deletions(-) delete mode 100644 src/utils/cyrillic.ts create mode 100644 src/utils/translate.ts diff --git a/biome.json b/biome.json index f80f4438..7df32a8d 100644 --- a/biome.json +++ b/biome.json @@ -34,6 +34,7 @@ "rules": { "recommended": true, "complexity": { + "all": true, "noForEach": "off", "useOptionalChain": "warn", "useLiteralKeys": "off" diff --git a/gen/context/new/context.ejs.t b/gen/context/new/context.ejs.t index e374020e..ca1de791 100644 --- a/gen/context/new/context.ejs.t +++ b/gen/context/new/context.ejs.t @@ -5,8 +5,7 @@ import type { Accessor, JSX } from 'solid-js' import { createContext, createSignal, useContext } from 'solid-js' type <%= h.changeCase.pascal(name) %>ContextType = { - actions: { - } + } const <%= h.changeCase.pascal(name) %>Context = createContext<<%= h.changeCase.pascal(name) %>ContextType>() @@ -19,7 +18,7 @@ export const <%= h.changeCase.pascal(name) %>Provider = (props: { children: JSX. const actions = { } - const value: <%= h.changeCase.pascal(name) %>ContextType = { actions } + const value: <%= h.changeCase.pascal(name) %>ContextType = { ...actions } return <<%= h.changeCase.pascal(name) %>Context.Provider value={value}>{props.children}Context.Provider> } diff --git a/src/components/Article/Comment/Comment.tsx b/src/components/Article/Comment/Comment.tsx index 17c19c48..d6af579f 100644 --- a/src/components/Article/Comment/Comment.tsx +++ b/src/components/Article/Comment/Comment.tsx @@ -39,23 +39,14 @@ export const Comment = (props: Props) => { const [editMode, setEditMode] = createSignal(false) const [clearEditor, setClearEditor] = createSignal(false) const { author } = useSession() - - const { - actions: { createReaction, deleteReaction, updateReaction }, - } = useReactions() - - const { - actions: { showConfirm }, - } = useConfirm() - - const { - actions: { showSnackbar }, - } = useSnackbar() + const { createReaction, deleteReaction, updateReaction } = useReactions() + const { showConfirm } = useConfirm() + const { showSnackbar } = useSnackbar() const isCommentAuthor = createMemo(() => props.comment.created_by?.slug === author()?.slug) - const comment = createMemo(() => props.comment) const body = createMemo(() => (comment().body || '').trim()) + const remove = async () => { if (comment()?.id) { try { diff --git a/src/components/Article/CommentRatingControl.tsx b/src/components/Article/CommentRatingControl.tsx index 4fb906c1..5ce60d08 100644 --- a/src/components/Article/CommentRatingControl.tsx +++ b/src/components/Article/CommentRatingControl.tsx @@ -19,13 +19,8 @@ type Props = { export const CommentRatingControl = (props: Props) => { const { t } = useLocalize() const { author } = useSession() - const { - actions: { showSnackbar }, - } = useSnackbar() - const { - reactionEntities, - actions: { createReaction, deleteReaction, loadReactionsBy }, - } = useReactions() + const { showSnackbar } = useSnackbar() + const { reactionEntities, createReaction, deleteReaction, loadReactionsBy } = useReactions() const checkReaction = (reactionKind: ReactionKind) => Object.values(reactionEntities).some( @@ -86,7 +81,7 @@ export const CommentRatingControl = (props: Props) => {