Skip to content

Commit

Permalink
chore: approve review
Browse files Browse the repository at this point in the history
  • Loading branch information
septs committed Aug 2, 2021
1 parent dfb2c1b commit 4c1682d
Show file tree
Hide file tree
Showing 32 changed files with 41 additions and 42 deletions.
3 changes: 0 additions & 3 deletions packages/.eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,9 @@
"lodash/import-scope": ["error", "member"],
"unused-imports/no-unused-imports-ts": "warn",
"@typescript-eslint/await-thenable": "error",
"@typescript-eslint/consistent-indexed-object-style": ["off", "record"],
"@typescript-eslint/no-for-in-array": "error",
"@typescript-eslint/no-implicit-any-catch": "error",
"@typescript-eslint/no-implied-eval": "error",
"@typescript-eslint/no-invalid-this": "error",
"@typescript-eslint/no-invalid-void-type": "error",
"@typescript-eslint/no-loop-func": "error",
"@typescript-eslint/no-this-alias": "error",
"@typescript-eslint/prefer-for-of": "error",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export default function BackupDialog({ open, onClose }: BackupDialogProps) {
try {
await Services.Welcome.createBackupFile({ download: true, onlyBackupWhoAmI: false })
onClose()
} catch (e: unknown) {
} catch (e) {
// TODO: show snack bar
// enqueueSnackbar(t('set_up_backup_fail'), {
// variant: 'error',
Expand Down
2 changes: 1 addition & 1 deletion packages/external-plugin-previewer/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export function MaskExternalPluginPreviewRenderer({ pluginBase, payload, script,
const instance = new RemoteContent({ $data: { payload } })
instance.$mount({ target: dom })
return () => instance.$destroy()
} catch (e: unknown) {
} catch (e) {
if (e instanceof Error) {
onError?.(e)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,7 @@ function BadgeRenderer({ meta }: { meta: TypedMessage['meta'] }) {
}
try {
return normalizeBadgeDescriptor(key, plugin, render(key, value), i18n)
} catch (e: unknown) {
} catch (e) {
console.error(e)
return null
}
Expand All @@ -510,7 +510,7 @@ function BadgeRenderer({ meta }: { meta: TypedMessage['meta'] }) {
}
try {
return normalizeBadgeDescriptor(key, plugin, f(value), i18n)
} catch (e: unknown) {
} catch (e) {
console.error(e)
return null
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ export const DefaultTypedMessageTupleRenderer = memo(function DefaultTypedMessag
) {
try {
JSON.stringify(props.message.items)
} catch (e: unknown) {
} catch (e) {
if (e instanceof Error && e.message.includes('circular structure')) {
return (
<Typography>
Expand Down
2 changes: 1 addition & 1 deletion packages/maskbook/src/database/helpers/avatar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export async function storeAvatar(
} else {
await storeAvatarDB(identifier, avatar)
}
} catch (e: unknown) {
} catch (e) {
console.error('Store avatar failed', e)
} finally {
queryAvatarDataURL.cache.delete(identifier.toText())
Expand Down
2 changes: 1 addition & 1 deletion packages/maskbook/src/database/helpers/openDB.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export function createDBAccessWithAsyncUpgrade<DBSchema, AsyncUpgradePreparedDat
// if the open success, the stored version is small or eq than currentTryOpenVersion
// let's call the prepare function to do all the async jobs
lastVersionData = await asyncUpgradePrepare(db)
} catch (e: unknown) {
} catch (e) {
if (currentVersion >= latestVersion) throw e
// if the stored database version is bigger than the currentTryOpenVersion
// It will fail and we just move to next version
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ async function* decryptFromPayloadWithProgress_raw(
const b = decryptAsAuthor(whoAmI, minePublic)
// ! Don't remove the await
return await a.catch(() => b)
} catch (e: unknown) {
} catch (e) {
lastError = e
}

Expand Down Expand Up @@ -235,7 +235,7 @@ async function* decryptFromPayloadWithProgress_raw(
try {
// ! Do not remove the await here.
return await decryptWith(aesKeyEncrypted)
} catch (e: unknown) {
} catch (e) {
if (e instanceof Error && e.message === i18n.t('service_not_share_target')) {
console.debug(e)
// TODO: Replace this error with:
Expand All @@ -261,7 +261,7 @@ async function* decryptFromPayloadWithProgress_raw(
console.log('New key received, trying', aes)
try {
return await decryptWith(aes)
} catch (e: unknown) {
} catch (e) {
console.debug(e)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export async function encryptTo(
try {
const publicKey = (await queryPersonaByProfileDB(whoAmI))?.publicKey
if (publicKey) payload.authorPublicKey = compressSecp256k1Key(publicKey, 'public')
} catch (e: unknown) {
} catch (e) {
// ignore
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class NonceManager {
try {
this.lock()
callback(null, await getTransactionCount(this.address))
} catch (e: unknown) {
} catch (e) {
if (e instanceof Error) {
callback(e)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ export async function INTERNAL_send(
}
break
}
} catch (error: unknown) {
} catch (error) {
if (error instanceof Error) {
callback(error)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ async function fetchInjectedScript() {
.then(JSON.stringify)}
document.documentElement.appendChild(script)
}`
} catch (e: unknown) {
} catch (e) {
console.error(e)
return `console.log('Injected script failed to load.')`
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class MutexStorage<T extends browser.storage.StorageValue> {
this.lock()
const stored = await browser.storage.local.get(key)
callback(null, (stored ?? {})[key] as T)
} catch (e: unknown) {
} catch (e) {
if (e instanceof Error) {
callback(e)
}
Expand All @@ -49,7 +49,7 @@ class MutexStorage<T extends browser.storage.StorageValue> {
this.lock()
await browser.storage.local.set({ [key]: value })
callback(null)
} catch (e: unknown) {
} catch (e) {
if (e instanceof Error) {
callback(e)
}
Expand Down
2 changes: 1 addition & 1 deletion packages/maskbook/src/extension/debug-page/DatabaseOps.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ async function restoreAll(parsed: BackupFormat) {
} else {
await db.add(storeName, value, key)
}
} catch (e: unknown) {
} catch (e) {
console.error('Recover error when ', key, value, parsed)
// Error from IndexedDB transaction is not recoverable
throw e
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ function dispatchEventRaw<T extends Event>(target: Node | Document | null, event
if (capture) continue
try {
f(event)
} catch (e: unknown) {
} catch (e) {
error(e)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ export function useCheckCallback() {
claimable: available && isGreaterThan(claimable, 0) && !isEnd ? claimable : '0',
ratio: new BigNumber(claimable).dividedBy(amount),
})
} catch (error: unknown) {
} catch (error) {
if (!(error instanceof Error)) {
return
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export function CheckoutDialog(props: CheckoutDialogProps) {
accountAddress: account,
recipientAddress: account,
})
} catch (e: unknown) {
} catch (e) {
if (e instanceof Error) {
enqueueSnackbar(e.message, {
variant: 'error',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ export function ListingByHighestBidCard(props: ListingByHighestBidCardProps) {
waitForHighestBid: true,
paymentTokenAddress: token.value.address, // english auction must be erc20 token
})
} catch (e: unknown) {
} catch (e) {
if (e instanceof Error) {
enqueueSnackbar(e.message, { variant: 'error', preventDuplicate: true })
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ export function ListingByPriceCard(props: ListingByPriceCardProps) {
expirationTime: endingPriceChecked ? toUnixTimestamp(expirationTime) : undefined,
buyerAddress: privacyChecked ? buyerAddress : undefined,
})
} catch (e: unknown) {
} catch (e) {
if (e instanceof Error) {
enqueueSnackbar(e.message, { variant: 'error', preventDuplicate: true })
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ export function MakeOfferDialog(props: MakeOfferDialogProps) {
expirationTime: !isAuction ? toUnixTimestamp(expirationDateTime) : undefined,
paymentTokenAddress: token.value.type === EthereumTokenType.Native ? undefined : token.value.address,
})
} catch (e: unknown) {
} catch (e) {
if (e instanceof Error) {
enqueueSnackbar(e.message, { variant: 'error', preventDuplicate: true })
}
Expand Down
3 changes: 2 additions & 1 deletion packages/maskbook/src/plugins/External/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ registerPlugin({
...base,
SNSAdaptor: {
load: () => import('./SNSAdaptor'),
hotModuleReload: (hot) => module.hot?.accept('./SNSAdaptor/index', () => hot(import('./SNSAdaptor'))),
hotModuleReload: (hot) =>
import.meta.webpackHot?.accept('./SNSAdaptor/index', () => hot(import('./SNSAdaptor'))),
},
})
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ export function ImportWalletDialog(props: ImportWalletDialogProps) {
mnemonic: words,
passphrase: '',
})
} catch (err: unknown) {
} catch (err) {
if (err instanceof Error && err.message !== 'Add exists phrase.') {
throw err
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ async function openPostDialogFacebook() {
notActivated.evaluate()[0].click()
await timeout(new MutationObserverWatcher(activated), 2000)
await delay(1000)
} catch (e: unknown) {
} catch (e) {
clickFailed(e)
}
} else {
Expand All @@ -37,7 +37,7 @@ async function openPostDialogFacebook() {
dom2.click()
await timeout(new MutationObserverWatcher(activated), 1000)
if (!dialog.evaluate()[0]) throw new Error('Click not working')
} catch (error: unknown) {
} catch (error) {
clickFailed(error)
}
console.log('Awaiting dialog')
Expand Down Expand Up @@ -92,7 +92,7 @@ export async function pasteTextToCompositionFacebook(
// Prevent Custom Paste failed, this will cause service not available to user.
if (!element.innerText.includes(text) || ('value' in element && !element.value.includes(text)))
copyFailed('Not detected')
} catch (error: unknown) {
} catch (error) {
copyFailed(error)
}
scrollBack()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export function getProfileIdentifierAtFacebook(
}
}
return unknown
} catch (e: unknown) {
} catch (e) {
console.error(e)
}
return unknown
Expand Down
4 changes: 2 additions & 2 deletions packages/maskbook/src/utils/hooks/useQRCodeVideoScan.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export function useQRCodeVideoScan(
}
video.current.srcObject = media
video.current.play()
} catch (e: unknown) {
} catch (e) {
console.error(e)
stop()
}
Expand Down Expand Up @@ -77,7 +77,7 @@ export function useQRCodeVideoScan(
try {
const [result] = await scanner.current.detect(video.current)
if (result) onResult?.(result.rawValue)
} catch (e: unknown) {
} catch (e) {
errorTimes.current += 1
} finally {
lastScanning.current = false
Expand Down
2 changes: 1 addition & 1 deletion packages/maskbook/src/utils/memoize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export function memoizePromise<T extends (...args: Args) => Promise<any>, Args e
try {
// ? DO NOT remove "await" here
return await f(...args)
} catch (e: unknown) {
} catch (e) {
memorizedFunction.cache.delete(resolver!(...args))
throw e
}
Expand Down
2 changes: 1 addition & 1 deletion packages/maskbook/src/utils/promiEvent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ export function iteratorToPromiEvent(
break
}
}
} catch (e: unknown) {
} catch (e) {
PE.emit(TransactionEventType.ERROR, e)
reject_?.(e)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export function WalletRecordToJSONFormat(wallet: WalletRecord): WalletBackup {
backup.publicKey = keyToJWK(wallet_._public_key_, 'public')
if (wallet_._private_key_ && isSameAddress(keyToAddr(wallet_._private_key_, 'private'), wallet.address))
backup.privateKey = keyToJWK(wallet_._private_key_, 'private')
} catch (e: unknown) {
} catch (e) {
console.error(e)
}
return backup as WalletBackup
Expand Down
2 changes: 1 addition & 1 deletion packages/shared-base/src/serializer/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export const serializer: Serialization = {
deserialization(to: string) {
try {
return typeson.revive(to)
} catch (e: unknown) {
} catch (e) {
console.error(e)
}
return {}
Expand Down
2 changes: 1 addition & 1 deletion packages/shared-base/src/utils/pollingTask.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export function pollingTask(
let stop = false
try {
stop = await task()
} catch (e: unknown) {
} catch (e) {
console.error(e)
}
if (!stop) resetTask()
Expand Down
4 changes: 2 additions & 2 deletions packages/web3-shared/src/hooks/useMulticall.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export function useMulticallCallback() {
type: MulticalStateType.SUCCEED,
results: returnData,
})
} catch (error: unknown) {
} catch (error) {
if (error instanceof Error) {
setMulticallState({
type: MulticalStateType.FAILED,
Expand Down Expand Up @@ -88,7 +88,7 @@ export function useMutlicallStateDecoded<
error: null,
value: decodeOutputString(web3, outputs, raw) as R,
}
} catch (error: unknown) {
} catch (error) {
return { raw, error, value: null }
}
})
Expand Down
3 changes: 2 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@
"skipLibCheck": true,
"resolveJsonModule": true,
"useDefineForClassFields": true,
"stripInternal": true
"stripInternal": true,
"useUnknownInCatchVariables": true
},
"files": [],
"ts-node": {
Expand Down

0 comments on commit 4c1682d

Please sign in to comment.