From f2b7af973bcc18a64065a398d428ae3f5f4aa7be Mon Sep 17 00:00:00 2001 From: Lim Jet <57783762+daoauth@users.noreply.github.com> Date: Sat, 4 Jan 2025 00:26:55 +0900 Subject: [PATCH] lint fix --- src/webview/activitybar/eslint.config.js | 8 ++++++++ src/webview/activitybar/package.json | 2 +- src/webview/activitybar/src/App.tsx | 12 ++++++++++-- src/webview/activitybar/src/components/Account.tsx | 7 ++++++- .../src/components/ExplorerOwnerObjects.tsx | 2 +- src/webview/activitybar/src/components/Function.tsx | 2 +- .../activitybar/src/utilities/signAndExcute.ts | 2 +- src/webview/panel/eslint.config.js | 8 ++++++++ src/webview/ptb-builder/eslint.config.js | 8 ++++++++ 9 files changed, 44 insertions(+), 7 deletions(-) diff --git a/src/webview/activitybar/eslint.config.js b/src/webview/activitybar/eslint.config.js index 2b3e6cc..b8369b2 100644 --- a/src/webview/activitybar/eslint.config.js +++ b/src/webview/activitybar/eslint.config.js @@ -23,6 +23,14 @@ export default tseslint.config( 'warn', { allowConstantExport: true }, ], + '@typescript-eslint/no-unused-expressions': [ + 'error', + { + allowShortCircuit: true, + allowTernary: true, + allowTaggedTemplates: true, + }, + ], }, }, ); diff --git a/src/webview/activitybar/package.json b/src/webview/activitybar/package.json index 8ab4c14..cc7871c 100644 --- a/src/webview/activitybar/package.json +++ b/src/webview/activitybar/package.json @@ -6,7 +6,7 @@ "scripts": { "dev": "vite", "build": "tsc -b && vite build", - "lint": "eslint .", + "lint": "eslint --fix .", "preview": "vite preview" }, "dependencies": { diff --git a/src/webview/activitybar/src/App.tsx b/src/webview/activitybar/src/App.tsx index dc3dae4..851a630 100644 --- a/src/webview/activitybar/src/App.tsx +++ b/src/webview/activitybar/src/App.tsx @@ -11,7 +11,7 @@ import { ExplorerObject } from './components/ExplorerObject'; import { ExplorerPackage } from './components/ExplorerPackage'; import { Workspace } from './components/Workspace'; import { COMMENDS } from './utilities/commends'; -import { STATE } from './recoil'; +import { IAccount, STATE } from './recoil'; function App() { const initialized = useRef(false); @@ -20,7 +20,15 @@ function App() { const [state, setState] = useRecoilState(STATE); useEffect(() => { - const handleMessage = async (event: any) => { + const handleMessage = async ( + event: MessageEvent<{ + command: COMMENDS; + data: { + hasTerminal: boolean; + account?: IAccount; + }; + }>, + ) => { const message = event.data; switch (message.command) { case COMMENDS.Env: diff --git a/src/webview/activitybar/src/components/Account.tsx b/src/webview/activitybar/src/components/Account.tsx index cbf3f78..04edf4a 100644 --- a/src/webview/activitybar/src/components/Account.tsx +++ b/src/webview/activitybar/src/components/Account.tsx @@ -85,7 +85,12 @@ export const Account = ({ client }: { client: SuiClient | undefined }) => { setState((oldState) => ({ ...oldState, balance })); }; - const handleMessage = async (event: any) => { + const handleMessage = async ( + event: MessageEvent<{ + command: COMMENDS; + data: string; + }>, + ) => { const message = event.data; switch (message.command) { case COMMENDS.LoginJwt: diff --git a/src/webview/activitybar/src/components/ExplorerOwnerObjects.tsx b/src/webview/activitybar/src/components/ExplorerOwnerObjects.tsx index cda8450..82b7491 100644 --- a/src/webview/activitybar/src/components/ExplorerOwnerObjects.tsx +++ b/src/webview/activitybar/src/components/ExplorerOwnerObjects.tsx @@ -119,7 +119,7 @@ export const ExplorerOwnerObjects = ({ const handleNext = async () => { if (currentPage < objectsInfo.length - 1) { setCurrentPage(currentPage + 1); - } else if (!!next) { + } else if (next) { await loadOwnerObjecs(next); setCurrentPage(currentPage + 1); } diff --git a/src/webview/activitybar/src/components/Function.tsx b/src/webview/activitybar/src/components/Function.tsx index 9ac83fa..56695e6 100644 --- a/src/webview/activitybar/src/components/Function.tsx +++ b/src/webview/activitybar/src/components/Function.tsx @@ -130,7 +130,7 @@ export const Function = ({ ) => { try { setIsLoading(true); - let errors: boolean[] = [...new Array(inputValues.length).fill(false)]; + const errors: boolean[] = [...new Array(inputValues.length).fill(false)]; for (let i = 0; i < inputValues.length; i++) { if (state.account) { const filtered = deleteTxContext(func); diff --git a/src/webview/activitybar/src/utilities/signAndExcute.ts b/src/webview/activitybar/src/utilities/signAndExcute.ts index 77980c2..5312aa4 100644 --- a/src/webview/activitybar/src/utilities/signAndExcute.ts +++ b/src/webview/activitybar/src/utilities/signAndExcute.ts @@ -46,7 +46,7 @@ export const signAndExcute = async ( digest, options: { showObjectChanges: true }, }); - if (!!res.errors) { + if (res.errors) { vscode.postMessage({ command: COMMENDS.MsgError, data: `error: ${res.errors.toString()}`, diff --git a/src/webview/panel/eslint.config.js b/src/webview/panel/eslint.config.js index 2b3e6cc..b8369b2 100644 --- a/src/webview/panel/eslint.config.js +++ b/src/webview/panel/eslint.config.js @@ -23,6 +23,14 @@ export default tseslint.config( 'warn', { allowConstantExport: true }, ], + '@typescript-eslint/no-unused-expressions': [ + 'error', + { + allowShortCircuit: true, + allowTernary: true, + allowTaggedTemplates: true, + }, + ], }, }, ); diff --git a/src/webview/ptb-builder/eslint.config.js b/src/webview/ptb-builder/eslint.config.js index 2b3e6cc..b8369b2 100644 --- a/src/webview/ptb-builder/eslint.config.js +++ b/src/webview/ptb-builder/eslint.config.js @@ -23,6 +23,14 @@ export default tseslint.config( 'warn', { allowConstantExport: true }, ], + '@typescript-eslint/no-unused-expressions': [ + 'error', + { + allowShortCircuit: true, + allowTernary: true, + allowTaggedTemplates: true, + }, + ], }, }, );