From 775ca9261c997de347a63acfb16ce0599b68814c Mon Sep 17 00:00:00 2001 From: Joe Anderson Date: Fri, 22 Dec 2023 14:37:38 +0000 Subject: [PATCH] Linter fixes --- .../default/plate-ui/table-dropdown-menu.tsx | 2 +- .../default/plate-ui/table-element.tsx | 2 +- .../src/stores/comments/CommentsProvider.tsx | 44 +++++++++---------- .../list/src/hooks/useListToolbarButton.ts | 7 +-- 4 files changed, 27 insertions(+), 28 deletions(-) diff --git a/apps/www/src/registry/default/plate-ui/table-dropdown-menu.tsx b/apps/www/src/registry/default/plate-ui/table-dropdown-menu.tsx index a87a139bea..cc5de0e78e 100644 --- a/apps/www/src/registry/default/plate-ui/table-dropdown-menu.tsx +++ b/apps/www/src/registry/default/plate-ui/table-dropdown-menu.tsx @@ -33,8 +33,8 @@ import { ToolbarButton } from './toolbar'; export function TableDropdownMenu(props: DropdownMenuProps) { const editor = useEditorRef(); - // eslint-disable-next-line @typescript-eslint/no-shadow const tableSelected = useEditorSelector( + // eslint-disable-next-line @typescript-eslint/no-shadow (editor) => someNode(editor, { match: { type: ELEMENT_TABLE } }), [] ); diff --git a/apps/www/src/registry/default/plate-ui/table-element.tsx b/apps/www/src/registry/default/plate-ui/table-element.tsx index 30e8476566..a7b0130694 100644 --- a/apps/www/src/registry/default/plate-ui/table-element.tsx +++ b/apps/www/src/registry/default/plate-ui/table-element.tsx @@ -119,8 +119,8 @@ const TableFloatingToolbar = React.forwardRef< const selected = useSelected(); const editor = useEditorRef(); - // eslint-disable-next-line @typescript-eslint/no-shadow const selectionCollapsed = useEditorSelector( + // eslint-disable-next-line @typescript-eslint/no-shadow (editor) => !isSelectionExpanded(editor), [] ); diff --git a/packages/comments/src/stores/comments/CommentsProvider.tsx b/packages/comments/src/stores/comments/CommentsProvider.tsx index ae030ea8b9..1e439c4575 100644 --- a/packages/comments/src/stores/comments/CommentsProvider.tsx +++ b/packages/comments/src/stores/comments/CommentsProvider.tsx @@ -1,4 +1,3 @@ -import React from 'react'; import { createAtomStore, getNodeString, @@ -37,31 +36,30 @@ export interface CommentsStoreState { focusTextarea: boolean; onCommentAdd: ((value: WithPartial) => void) | null; - onCommentUpdate: ((value: Pick & Partial>) => void) | null; + onCommentUpdate: + | ((value: Pick & Partial>) => void) + | null; onCommentDelete: ((id: string) => void) | null; } -export const { - commentsStore, - useCommentsStore, - CommentsProvider, -} = createAtomStore( - { - myUserId: null, - users: {}, - comments: {}, - activeCommentId: null, - addingCommentId: null, - newValue: [{ type: 'p', children: [{ text: '' }] }], - focusTextarea: false, - onCommentAdd: null, - onCommentUpdate: null, - onCommentDelete: null, - } as CommentsStoreState, - { - name: 'comments', - } -); +export const { commentsStore, useCommentsStore, CommentsProvider } = + createAtomStore( + { + myUserId: null, + users: {}, + comments: {}, + activeCommentId: null, + addingCommentId: null, + newValue: [{ type: 'p', children: [{ text: '' }] }], + focusTextarea: false, + onCommentAdd: null, + onCommentUpdate: null, + onCommentDelete: null, + } as CommentsStoreState, + { + name: 'comments', + } + ); export const useCommentsStates = () => useCommentsStore().use; export const useCommentsSelectors = () => useCommentsStore().get; diff --git a/packages/list/src/hooks/useListToolbarButton.ts b/packages/list/src/hooks/useListToolbarButton.ts index cc7f9cc243..0de05dc2b2 100644 --- a/packages/list/src/hooks/useListToolbarButton.ts +++ b/packages/list/src/hooks/useListToolbarButton.ts @@ -8,9 +8,10 @@ import { import { ELEMENT_UL, toggleList } from '../index'; export const useListToolbarButtonState = ({ nodeType = ELEMENT_UL } = {}) => { - const pressed = useEditorSelector((editor) => - !!editor.selection && - someNode(editor, { match: { type: getPluginType(editor, nodeType) } }), + const pressed = useEditorSelector( + (editor) => + !!editor.selection && + someNode(editor, { match: { type: getPluginType(editor, nodeType) } }), [nodeType] );