From 715d48c0375f2cd9c95e604f51c386de80dc8881 Mon Sep 17 00:00:00 2001 From: Lais Portugal Date: Wed, 24 Jul 2024 15:37:12 +0100 Subject: [PATCH] Fix lint issues --- packages/studio-base/src/panels/Plot/subscription.ts | 4 ++-- packages/studio-base/src/players/UserScriptPlayer/index.ts | 2 +- packages/studio-base/src/util/VirtualLRUBuffer.ts | 6 +----- packages/studio-base/src/util/layout.ts | 4 ++-- 4 files changed, 6 insertions(+), 10 deletions(-) diff --git a/packages/studio-base/src/panels/Plot/subscription.ts b/packages/studio-base/src/panels/Plot/subscription.ts index a7b3c661b2..ae113ffebc 100644 --- a/packages/studio-base/src/panels/Plot/subscription.ts +++ b/packages/studio-base/src/panels/Plot/subscription.ts @@ -2,7 +2,7 @@ // License, v2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/ -import type { MessagePathPart, MessagePath } from "@foxglove/message-path"; +import type { MessagePath, MessagePathPart } from "@foxglove/message-path"; import type { Immutable } from "@foxglove/studio"; import type { SubscribePayload, @@ -18,7 +18,7 @@ export function pathToSubscribePayload( const { messagePath: parts, topicName: topic } = path; const firstField = parts.find(typeIsName); - if (firstField == undefined || firstField.type !== "name" || firstField.name.length === 0) { + if (firstField == undefined || firstField.name.length === 0) { return undefined; } diff --git a/packages/studio-base/src/players/UserScriptPlayer/index.ts b/packages/studio-base/src/players/UserScriptPlayer/index.ts index f39208dbdf..8a36d6a5f9 100644 --- a/packages/studio-base/src/players/UserScriptPlayer/index.ts +++ b/packages/studio-base/src/players/UserScriptPlayer/index.ts @@ -326,7 +326,7 @@ export default class UserScriptPlayer implements Player { if (!messagesByTopic[outTopic]) { messagesByTopic[outTopic] = []; } - messagesByTopic[outTopic]?.push(outputMessage); + messagesByTopic[outTopic].push(outputMessage); } } } diff --git a/packages/studio-base/src/util/VirtualLRUBuffer.ts b/packages/studio-base/src/util/VirtualLRUBuffer.ts index 59005b88ad..9adac16580 100644 --- a/packages/studio-base/src/util/VirtualLRUBuffer.ts +++ b/packages/studio-base/src/util/VirtualLRUBuffer.ts @@ -157,11 +157,7 @@ export default class VirtualLRUBuffer { ); } } - const block = this.#blocks[index]; - if (!block) { - throw new Error("invariant violation - no block at index"); - } - return block; + return this.#blocks[index]; } // For a given position, calculate `blockIndex` (which block is this position in); diff --git a/packages/studio-base/src/util/layout.ts b/packages/studio-base/src/util/layout.ts index 5d818f1520..61270c835d 100644 --- a/packages/studio-base/src/util/layout.ts +++ b/packages/studio-base/src/util/layout.ts @@ -119,8 +119,8 @@ function getLayoutWithNewPanelIds( for (const key in layout) { if (typeof layout[key] === "object" && !Array.isArray(layout[key])) { newLayout[key] = getLayoutWithNewPanelIds(layout[key] as IndexableMosaic, panelIdMap); - } else if (typeof layout[key] === "string" && panelIdMap[layout[key] as string] != undefined) { - newLayout[key] = panelIdMap[layout[key] as string]; + } else if (typeof layout[key] === "string" && panelIdMap[layout[key]] != undefined) { + newLayout[key] = panelIdMap[layout[key]]; } else { newLayout[key] = layout[key]; }