🎨 run biome check in vscode

This commit is contained in:
Nate Sesti 2024-04-13 23:58:34 -07:00
parent 4bd76b662d
commit c4e10553ff
18 changed files with 54 additions and 51 deletions

View file

@ -1,4 +1,4 @@
import path from "path";
import path from "node:path";
import { getTsConfigPath, migrate } from "core/util/paths";
import { Telemetry } from "core/util/posthog";
import * as vscode from "vscode";

View file

@ -2,7 +2,7 @@
* If we wanted to run or use another language server from our extension, this is how we would do it.
*/
import * as path from "path";
import * as path from "node:path";
import { type ExtensionContext, extensions, workspace } from "vscode";
import {

View file

@ -37,7 +37,7 @@ export async function getDefinitionsForNode(
): Promise<RangeInFile[]> {
const ranges: RangeInFile[] = [];
switch (node.type) {
case "call_expression":
case "call_expression": {
// function call -> function definition
const defs = await executeGotoProvider(
uri,
@ -47,6 +47,7 @@ export async function getDefinitionsForNode(
);
ranges.push(...defs);
break;
}
case "variable_declarator":
// variable assignment -> variable definition/type
// usages of the var that appear after the declaration

View file

@ -28,14 +28,14 @@ export function registerDebugTracker(
updateThreads();
},
async onDidSendMessage(message: any) {
if (message.type == "event") {
if (message.type === "event") {
switch (message.event) {
case "continued":
case "stopped":
if (typeof message.body.threadId !== "undefined")
threadStopped.set(
Number(message.body.threadId),
message.event == "stopped",
message.event === "stopped",
);
if (message.body.allThreadsStopped)
@ -52,9 +52,9 @@ export function registerDebugTracker(
break;
case "thread":
if (message.body.reason == "exited")
if (message.body.reason === "exited")
threadStopped.delete(Number(message.body.threadId));
else if (message.body.reason == "started")
else if (message.body.reason === "started")
threadStopped.set(Number(message.body.threadId), false);
// somehow the threadId does not respect the specification in my vscodium (debugging C++)
// expecting a number but got a string instead

View file

@ -1,6 +1,6 @@
import * as fs from "fs";
import * as os from "os";
import * as path from "path";
import * as fs from "node:fs";
import * as os from "node:os";
import * as path from "node:path";
import { devDataPath } from "core/util/paths";
import * as vscode from "vscode";
import { getMetaKeyLabel, getPlatform } from "../util/util";

View file

@ -148,10 +148,10 @@ export class VerticalPerLineDiffHandler {
lineCount,
this.editor.document.lineAt(lineCount - 1).text.length,
),
"\n" + text,
`\n${text}`,
);
} else {
editBuilder.insert(new vscode.Position(index, 0), text + "\n");
editBuilder.insert(new vscode.Position(index, 0), `${text}\n`);
}
},
{

View file

@ -1,5 +1,5 @@
import * as os from "os";
import * as path from "path";
import * as os from "node:os";
import * as path from "node:path";
import * as vscode from "vscode";
import { DIFF_DIRECTORY, type DiffManager } from "../diff/horizontal";
import type { VerticalDiffCodeLens } from "../diff/verticalPerLine/manager";
@ -215,7 +215,7 @@ class ConfigPyCodeLensProvider implements vscode.CodeLensProvider {
);
codeLenses.push(
new vscode.CodeLens(range, {
title: `✏️ Edit in UI`,
title: "✏️ Edit in UI",
command: "continue.openSettingsUI",
}),
);
@ -234,7 +234,7 @@ const actions: TutorialCodeLensItems[] = [
lineIncludes: "Step 2: Use the keyboard shortcut cmd/ctrl + M",
commands: [
{
title: `Do it for me`,
title: "Do it for me",
command: "continue.focusContinueInput",
},
],
@ -276,9 +276,10 @@ const actions: TutorialCodeLensItems[] = [
title: "Run the file",
command: "continue.sendToTerminal",
arguments: [
"python " +
path.join(getExtensionUri().fsPath, "continue_tutorial.py") +
"\n",
`python ${path.join(
getExtensionUri().fsPath,
"continue_tutorial.py",
)}\n`,
],
},
],
@ -362,7 +363,7 @@ class TutorialCodeLensProvider implements vscode.CodeLensProvider {
});
codeLenses.push(
new vscode.CodeLens(range, {
title: `Begin Section`,
title: "Begin Section",
command: "continue.foldAndUnfold",
arguments: [linesToFold, [lineOfRegion, lineOfRegion + 1]],
}),

View file

@ -90,7 +90,7 @@ export function rerenderDecorations(editorUri: string) {
let newSels: vscode.Range[] = [];
for (let i = 0; i < suggestions.length; i++) {
const suggestion = suggestions[i];
if (typeof idx != "undefined" && idx === i) {
if (typeof idx !== "undefined" && idx === i) {
if (suggestion.newSelected) {
olds.push(suggestion.oldRange);
newSels.push(suggestion.newRange);
@ -194,7 +194,7 @@ function selectSuggestion(
const [suggestion] = suggestions.splice(idx, 1);
var rangeToDelete: vscode.Range;
let rangeToDelete: vscode.Range;
switch (accept) {
case "old":
rangeToDelete = suggestion.newRange;

View file

@ -1,6 +1,6 @@
/* Terminal emulator - commented because node-pty is causing problems. */
import * as os from "os";
import * as os from "node:os";
import stripAnsi from "strip-ansi";
import * as vscode from "vscode";
import { longestCommonSubsequence } from "../util/lcs";
@ -225,7 +225,7 @@ export class CapturedTerminal {
this.seenClear = false;
this.commandPromptString = commandPromptString;
console.log(
"Found command prompt string: " + this.commandPromptString,
`Found command prompt string: ${this.commandPromptString}`,
);
if (this.resolveMeWhenCommandPromptStringFound) {
this.resolveMeWhenCommandPromptStringFound(undefined);

View file

@ -1,4 +1,4 @@
import * as path from "path";
import * as path from "node:path";
import * as glob from "glob";
import Mocha from "mocha";

View file

@ -1,4 +1,4 @@
import * as path from "path";
import * as path from "node:path";
import { runTests } from "@vscode/test-electron";
async function main() {

View file

@ -1,4 +1,4 @@
import * as assert from "assert";
import * as assert from "node:assert";
import { describe, test } from "mocha";
import * as vscode from "vscode";
import { vscodeExtensionPromise } from "../../activation/activate";

View file

@ -1,5 +1,5 @@
import * as fs from "fs";
import * as path from "path";
import * as fs from "node:fs";
import * as path from "node:path";
import mergeJson from "core/util/merge";
import { convertTheme } from "monaco-vscode-textmate-theme-converter/lib/cjs";
import * as vscode from "vscode";
@ -57,7 +57,7 @@ export function getTheme() {
}
if (currentTheme === undefined && builtinThemes[colorTheme]) {
const filename = builtinThemes[colorTheme] + ".json";
const filename = `${builtinThemes[colorTheme]}.json`;
currentTheme = fs
.readFileSync(
path.join(getExtensionUri().fsPath, "builtin-themes", filename),

View file

@ -1,4 +1,4 @@
import path from "path";
import path from "node:path";
import type { FileEdit, RangeInFile, Thread } from "core";
import { defaultIgnoreFile } from "core/indexing/ignore";
import * as vscode from "vscode";
@ -18,8 +18,8 @@ import {
uriFromFilePath,
} from "./vscode";
const util = require("util");
const asyncExec = util.promisify(require("child_process").exec);
const util = require("node:util");
const asyncExec = util.promisify(require("node:child_process").exec);
export class VsCodeIdeUtils {
visibleMessages: Set<string> = new Set();
@ -331,13 +331,11 @@ export class VsCodeIdeUtils {
await vscode.workspace.fs.readFile(vscode.Uri.file(filepath)),
);
const lines = contents.split("\n");
return (
lines.slice(range.start.line, range.end.line).join("\n") +
"\n" +
lines[
range.end.line < lines.length - 1 ? range.end.line : lines.length - 1
].slice(0, range.end.character)
);
return `${lines
.slice(range.start.line, range.end.line)
.join("\n")}\n${lines[
range.end.line < lines.length - 1 ? range.end.line : lines.length - 1
].slice(0, range.end.character)}`;
}
async getTerminalContents(commands = -1): Promise<string> {

View file

@ -1,6 +1,6 @@
import * as path from "path";
import { defaultIgnoreDir, defaultIgnoreFile } from "core/indexing/ignore";
import ignore from "ignore";
import * as path from "node:path";
import * as vscode from "vscode";
import { uriFromFilePath } from "./vscode";
@ -70,7 +70,7 @@ export async function* traverseDirectory(
const allIgnorePatterns = [...gitIgnorePatterns, ...ignorePatterns].map(
(pattern) => {
if (!pattern.slice(0, -1).includes("/")) {
return "**/" + pattern;
return `**/${pattern}`;
}
return pattern;
},
@ -90,7 +90,7 @@ export async function* traverseDirectory(
for (const ignorePattern of allIgnorePatterns) {
const [first, rest, leadingWildcard] = splitGlob(ignorePattern);
if (leadingWildcard) {
wildcardPatterns.push("**/" + first + (rest ? "/" + rest : ""));
wildcardPatterns.push(`**/${first}${rest ? `/${rest}` : ""}`);
}
if (first) {
if (subDirIgnorePatterns[first] === undefined) {
@ -107,7 +107,7 @@ export async function* traverseDirectory(
}
// Recurse if not ignored
if (!(ig.ignores(dir + "/") || ig.ignores(dir))) {
if (!(ig.ignores(`${dir}/`) || ig.ignores(dir))) {
// For patterns who can potentially match items of this subdir, strip the subdir from the start
const keepPatterns = [...wildcardPatterns];
for (const [startPattern, subDirPatterns] of entries) {

View file

@ -1,4 +1,4 @@
const os = require("os");
const os = require("node:os");
import * as vscode from "vscode";
function charIsEscapedAtIndex(index: number, str: string): boolean {

View file

@ -1,4 +1,4 @@
import * as path from "path";
import * as path from "node:path";
import { machineIdSync } from "node-machine-id";
import * as vscode from "vscode";

View file

@ -1,5 +1,5 @@
import fs from "fs";
import path from "path";
import fs from "node:fs";
import path from "node:path";
import type { ContextItemId, IDE } from "core";
import type { ConfigHandler } from "core/config/handler";
import {
@ -82,7 +82,7 @@ export class VsCodeWebviewProtocol {
this._webviewListener = this._webview.onDidReceiveMessage(async (msg) => {
if (!msg.messageType || !msg.messageId) {
throw new Error("Invalid webview protocol msg: " + JSON.stringify(msg));
throw new Error(`Invalid webview protocol msg: ${JSON.stringify(msg)}`);
}
const respond = (message: any) =>
@ -107,8 +107,11 @@ export class VsCodeWebviewProtocol {
}
} catch (e: any) {
console.error(
"Error handling webview message: " +
JSON.stringify({ msg }, null, 2),
`Error handling webview message: ${JSON.stringify(
{ msg },
null,
2,
)}`,
);
let message = e.message;