From e66b0c71c404f13685cc8f414c5acf7282949332 Mon Sep 17 00:00:00 2001 From: fyears <1142836+fyears@users.noreply.github.com> Date: Wed, 8 May 2024 22:04:21 +0800 Subject: [PATCH] fix format again --- biome.json | 16 ++++++++++++++-- src/fsDropbox.ts | 4 ++-- src/fsGetter.ts | 6 ------ src/fsLocal.ts | 2 +- src/fsOnedrive.ts | 2 ++ src/fsS3.ts | 1 + src/main.ts | 2 +- src/misc.ts | 16 +++++++--------- src/sync.ts | 1 + 9 files changed, 29 insertions(+), 21 deletions(-) diff --git a/biome.json b/biome.json index 524a201..405a298 100644 --- a/biome.json +++ b/biome.json @@ -32,11 +32,23 @@ "rules": { "recommended": true, "suspicious": { - "noExplicitAny": "off" + "noExplicitAny": "off", + "noPrototypeBuiltins": "off", + "noControlCharactersInRegex": "off" }, "style": { "noUselessElse": "off", - "useNodejsImportProtocol": "off" + "useNodejsImportProtocol": "off", + "noUnusedTemplateLiteral": "off", + "useTemplate": "off", + "noNonNullAssertion": "off" + }, + "performance": { + "noDelete": "off" + }, + "complexity": { + "noForEach": "off", + "useLiteralKeys": "off" } } } diff --git a/src/fsDropbox.ts b/src/fsDropbox.ts index 1c3a116..b69da2f 100644 --- a/src/fsDropbox.ts +++ b/src/fsDropbox.ts @@ -134,7 +134,7 @@ export const fixEntityListCasesInplace = (entities: { key?: string }[]) => { caseMapping[newKey.toLocaleLowerCase()] = newKey; e.key = newKey; // console.log(JSON.stringify(caseMapping,null,2)); - continue; + // continue; } else { throw Error(`${parentFolder} doesn't have cases record??`); } @@ -145,7 +145,7 @@ export const fixEntityListCasesInplace = (entities: { key?: string }[]) => { .slice(-1) .join("/")}`; e.key = newKey; - continue; + // continue; } else { throw Error(`${parentFolder} doesn't have cases record??`); } diff --git a/src/fsGetter.ts b/src/fsGetter.ts index ea36d2a..bcfc82c 100644 --- a/src/fsGetter.ts +++ b/src/fsGetter.ts @@ -17,37 +17,31 @@ export function getClient( switch (settings.serviceType) { case "s3": return new FakeFsS3(settings.s3); - break; case "webdav": return new FakeFsWebdav( settings.webdav, vaultName, saveUpdatedConfigFunc ); - break; case "dropbox": return new FakeFsDropbox( settings.dropbox, vaultName, saveUpdatedConfigFunc ); - break; case "onedrive": return new FakeFsOnedrive( settings.onedrive, vaultName, saveUpdatedConfigFunc ); - break; case "webdis": return new FakeFsWebdis( settings.webdis, vaultName, saveUpdatedConfigFunc ); - break; default: throw Error(`cannot init client for serviceType=${settings.serviceType}`); - break; } } diff --git a/src/fsLocal.ts b/src/fsLocal.ts index 1bee67a..330d22c 100644 --- a/src/fsLocal.ts +++ b/src/fsLocal.ts @@ -83,7 +83,7 @@ export class FakeFsLocal extends FakeFs { if (r.keyRaw.startsWith(DEFAULT_DEBUG_FOLDER)) { // skip listing the debug folder, // which should always not involved in sync - continue; + // continue; } else { local.push(r); } diff --git a/src/fsOnedrive.ts b/src/fsOnedrive.ts index a17c24d..4187b6e 100644 --- a/src/fsOnedrive.ts +++ b/src/fsOnedrive.ts @@ -567,6 +567,7 @@ export class FakeFsOnedrive extends FakeFs { // TODO: // 20220401: On Android, requestUrl has issue that text becomes base64. // Use fetch everywhere instead! + // biome-ignore lint/correctness/noConstantCondition: hard code if (false /*VALID_REQURL*/) { const res = await requestUrl({ url: theUrl, @@ -617,6 +618,7 @@ export class FakeFsOnedrive extends FakeFs { // TODO: // 20220401: On Android, requestUrl has issue that text becomes base64. // Use fetch everywhere instead! + // biome-ignore lint/correctness/noConstantCondition: hard code if (false /*VALID_REQURL*/) { const res = await requestUrl({ url: theUrl, diff --git a/src/fsS3.ts b/src/fsS3.ts index 6ce8fa5..7c30777 100644 --- a/src/fsS3.ts +++ b/src/fsS3.ts @@ -22,6 +22,7 @@ import { import { requestTimeout } from "@smithy/fetch-http-handler/dist-es/request-timeout"; import { type HttpRequest, HttpResponse } from "@smithy/protocol-http"; import { buildQueryString } from "@smithy/querystring-builder"; +// biome-ignore lint/suspicious/noShadowRestrictedNames: import AggregateError from "aggregate-error"; import * as mime from "mime-types"; import { Platform, type RequestUrlParam, requestUrl } from "obsidian"; diff --git a/src/main.ts b/src/main.ts index bd4a8a7..4998bce 100644 --- a/src/main.ts +++ b/src/main.ts @@ -53,6 +53,7 @@ import { import { RemotelySaveSettingTab } from "./settings"; import { SyncAlgoV3Modal } from "./syncAlgoV3Notice"; +// biome-ignore lint/suspicious/noShadowRestrictedNames: import AggregateError from "aggregate-error"; import throttle from "lodash/throttle"; import { exportVaultSyncPlansToFiles } from "./debugMode"; @@ -300,7 +301,6 @@ export default class RemotelySavePlugin extends Plugin { default: throw Error(`unknown step=${step} for showing notice`); - break; } }; diff --git a/src/misc.ts b/src/misc.ts index 9f7b41b..457e1f8 100644 --- a/src/misc.ts +++ b/src/misc.ts @@ -115,7 +115,7 @@ export const base64ToArrayBuffer = (b64text: string) => { }; export const copyArrayBuffer = (src: ArrayBuffer) => { - var dst = new ArrayBuffer(src.byteLength); + const dst = new ArrayBuffer(src.byteLength); new Uint8Array(dst).set(new Uint8Array(src)); return dst; }; @@ -254,9 +254,9 @@ export const getRandomIntInclusive = (min: number, max: number) => { const randomBuffer = new Uint32Array(1); window.crypto.getRandomValues(randomBuffer); const randomNumber = randomBuffer[0] / (0xffffffff + 1); - min = Math.ceil(min); - max = Math.floor(max); - return Math.floor(randomNumber * (max - min + 1)) + min; + const min2 = Math.ceil(min); + const max2 = Math.floor(max); + return Math.floor(randomNumber * (max2 - min2 + 1)) + min2; }; /** @@ -389,9 +389,8 @@ export const toText = (x: any) => { if ( x instanceof Error || - (x && - x.stack && - x.message && + (x?.stack && + x?.message && typeof x.stack === "string" && typeof x.message === "string") ) { @@ -587,6 +586,7 @@ export const changeMobileStatusBar = ( if (oldAppContainerObserver !== undefined) { console.debug(`disconnect oldAppContainerObserver`); oldAppContainerObserver.disconnect(); + // biome-ignore lint/style/noParameterAssign: we want gc oldAppContainerObserver = undefined; } statusbar.style.removeProperty("display"); @@ -623,7 +623,6 @@ export const fixEntityListCasesInplace = (entities: { keyRaw: string }[]) => { caseMapping[newKeyRaw.toLocaleLowerCase()] = newKeyRaw; e.keyRaw = newKeyRaw; // console.log(JSON.stringify(caseMapping,null,2)); - continue; } else { throw Error(`${parentFolder} doesn't have cases record??`); } @@ -634,7 +633,6 @@ export const fixEntityListCasesInplace = (entities: { keyRaw: string }[]) => { .slice(-1) .join("/")}`; e.keyRaw = newKeyRaw; - continue; } else { throw Error(`${parentFolder} doesn't have cases record??`); } diff --git a/src/sync.ts b/src/sync.ts index 2ada425..201fc0e 100644 --- a/src/sync.ts +++ b/src/sync.ts @@ -1,3 +1,4 @@ +// biome-ignore lint/suspicious/noShadowRestrictedNames: import AggregateError from "aggregate-error"; import PQueue from "p-queue"; import XRegExp from "xregexp";