biome: Enable lint to check for missing await statements (#8305)

This commit is contained in:
Simon Hausmann 2025-04-29 14:57:52 +02:00 committed by GitHub
parent ab572fc6de
commit dbe4a684c6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
13 changed files with 37 additions and 39 deletions

View file

@ -36,10 +36,10 @@ test.serial("merged event loops with networking", async (t) => {
console.log(`server ready at ${host}:${port}`);
(fetch as any)(`http://${host}:${port}/`)
.then(async (response) => {
.then((response: Response) => {
return response.text();
})
.then((text) => {
.then((text: string) => {
received_response = text;
//console.log("received ", text);
quitEventLoop();

View file

@ -16,7 +16,9 @@
"editors/vscode/out/**"
]
},
"organizeImports": { "enabled": false },
"organizeImports": {
"enabled": false
},
"linter": {
"enabled": true,
"ignore": ["api/node/docs/assets/**", "**/dist/**"],
@ -36,7 +38,8 @@
"suspicious": {
"noDoubleEquals": "error",
"noRedundantUseStrict": "warn",
"noImplicitAnyLet": "error"
"noImplicitAnyLet": "error",
"useAwait": "error"
}
}
},

View file

@ -25,7 +25,7 @@ function sideBorder() {
}
`,
hooks: {
postprocessRenderedBlock: async (context) => {
postprocessRenderedBlock: (context) => {
if (
context.renderData.blockAst.children[1].properties
.dataLanguage !== "slint"
@ -80,7 +80,7 @@ function languageLabel() {
}
`,
hooks: {
postprocessRenderedBlock: async (context) => {
postprocessRenderedBlock: (context) => {
const language =
context.renderData.blockAst.children[1].properties
.dataLanguage;
@ -141,7 +141,7 @@ function workersPlaygroundButton() {
}
`,
hooks: {
postprocessRenderedBlock: async (context) => {
postprocessRenderedBlock: (context) => {
if (!context.codeBlock.meta.includes("playground")) {
return;
}

View file

@ -158,7 +158,7 @@ async function updateWasmPreview(previewContainer, content) {
// Wrap updateWasmPreview in a debounce function (500ms delay)
const debouncedUpdateWasmPreview = debounce(updateWasmPreview, 500);
async function initializePreviewContainers(previewContainer, _content) {
function initializePreviewContainers(previewContainer, _content) {
const canvas_id = "canvas_" + Math.random().toString(36).substring(2, 9);
const canvas = document.createElement("canvas");
canvas.id = canvas_id;
@ -260,7 +260,7 @@ window.initCodeMirror = function (editorDiv, language, content) {
previewContainer.classList.add("preview-container");
editorDiv.classList.add("show-preview");
extensions.push(
EditorView.updateListener.of(async (editor) => {
EditorView.updateListener.of((editor) => {
if (editor.docChanged) {
const newContent = editor.state.doc.toString();
debouncedUpdateWasmPreview(
@ -289,7 +289,7 @@ window.initCodeMirror = function (editorDiv, language, content) {
loadSlintWasmInterpreter(editor)
.then(async () => {
initializePreviewContainers(previewContainer, content);
updateWasmPreview(previewContainer, content);
await updateWasmPreview(previewContainer, content);
})
.catch((error) => {
console.error("Error loading Slint WASM interpreter:", error);
@ -297,7 +297,7 @@ window.initCodeMirror = function (editorDiv, language, content) {
}
};
document.addEventListener("DOMContentLoaded", async function () {
document.addEventListener("DOMContentLoaded", () => {
// Find all the divs that need a CodeMirror editor
document
.querySelectorAll(".codemirror-editor")

View file

@ -85,7 +85,7 @@ slint_init(slint_wasm_data).then((_) => {
});
connection.onDidChangeConfiguration(async (_param: unknown) => {
the_lsp.reload_config();
await the_lsp.reload_config();
});
// Listen on the connection

View file

@ -154,7 +154,7 @@ export function activate(
vscode.workspace.onDidChangeConfiguration(async (ev) => {
if (ev.affectsConfiguration("slint")) {
client.client?.sendNotification(
await client.client?.sendNotification(
"workspace/didChangeConfiguration",
{ settings: "" },
);
@ -171,7 +171,7 @@ export function activate(
return;
}
lsp_commands.showPreview(ae.document.uri.toString(), "");
await lsp_commands.showPreview(ae.document.uri.toString(), "");
}),
);
@ -190,7 +190,7 @@ export function activate(
vscode.workspace.onDidChangeConfiguration(async (ev) => {
if (ev.affectsConfiguration("slint")) {
client.client?.sendNotification(
await client.client?.sendNotification(
"workspace/didChangeConfiguration",
{ settings: "" },
);

View file

@ -18,9 +18,6 @@ import * as vscode from "vscode";
//
// has the side effect of going around our middleware.
export async function showPreview(
url: LspURI,
component: string,
): Promise<unknown> {
export function showPreview(url: LspURI, component: string): Thenable<unknown> {
return vscode.commands.executeCommand("slint/showPreview", url, component);
}

View file

@ -48,7 +48,7 @@ export function initClientForPreview(
}
}
previewPanel?.webview.postMessage({
await previewPanel?.webview.postMessage({
command: "slint/lsp_to_preview",
params: message,
});
@ -190,12 +190,10 @@ export class PreviewSerializer implements vscode.WebviewPanelSerializer {
this.context = context;
}
async deserializeWebviewPanel(
webviewPanel: vscode.WebviewPanel,
_state: any,
) {
deserializeWebviewPanel(webviewPanel: vscode.WebviewPanel, _state: any) {
previewPanel = initPreviewPanel(this.context, webviewPanel);
//// How can we load this state? We can not query the necessary data...
return Promise.resolve();
}
}
@ -225,7 +223,7 @@ function initPreviewPanel(
panel.iconPath = Uri.joinPath(context.extensionUri, "slint-file-icon.svg");
// we will get a preview_ready when the html is loaded and message are ready to be sent
panel.webview.onDidReceiveMessage(
async (message) => {
(message) => {
switch (message.command) {
case "map_url":
map_url(panel.webview, message.url);

View file

@ -134,7 +134,7 @@ const variableMonitoring: {
// Keep the DEBOUNCE_INTERVAL as a constant
const DEBOUNCE_INTERVAL = 3000; // 3 seconds
listenTS("monitorVariableChanges", async () => {
listenTS("monitorVariableChanges", () => {
figma.ui.postMessage({
type: "variableMonitoringActive", // Keep this confirmation
timestamp: Date.now(),

View file

@ -284,7 +284,7 @@ export async function getBorderWidthAndColor(
return properties.length > 0 ? properties : null;
}
export async function getBrush(fill: {
export function getBrush(fill: {
type: string;
opacity: number;
color?: { r: number; g: number; b: number };
@ -293,7 +293,7 @@ export async function getBrush(fill: {
position: number;
}>;
gradientTransform?: number[][];
}): Promise<string | null> {
}): string | null {
switch (fill.type) {
case "SOLID": {
if (!fill.color) {
@ -574,7 +574,7 @@ export async function generateRectangleSnippet(
await getVariablePathString(boundVarId);
}
if (!fillValue) {
fillValue = await getBrush(firstFill);
fillValue = getBrush(firstFill);
}
if (fillValue) {
properties.push(
@ -582,7 +582,7 @@ export async function generateRectangleSnippet(
);
}
} else {
const brush = await getBrush(firstFill);
const brush = getBrush(firstFill);
if (brush) {
properties.push(
`${indentation}background: ${brush};`,

View file

@ -2,7 +2,7 @@
// SPDX-License-Identifier: MIT
import { dispatchTS } from "./bolt-utils.js";
export async function writeTextToClipboard(str: string) {
export function writeTextToClipboard(str: string) {
const prevActive = document.activeElement;
const textArea = document.createElement("textarea");

View file

@ -415,9 +415,9 @@ export class EditorWidget extends Widget {
),
);
} else if (load_url) {
return this.project_from_url(load_url);
return await this.project_from_url(load_url);
} else {
return this.set_demo(load_demo ?? "");
return await this.set_demo(load_demo ?? "");
}
}
@ -486,7 +486,7 @@ export class EditorWidget extends Widget {
return Promise.resolve(pane.editor);
}
public async map_url(url_: string): Promise<string | undefined> {
public map_url(url_: string): Promise<string | undefined> {
const js_url = new URL(url_);
const absolute_uri = monaco.Uri.parse(js_url.toString());
@ -499,7 +499,7 @@ export class EditorWidget extends Widget {
this.#extra_file_urls[file] = mapped_string;
}
return mapped_string;
return Promise.resolve(mapped_string);
}
private get current_editor_pane(): EditorPaneWidget {
@ -590,7 +590,7 @@ export class EditorWidget extends Widget {
return true;
}
public async set_demo(location: string): Promise<monaco.Uri | null> {
public set_demo(location: string): Promise<monaco.Uri | null> {
if (location) {
const default_tag = "XXXX_DEFAULT_TAG_XXXX";
let tag = default_tag.startsWith("XXXX_DEFAULT_TAG_")

View file

@ -176,7 +176,7 @@ export async function export_to_gist(
}
const extras: { [path: string]: string } = {};
Object.entries(editor.extra_files).forEach(async ([f, u]) => {
Object.entries(editor.extra_files).forEach(([f, u]) => {
extras[f.slice(1)] = u;
});
@ -333,7 +333,7 @@ async function _process_gist_url(
return Promise.resolve([url.toString(), null, null]);
}
async function _process_github_url(url: URL): Promise<[string, null, null]> {
function _process_github_url(url: URL): Promise<[string, null, null]> {
const path = url.pathname.split("/");
if (path[3] === "blob") {
@ -349,7 +349,7 @@ async function _process_github_url(url: URL): Promise<[string, null, null]> {
}
}
export async function open_url(
export function open_url(
url_string: string,
): Promise<[string | null, string | null, UrlMapper | null]> {
try {