From fa3708c879a1477cf0738521fd343b2c6f789663 Mon Sep 17 00:00:00 2001 From: Sebastian Malton Date: Fri, 7 Jan 2022 08:38:21 -0500 Subject: [PATCH] Add eslint:recommended lint rule (#4577) --- .eslintrc.js | 7 ++++-- src/common/__tests__/cluster-store.test.ts | 4 ++-- .../k8s-api/__tests__/kube-object.test.ts | 6 ++--- src/common/k8s-api/endpoints/crd.api.ts | 4 +++- src/common/k8s-api/endpoints/ingress.api.ts | 2 +- src/common/k8s-api/endpoints/metrics.api.ts | 3 ++- src/common/k8s-api/kube-api.ts | 23 ++++++++----------- src/common/k8s-api/kube-object.store.ts | 6 ++++- src/common/protocol-handler/router.ts | 2 +- src/common/search-store.ts | 2 +- src/common/utils/defineGlobal.ts | 2 +- src/common/utils/iter.ts | 1 + src/common/utils/tar.ts | 5 ++-- src/main/helm/helm-repo-manager.ts | 4 +++- src/main/initializers/ipc.ts | 4 +++- src/main/kubectl.ts | 22 +++++++++--------- src/main/shell-session/node-shell-session.ts | 1 + src/main/shell-session/shell-session.ts | 8 +++++-- src/migrations/cluster-store/2.0.0-beta.2.ts | 2 +- src/migrations/cluster-store/2.6.0-beta.3.ts | 2 +- .../+config-autoscalers/hpa-details.tsx | 11 +++++---- .../get-base-registry-url.tsx | 2 +- .../components/file-picker/file-picker.tsx | 9 ++++++-- src/renderer/components/icon/icon.tsx | 1 + .../components/input/input_validators.ts | 2 +- src/renderer/components/menu/menu.tsx | 6 ++++- src/renderer/utils/createStorage.ts | 4 +++- 27 files changed, 88 insertions(+), 57 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index dba0a666d9..514ab56bd7 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -54,6 +54,7 @@ module.exports = { "react-hooks", ], rules: { + "no-constant-condition": ["error", { "checkLoops": false }], "header/header": [2, "./license-header"], "comma-dangle": ["error", "always-multiline"], "comma-spacing": "error", @@ -107,6 +108,7 @@ module.exports = { ], parser: "@typescript-eslint/parser", extends: [ + "eslint:recommended", "plugin:@typescript-eslint/recommended", "plugin:import/recommended", "plugin:import/typescript", @@ -120,7 +122,7 @@ module.exports = { sourceType: "module", }, rules: { - "no-irregular-whitespace": "error", + "no-constant-condition": ["error", { "checkLoops": false }], "header/header": [2, "./license-header"], "no-invalid-this": "off", "@typescript-eslint/no-invalid-this": ["error"], @@ -193,6 +195,7 @@ module.exports = { "unused-imports", ], extends: [ + "eslint:recommended", "plugin:@typescript-eslint/recommended", "plugin:react/recommended", "plugin:import/recommended", @@ -204,7 +207,7 @@ module.exports = { jsx: true, }, rules: { - "no-irregular-whitespace": "error", + "no-constant-condition": ["error", { "checkLoops": false }], "header/header": [2, "./license-header"], "react/prop-types": "off", "no-invalid-this": "off", diff --git a/src/common/__tests__/cluster-store.test.ts b/src/common/__tests__/cluster-store.test.ts index 1452dfadd5..81923d93ea 100644 --- a/src/common/__tests__/cluster-store.test.ts +++ b/src/common/__tests__/cluster-store.test.ts @@ -472,8 +472,8 @@ describe("pre 2.6.0 config with a cluster icon", () => { it("moves the icon into preferences", async () => { const storedClusterData = ClusterStore.getInstance().clustersList[0]; - expect(storedClusterData.hasOwnProperty("icon")).toBe(false); - expect(storedClusterData.preferences.hasOwnProperty("icon")).toBe(true); + expect(Object.prototype.hasOwnProperty.call(storedClusterData, "icon")).toBe(false); + expect(Object.prototype.hasOwnProperty.call(storedClusterData.preferences, "icon")).toBe(true); expect(storedClusterData.preferences.icon.startsWith("data:;base64,")).toBe(true); }); }); diff --git a/src/common/k8s-api/__tests__/kube-object.test.ts b/src/common/k8s-api/__tests__/kube-object.test.ts index cb2a412a5e..edc7a52505 100644 --- a/src/common/k8s-api/__tests__/kube-object.test.ts +++ b/src/common/k8s-api/__tests__/kube-object.test.ts @@ -164,14 +164,14 @@ describe("KubeObject", () => { describe("isJsonApiDataList", () => { function isAny(val: unknown): val is any { - return !Boolean(void val); + return true; } function isNotAny(val: unknown): val is any { - return Boolean(void val); + return false; } - function isBoolean(val: unknown): val is Boolean { + function isBoolean(val: unknown): val is boolean { return typeof val === "boolean"; } diff --git a/src/common/k8s-api/endpoints/crd.api.ts b/src/common/k8s-api/endpoints/crd.api.ts index 6b3f198f9d..4892a8a262 100644 --- a/src/common/k8s-api/endpoints/crd.api.ts +++ b/src/common/k8s-api/endpoints/crd.api.ts @@ -162,7 +162,8 @@ export class CustomResourceDefinition extends KubeObject { } } break; - case "apiextensions.k8s.io/v1beta1": + + case "apiextensions.k8s.io/v1beta1": { const { additionalPrinterColumns: apc } = this.spec; const additionalPrinterColumns = apc?.map(({ JSONPath, ...apc }) => ({ ...apc, jsonPath: JSONPath })); @@ -173,6 +174,7 @@ export class CustomResourceDefinition extends KubeObject { schema: this.spec.validation, additionalPrinterColumns, }; + } } throw new Error(`Unknown apiVersion=${apiVersion}: Failed to find a version for CustomResourceDefinition ${this.metadata.name}`); diff --git a/src/common/k8s-api/endpoints/ingress.api.ts b/src/common/k8s-api/endpoints/ingress.api.ts index 7b80dca29e..8e46021eae 100644 --- a/src/common/k8s-api/endpoints/ingress.api.ts +++ b/src/common/k8s-api/endpoints/ingress.api.ts @@ -187,7 +187,7 @@ export class Ingress extends KubeObject { const servicePort = defaultBackend?.service.port.number ?? backend?.servicePort; if (rules && rules.length > 0) { - if (rules.some(rule => rule.hasOwnProperty("http"))) { + if (rules.some(rule => Object.prototype.hasOwnProperty.call(rule, "http"))) { ports.push(httpPort); } } else if (servicePort !== undefined) { diff --git a/src/common/k8s-api/endpoints/metrics.api.ts b/src/common/k8s-api/endpoints/metrics.api.ts index bd6bc4709c..0fdadbe0dc 100644 --- a/src/common/k8s-api/endpoints/metrics.api.ts +++ b/src/common/k8s-api/endpoints/metrics.api.ts @@ -184,7 +184,8 @@ export function getMetricLastPoints(metrics: Record) { if (metric.data.result.length) { result[metricName] = +metric.data.result[0].values.slice(-1)[0][1]; } - } catch (e) { + } catch { + // ignore error } return result; diff --git a/src/common/k8s-api/kube-api.ts b/src/common/k8s-api/kube-api.ts index a5d9a91347..b6a823935a 100644 --- a/src/common/k8s-api/kube-api.ts +++ b/src/common/k8s-api/kube-api.ts @@ -701,21 +701,16 @@ export class KubeApi { } protected modifyWatchEvent(event: IKubeWatchEvent) { + if (event.type === "ERROR") { + return; - switch (event.type) { - case "ADDED": - case "DELETED": - - case "MODIFIED": { - ensureObjectSelfLink(this, event.object); - - const { namespace, resourceVersion } = event.object.metadata; - - this.setResourceVersion(namespace, resourceVersion); - this.setResourceVersion("", resourceVersion); - - break; - } } + + ensureObjectSelfLink(this, event.object); + + const { namespace, resourceVersion } = event.object.metadata; + + this.setResourceVersion(namespace, resourceVersion); + this.setResourceVersion("", resourceVersion); } } diff --git a/src/common/k8s-api/kube-object.store.ts b/src/common/k8s-api/kube-object.store.ts index 6858a96907..1eb7d9ff50 100644 --- a/src/common/k8s-api/kube-object.store.ts +++ b/src/common/k8s-api/kube-object.store.ts @@ -472,7 +472,9 @@ export abstract class KubeObjectStore extends ItemStore switch (type) { case "ADDED": - case "MODIFIED": + + // falls through + case "MODIFIED": { const newItem = new this.api.objectConstructor(object); if (!item) { @@ -480,7 +482,9 @@ export abstract class KubeObjectStore extends ItemStore } else { items[index] = newItem; } + break; + } case "DELETED": if (item) { items.splice(index, 1); diff --git a/src/common/protocol-handler/router.ts b/src/common/protocol-handler/router.ts index afb0f4c2af..b51e687677 100644 --- a/src/common/protocol-handler/router.ts +++ b/src/common/protocol-handler/router.ts @@ -88,7 +88,7 @@ export abstract class LensProtocolRouter { public static readonly LoggingPrefix = "[PROTOCOL ROUTER]"; - static readonly ExtensionUrlSchema = `/:${EXTENSION_PUBLISHER_MATCH}(\@[A-Za-z0-9_]+)?/:${EXTENSION_NAME_MATCH}`; + static readonly ExtensionUrlSchema = `/:${EXTENSION_PUBLISHER_MATCH}(@[A-Za-z0-9_]+)?/:${EXTENSION_NAME_MATCH}`; constructor(protected dependencies: Dependencies) {} diff --git a/src/common/search-store.ts b/src/common/search-store.ts index ac77e0ec94..6827548bda 100644 --- a/src/common/search-store.ts +++ b/src/common/search-store.ts @@ -29,7 +29,7 @@ export class SearchStore { * @param value Unescaped string */ public static escapeRegex(value?: string): string { - return value ? value.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g, "\\$&") : ""; + return value ? value.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&") : ""; } /** diff --git a/src/common/utils/defineGlobal.ts b/src/common/utils/defineGlobal.ts index eeaea8baa5..1c205a0632 100755 --- a/src/common/utils/defineGlobal.ts +++ b/src/common/utils/defineGlobal.ts @@ -26,7 +26,7 @@ export function defineGlobal(propName: string, descriptor: PropertyDescriptor) { const scope = typeof global !== "undefined" ? global : window; - if (scope.hasOwnProperty(propName)) { + if (Object.prototype.hasOwnProperty.call(scope, propName)) { return; } diff --git a/src/common/utils/iter.ts b/src/common/utils/iter.ts index 6271a05969..9d185ab5d7 100644 --- a/src/common/utils/iter.ts +++ b/src/common/utils/iter.ts @@ -25,6 +25,7 @@ export type Falsey = false | 0 | "" | null | undefined; * Create a new type safe empty Iterable * @returns An `Iterable` that yields 0 items */ +// eslint-disable-next-line require-yield export function* newEmpty(): IterableIterator { return; } diff --git a/src/common/utils/tar.ts b/src/common/utils/tar.ts index d0c67976e9..b3ef949173 100644 --- a/src/common/utils/tar.ts +++ b/src/common/utils/tar.ts @@ -31,12 +31,13 @@ export interface ReadFileFromTarOpts { } export function readFileFromTar({ tarPath, filePath, parseJson }: ReadFileFromTarOpts): Promise { - return new Promise(async (resolve, reject) => { + return new Promise((resolve, reject) => { const fileChunks: Buffer[] = []; - await tar.list({ + tar.list({ file: tarPath, filter: entryPath => path.normalize(entryPath) === filePath, + sync: true, onentry(entry: FileStat) { entry.on("data", chunk => { fileChunks.push(chunk); diff --git a/src/main/helm/helm-repo-manager.ts b/src/main/helm/helm-repo-manager.ts index f8edc12e00..8c8c0c6996 100644 --- a/src/main/helm/helm-repo-manager.ts +++ b/src/main/helm/helm-repo-manager.ts @@ -119,7 +119,9 @@ export class HelmRepoManager extends Singleton { if (typeof parsedConfig === "object" && parsedConfig) { return parsedConfig as HelmRepoConfig; } - } catch { } + } catch { + // ignore error + } return { repositories: [], diff --git a/src/main/initializers/ipc.ts b/src/main/initializers/ipc.ts index e3d4553935..0ad881f36e 100644 --- a/src/main/initializers/ipc.ts +++ b/src/main/initializers/ipc.ts @@ -97,7 +97,9 @@ export function initIpcMainHandlers(electronMenuItems: IComputedValue { diff --git a/src/main/kubectl.ts b/src/main/kubectl.ts index 2ac1831c41..1c2fe98631 100644 --- a/src/main/kubectl.ts +++ b/src/main/kubectl.ts @@ -357,10 +357,10 @@ export class Kubectl { bashScript += `export PATH="${helmPath}:${kubectlPath}:$PATH"\n`; bashScript += "export KUBECONFIG=\"$tempkubeconfig\"\n"; - bashScript += `NO_PROXY=\",\${NO_PROXY:-localhost},\"\n`; - bashScript += `NO_PROXY=\"\${NO_PROXY//,localhost,/,}\"\n`; - bashScript += `NO_PROXY=\"\${NO_PROXY//,127.0.0.1,/,}\"\n`; - bashScript += `NO_PROXY=\"localhost,127.0.0.1\${NO_PROXY%,}\"\n`; + bashScript += `NO_PROXY=",\${NO_PROXY:-localhost},"\n`; + bashScript += `NO_PROXY="\${NO_PROXY//,localhost,/,}"\n`; + bashScript += `NO_PROXY="\${NO_PROXY//,127.0.0.1,/,}"\n`; + bashScript += `NO_PROXY="localhost,127.0.0.1\${NO_PROXY%,}"\n`; bashScript += "export NO_PROXY\n"; bashScript += "unset tempkubeconfig\n"; await fsPromises.writeFile(bashScriptPath, bashScript.toString(), { mode: 0o644 }); @@ -378,18 +378,18 @@ export class Kubectl { zshScript += "test -f \"$OLD_ZDOTDIR/.zshrc\" && . \"$OLD_ZDOTDIR/.zshrc\"\n"; // voodoo to replace any previous occurrences of kubectl path in the PATH - zshScript += `kubectlpath=\"${kubectlPath}"\n`; - zshScript += `helmpath=\"${helmPath}"\n`; + zshScript += `kubectlpath="${kubectlPath}"\n`; + zshScript += `helmpath="${helmPath}"\n`; zshScript += "p=\":$kubectlpath:\"\n"; zshScript += "d=\":$PATH:\"\n"; zshScript += `d=\${d//$p/:}\n`; zshScript += `d=\${d/#:/}\n`; - zshScript += `export PATH=\"$helmpath:$kubectlpath:\${d/%:/}\"\n`; + zshScript += `export PATH="$helmpath:$kubectlpath:\${d/%:/}"\n`; zshScript += "export KUBECONFIG=\"$tempkubeconfig\"\n"; - zshScript += `NO_PROXY=\",\${NO_PROXY:-localhost},\"\n`; - zshScript += `NO_PROXY=\"\${NO_PROXY//,localhost,/,}\"\n`; - zshScript += `NO_PROXY=\"\${NO_PROXY//,127.0.0.1,/,}\"\n`; - zshScript += `NO_PROXY=\"localhost,127.0.0.1\${NO_PROXY%,}\"\n`; + zshScript += `NO_PROXY=",\${NO_PROXY:-localhost},"\n`; + zshScript += `NO_PROXY="\${NO_PROXY//,localhost,/,}"\n`; + zshScript += `NO_PROXY="\${NO_PROXY//,127.0.0.1,/,}"\n`; + zshScript += `NO_PROXY="localhost,127.0.0.1\${NO_PROXY%,}"\n`; zshScript += "export NO_PROXY\n"; zshScript += "unset tempkubeconfig\n"; zshScript += "unset OLD_ZDOTDIR\n"; diff --git a/src/main/shell-session/node-shell-session.ts b/src/main/shell-session/node-shell-session.ts index b865fc411d..0b7d673de9 100644 --- a/src/main/shell-session/node-shell-session.ts +++ b/src/main/shell-session/node-shell-session.ts @@ -72,6 +72,7 @@ export class NodeShellSession extends ShellSession { switch (nodeOs) { default: logger.warn(`[NODE-SHELL-SESSION]: could not determine node OS, falling back with assumption of linux`); + // fallthrough case "linux": args.push("sh", "-c", "((clear && bash) || (clear && ash) || (clear && sh))"); break; diff --git a/src/main/shell-session/shell-session.ts b/src/main/shell-session/shell-session.ts index 677a637cc0..b17ef22689 100644 --- a/src/main/shell-session/shell-session.ts +++ b/src/main/shell-session/shell-session.ts @@ -134,7 +134,9 @@ export abstract class ShellSession { for (const shellProcess of this.processes.values()) { try { process.kill(shellProcess.pid); - } catch {} + } catch { + // ignore error + } } this.processes.clear(); @@ -214,7 +216,9 @@ export abstract class ShellSession { if (stats.isDirectory()) { return potentialCwd; } - } catch {} + } catch { + // ignore error + } } return "."; // Always valid diff --git a/src/migrations/cluster-store/2.0.0-beta.2.ts b/src/migrations/cluster-store/2.0.0-beta.2.ts index e3a89b37d3..8d49aa3ab0 100644 --- a/src/migrations/cluster-store/2.0.0-beta.2.ts +++ b/src/migrations/cluster-store/2.0.0-beta.2.ts @@ -33,7 +33,7 @@ export default { const contextName = value[0]; // Looping all the keys gives out the store internal stuff too... - if (contextName === "__internal__" || value[1].hasOwnProperty("kubeConfig")) continue; + if (contextName === "__internal__" || Object.prototype.hasOwnProperty.call(value[1], "kubeConfig")) continue; store.set(contextName, { kubeConfig: value[1] }); } }, diff --git a/src/migrations/cluster-store/2.6.0-beta.3.ts b/src/migrations/cluster-store/2.6.0-beta.3.ts index a33dd7523f..82f1ac0f88 100644 --- a/src/migrations/cluster-store/2.6.0-beta.3.ts +++ b/src/migrations/cluster-store/2.6.0-beta.3.ts @@ -34,7 +34,7 @@ export default { if (!cluster.kubeConfig) continue; const config = yaml.load(cluster.kubeConfig); - if (!config || typeof config !== "object" || !config.hasOwnProperty("users")) { + if (!config || typeof config !== "object" || !Object.prototype.hasOwnProperty.call(config, "users")) { continue; } diff --git a/src/renderer/components/+config-autoscalers/hpa-details.tsx b/src/renderer/components/+config-autoscalers/hpa-details.tsx index 3e6c74b9bb..78a0457293 100644 --- a/src/renderer/components/+config-autoscalers/hpa-details.tsx +++ b/src/renderer/components/+config-autoscalers/hpa-details.tsx @@ -45,15 +45,17 @@ export class HpaDetails extends React.Component { const renderName = (metric: IHpaMetric) => { switch (metric.type) { - case HpaMetricType.Resource: - const addition = metric.resource.targetAverageUtilization ? <>(as a percentage of request) : ""; + case HpaMetricType.Resource: { + const addition = metric.resource.targetAverageUtilization + ? "(as a percentage of request)" + : ""; return <>Resource {metric.resource.name} on Pods {addition}; - + } case HpaMetricType.Pods: return <>{metric.pods.metricName} on Pods; - case HpaMetricType.Object: + case HpaMetricType.Object: { const { target } = metric.object; const { kind, name } = target; const objectUrl = getDetailsUrl(apiManager.lookupApiLink(target, hpa)); @@ -64,6 +66,7 @@ export class HpaDetails extends React.Component { {kind}/{name} ); + } case HpaMetricType.External: return ( <> diff --git a/src/renderer/components/+extensions/get-base-registry-url/get-base-registry-url.tsx b/src/renderer/components/+extensions/get-base-registry-url/get-base-registry-url.tsx index c811a21319..1e9c582d39 100644 --- a/src/renderer/components/+extensions/get-base-registry-url/get-base-registry-url.tsx +++ b/src/renderer/components/+extensions/get-base-registry-url/get-base-registry-url.tsx @@ -47,8 +47,8 @@ export const getBaseRegistryUrl = ({ getRegistryUrlPreference }: Dependencies) = } catch (error) { Notifications.error(

Failed to get configured registry from .npmrc. Falling back to default registry

); console.warn("[EXTENSIONS]: failed to get configured registry from .npmrc", error); - // fallthrough } + // fallthrough } default: case ExtensionRegistryLocation.DEFAULT: diff --git a/src/renderer/components/file-picker/file-picker.tsx b/src/renderer/components/file-picker/file-picker.tsx index 3661bb2cb2..ed955c4a22 100644 --- a/src/renderer/components/file-picker/file-picker.tsx +++ b/src/renderer/components/file-picker/file-picker.tsx @@ -133,7 +133,8 @@ export class FilePicker extends React.Component { switch (onOverSizeLimit) { case OverSizeLimitStyle.FILTER: return files.filter(file => file.size <= maxSize ); - case OverSizeLimitStyle.REJECT: + + case OverSizeLimitStyle.REJECT: { const firstFileToLarge = files.find(file => file.size > maxSize); if (firstFileToLarge) { @@ -141,6 +142,7 @@ export class FilePicker extends React.Component { } return files; + } } } @@ -156,7 +158,9 @@ export class FilePicker extends React.Component { switch (onOverTotalSizeLimit) { case OverTotalSizeLimitStyle.FILTER_LARGEST: files = _.orderBy(files, ["size"]); - case OverTotalSizeLimitStyle.FILTER_LAST: + + // fallthrough + case OverTotalSizeLimitStyle.FILTER_LAST: { let newTotalSize = totalSize; for (;files.length > 0;) { @@ -168,6 +172,7 @@ export class FilePicker extends React.Component { } return files; + } case OverTotalSizeLimitStyle.REJECT: throw `Total file size to upload is too large. Expected at most ${maxTotalSize}. Found ${totalSize}.`; } diff --git a/src/renderer/components/icon/icon.tsx b/src/renderer/components/icon/icon.tsx index e5258f1a14..f5943ba109 100644 --- a/src/renderer/components/icon/icon.tsx +++ b/src/renderer/components/icon/icon.tsx @@ -73,6 +73,7 @@ export class Icon extends React.PureComponent { switch (evt.nativeEvent.code) { case "Space": + // fallthrough case "Enter": { // eslint-disable-next-line react/no-find-dom-node const icon = findDOMNode(this) as HTMLElement; diff --git a/src/renderer/components/input/input_validators.ts b/src/renderer/components/input/input_validators.ts index 8ea1a7e3c2..36086aca24 100644 --- a/src/renderer/components/input/input_validators.ts +++ b/src/renderer/components/input/input_validators.ts @@ -39,7 +39,7 @@ export const isRequired: InputValidator = { export const isEmail: InputValidator = { condition: ({ type }) => type === "email", message: () => `Wrong email format`, - validate: value => !!value.match(/^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/), + validate: value => !!value.match(/^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/), }; export const isNumber: InputValidator = { diff --git a/src/renderer/components/menu/menu.tsx b/src/renderer/components/menu/menu.tsx index 71ca69c6a8..2ef570a938 100644 --- a/src/renderer/components/menu/menu.tsx +++ b/src/renderer/components/menu/menu.tsx @@ -243,7 +243,9 @@ export class Menu extends React.Component { break; case "Space": - case "Enter": + // fallthrough + + case "Enter": { const focusedItem = this.focusedItem; if (focusedItem) { @@ -251,10 +253,12 @@ export class Menu extends React.Component { evt.preventDefault(); } break; + } case "ArrowUp": this.focusNextItem(true); break; + case "ArrowDown": this.focusNextItem(); break; diff --git a/src/renderer/utils/createStorage.ts b/src/renderer/utils/createStorage.ts index 92c92c8f5a..c282994e61 100755 --- a/src/renderer/utils/createStorage.ts +++ b/src/renderer/utils/createStorage.ts @@ -50,7 +50,9 @@ export function createStorage(key: string, defaultValue: T) { try { storage.data = await fse.readJson(filePath); - } catch {} finally { + } catch { + // ignore error + } finally { if (!isTestEnv) { logger.info(`${logPrefix} loading finished for ${filePath}`); }