From 1d43e46f996741cfe102e9cd5f8f5a9fad9d6983 Mon Sep 17 00:00:00 2001 From: Alex Yang Date: Sun, 30 Jul 2023 22:47:37 -0700 Subject: [PATCH] chore: add `noUnusedLocals` and `noUnusedParameters` rules (#3476) Co-authored-by: LongYinan --- apps/core/server.mts | 2 +- apps/core/src/atoms/index.ts | 2 +- apps/core/src/pages/workspace/detail-page.tsx | 2 +- apps/storybook/.storybook/main.ts | 2 +- .../src/components/notification-center/index.jotai.ts | 4 ++-- .../src/components/page-list/filter/logical/typesystem.ts | 1 + packages/component/src/ui/button/utils.ts | 2 +- packages/hooks/src/use-block-suite-workspace-name.ts | 2 +- .../hooks/src/use-block-suite-workspace-page-is-public.ts | 2 +- packages/plugin-infra/src/atom.ts | 2 +- packages/workspace/src/manager/index.ts | 2 +- .../workspace/src/providers/__tests__/sqlite-provider.spec.ts | 4 ++-- plugins/copilot/src/core/hooks/index.ts | 2 +- tsconfig.json | 4 ++-- 14 files changed, 17 insertions(+), 16 deletions(-) diff --git a/apps/core/server.mts b/apps/core/server.mts index 87d328f4f7..daf2163c4e 100644 --- a/apps/core/server.mts +++ b/apps/core/server.mts @@ -6,7 +6,7 @@ const PORT = process.env.PORT || 8080; app.use('/', express.static('dist')); -app.get('/*', (req, res) => { +app.get('/*', (_, res) => { res.sendFile('index.html', { root: 'dist' }); }); diff --git a/apps/core/src/atoms/index.ts b/apps/core/src/atoms/index.ts index 938b38a1b2..d997982dca 100644 --- a/apps/core/src/atoms/index.ts +++ b/apps/core/src/atoms/index.ts @@ -93,7 +93,7 @@ export const pageSettingFamily = atomFamily((pageId: string) => export const setPageModeAtom = atom( void 0, - (get, set, pageId: string, mode: PageMode) => { + (_, set, pageId: string, mode: PageMode) => { set(pageSettingFamily(pageId), { mode }); } ); diff --git a/apps/core/src/pages/workspace/detail-page.tsx b/apps/core/src/pages/workspace/detail-page.tsx index e536b08fe1..a76b677196 100644 --- a/apps/core/src/pages/workspace/detail-page.tsx +++ b/apps/core/src/pages/workspace/detail-page.tsx @@ -27,7 +27,7 @@ const DetailPageImpl = (): ReactElement => { const blockSuiteWorkspace = currentWorkspace.blockSuiteWorkspace; const collectionManager = useCollectionManager(currentWorkspace.id); const onLoad = useCallback( - (page: Page, editor: EditorContainer) => { + (_: Page, editor: EditorContainer) => { const dispose = editor.slots.pageLinkClicked.on(({ pageId }) => { return openPage(blockSuiteWorkspace.id, pageId); }); diff --git a/apps/storybook/.storybook/main.ts b/apps/storybook/.storybook/main.ts index e771ceeddb..817bb1865c 100644 --- a/apps/storybook/.storybook/main.ts +++ b/apps/storybook/.storybook/main.ts @@ -32,7 +32,7 @@ export default { framework: { name: '@storybook/react-vite', }, - async viteFinal(config, { configType }) { + async viteFinal(config, _) { return mergeConfig(config, { assetsInclude: ['**/*.md'], plugins: [ diff --git a/packages/component/src/components/notification-center/index.jotai.ts b/packages/component/src/components/notification-center/index.jotai.ts index 3d9e17a905..97a071ccb7 100644 --- a/packages/component/src/components/notification-center/index.jotai.ts +++ b/packages/component/src/components/notification-center/index.jotai.ts @@ -32,7 +32,7 @@ export const notificationsAtom = atom(get => get(notificationsBaseAtom) ); -export const removeNotificationAtom = atom(null, (get, set, key: string) => { +export const removeNotificationAtom = atom(null, (_, set, key: string) => { set(notificationsBaseAtom, notifications => notifications.filter(notification => notification.key !== key) ); @@ -40,7 +40,7 @@ export const removeNotificationAtom = atom(null, (get, set, key: string) => { export const pushNotificationAtom = atom( null, - (get, set, newNotification) => { + (_, set, newNotification) => { const key = newNotification.key; const removeNotification = () => set(notificationsBaseAtom, notifications => diff --git a/packages/component/src/components/page-list/filter/logical/typesystem.ts b/packages/component/src/components/page-list/filter/logical/typesystem.ts index 1aac7e8166..4b0e0a8533 100644 --- a/packages/component/src/components/page-list/filter/logical/typesystem.ts +++ b/packages/component/src/components/page-list/filter/logical/typesystem.ts @@ -145,6 +145,7 @@ export class DataDefine> { interface DataDefineConfig { name: string; supers: DataDefine[]; + _phantom?: T; } interface DataHelper { diff --git a/packages/component/src/ui/button/utils.ts b/packages/component/src/ui/button/utils.ts index 5071c8604a..874e1c5b47 100644 --- a/packages/component/src/ui/button/utils.ts +++ b/packages/component/src/ui/button/utils.ts @@ -35,7 +35,7 @@ export const getSize = ( }; export const getButtonColors = ( - theme: Theme, + _theme: Theme, type: ButtonProps['type'], disabled: boolean, extend?: { diff --git a/packages/hooks/src/use-block-suite-workspace-name.ts b/packages/hooks/src/use-block-suite-workspace-name.ts index 2f9365571d..f7df247d47 100644 --- a/packages/hooks/src/use-block-suite-workspace-name.ts +++ b/packages/hooks/src/use-block-suite-workspace-name.ts @@ -15,7 +15,7 @@ export function useBlockSuiteWorkspaceName(blockSuiteWorkspace: Workspace) { ); const writableAtom = atom( get => get(baseAtom), - (get, set, name: string) => { + (_, set, name: string) => { blockSuiteWorkspace.meta.setName(name); set(baseAtom, name); } diff --git a/packages/hooks/src/use-block-suite-workspace-page-is-public.ts b/packages/hooks/src/use-block-suite-workspace-page-is-public.ts index f09234aadf..cdfcf371fd 100644 --- a/packages/hooks/src/use-block-suite-workspace-page-is-public.ts +++ b/packages/hooks/src/use-block-suite-workspace-page-is-public.ts @@ -13,7 +13,7 @@ export function useBlockSuiteWorkspacePageIsPublic(page: Page) { const baseAtom = atom(page.meta.isPublic ?? false); const writableAtom = atom( get => get(baseAtom), - (get, set, isPublic: boolean) => { + (_, set, isPublic: boolean) => { page.workspace.setPageMeta(page.id, { isPublic, }); diff --git a/packages/plugin-infra/src/atom.ts b/packages/plugin-infra/src/atom.ts index 41c86b81fb..cc902d727e 100644 --- a/packages/plugin-infra/src/atom.ts +++ b/packages/plugin-infra/src/atom.ts @@ -56,7 +56,7 @@ export const contentLayoutAtom = atom< void >( get => get(contentLayoutBaseAtom), - (get, set, layout) => { + (_, set, layout) => { set(contentLayoutBaseAtom, prev => { let setV: (prev: ExpectedLayout) => ExpectedLayout; if (typeof layout !== 'function') { diff --git a/packages/workspace/src/manager/index.ts b/packages/workspace/src/manager/index.ts index da82455eb7..ad48e55770 100644 --- a/packages/workspace/src/manager/index.ts +++ b/packages/workspace/src/manager/index.ts @@ -45,7 +45,7 @@ type SubdocEvent = { const docUpdateCallbackWeakMap = new WeakMap(); const createMonitor = (doc: Doc) => { - const onUpdate: UpdateCallback = (update, origin) => { + const onUpdate: UpdateCallback = (_, origin) => { if (process.env.NODE_ENV === 'development') { if (typeof origin !== 'string' && typeof origin !== 'number') { console.warn( diff --git a/packages/workspace/src/providers/__tests__/sqlite-provider.spec.ts b/packages/workspace/src/providers/__tests__/sqlite-provider.spec.ts index 5d394d9d5b..44e3351541 100644 --- a/packages/workspace/src/providers/__tests__/sqlite-provider.spec.ts +++ b/packages/workspace/src/providers/__tests__/sqlite-provider.spec.ts @@ -32,14 +32,14 @@ const mockedAddBlob = vi.fn(); vi.stubGlobal('window', { apis: { db: { - getDocAsUpdates: async (workspaceId, guid) => { + getDocAsUpdates: async (_, guid) => { const subdoc = guid ? getDoc(offlineYdoc, guid) : offlineYdoc; if (!subdoc) { return false; } return Y.encodeStateAsUpdate(subdoc); }, - applyDocUpdate: async (id, update, subdocId) => { + applyDocUpdate: async (_, update, subdocId) => { const subdoc = subdocId ? getDoc(offlineYdoc, subdocId) : offlineYdoc; if (!subdoc) { return; diff --git a/plugins/copilot/src/core/hooks/index.ts b/plugins/copilot/src/core/hooks/index.ts index ec4563e571..6c08c00877 100644 --- a/plugins/copilot/src/core/hooks/index.ts +++ b/plugins/copilot/src/core/hooks/index.ts @@ -132,7 +132,7 @@ const getFollowingUpAtoms = ( const baseAtom = atomWithDefault | string[]>(async () => { return chatHistory?.getFollowingUp() ?? []; }); - const setAtom = atom(null, async (get, set) => { + const setAtom = atom(null, async (_, set) => { if (!followupLLMChain || !chatHistory) { throw new Error('followupLLMChain not set'); } diff --git a/tsconfig.json b/tsconfig.json index 61f7dcf59f..197c7eb833 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -11,10 +11,10 @@ "noImplicitOverride": true, "noImplicitReturns": true, "noImplicitThis": true, + "noUnusedLocals": true, + "noUnusedParameters": true, // noPropertyAccessFromIndexSignature: false, // noUncheckedIndexedAccess: false, - // noUnusedLocals: false, - // noUnusedParameters: false, "useUnknownInCatchVariables": true, // Modules