From 9d3f60d44ed90bcb581b590067b42d92e7cdecad Mon Sep 17 00:00:00 2001 From: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> Date: Mon, 18 Sep 2023 21:30:17 -0700 Subject: [PATCH] Prettier --- packages/bun-vscode/scripts/build.mjs | 2 +- packages/bun-vscode/src/features/debug.ts | 4 +- .../bun-vscode/src/features/lockfile.style.ts | 48 +++++++++---------- .../src/features/tasks/package.json.ts | 2 +- test/js/bun/test/expect.test.js | 6 +-- test/js/node/watch/fs.watch.test.ts | 8 ++-- 6 files changed, 33 insertions(+), 37 deletions(-) diff --git a/packages/bun-vscode/scripts/build.mjs b/packages/bun-vscode/scripts/build.mjs index 5db5772814..347a59631d 100644 --- a/packages/bun-vscode/scripts/build.mjs +++ b/packages/bun-vscode/scripts/build.mjs @@ -12,7 +12,7 @@ buildSync({ external: ["vscode"], platform: "node", format: "cjs", - + // The following settings are required to allow for extension debugging minify: false, sourcemap: true, diff --git a/packages/bun-vscode/src/features/debug.ts b/packages/bun-vscode/src/features/debug.ts index d5522c493d..caa0c93783 100644 --- a/packages/bun-vscode/src/features/debug.ts +++ b/packages/bun-vscode/src/features/debug.ts @@ -13,7 +13,6 @@ export const DEBUG_CONFIGURATION: vscode.DebugConfiguration = { cwd: "${workspaceFolder}", stopOnEntry: false, watchMode: false, - }; export const RUN_CONFIGURATION: vscode.DebugConfiguration = { @@ -83,7 +82,7 @@ function debugFileCommand(resource?: vscode.Uri) { } function injectDebugTerminal(terminal: vscode.Terminal): void { - if (!getConfig("debugTerminal.enabled")) return + if (!getConfig("debugTerminal.enabled")) return; const { name, creationOptions } = terminal; if (name !== "JavaScript Debug Terminal") { @@ -246,4 +245,3 @@ function getRuntime(scope?: vscode.ConfigurationScope): string { function getConfig(path: string, scope?: vscode.ConfigurationScope) { return vscode.workspace.getConfiguration("bun", scope).get(path); } - \ No newline at end of file diff --git a/packages/bun-vscode/src/features/lockfile.style.ts b/packages/bun-vscode/src/features/lockfile.style.ts index 76af4801ba..7c46504975 100644 --- a/packages/bun-vscode/src/features/lockfile.style.ts +++ b/packages/bun-vscode/src/features/lockfile.style.ts @@ -1,37 +1,35 @@ export function styleLockfile(preview: string) { - // Match all lines that don't start with a whitespace character - const lines = preview.split(/\n(?!\s)/); + // Match all lines that don't start with a whitespace character + const lines = preview.split(/\n(?!\s)/); - return lines.map(styleSection).join('\n') + return lines.map(styleSection).join("\n"); } function styleSection(section: string) { - const lines = section.split(/\n/); + const lines = section.split(/\n/); - return lines.map(styleLine).join('\n') + return lines.map(styleLine).join("\n"); } function styleLine(line: string) { - if(line.startsWith('#')){ - return `${line}` - } + if (line.startsWith("#")) { + return `${line}`; + } - const parts = line.trim().split(' ') - if(line.startsWith(' ')){ - return `    ${parts[0]} ${parts[1]}` - } - if(line.startsWith(' ')){ - const leftPart = `  ${parts[0]} ` + const parts = line.trim().split(" "); + if (line.startsWith(" ")) { + return `    ${parts[0]} ${parts[1]}`; + } + if (line.startsWith(" ")) { + const leftPart = `  ${parts[0]} `; - if(parts.length === 1) - return `${leftPart}` - - if(parts[1].startsWith('"http://') || parts[1].startsWith('"https://')) - return `${leftPart}${parts[1]}` - if(parts[1].startsWith('"')) - return `${leftPart}${parts[1]}` - - return `${leftPart}${parts[1]}` - } - return `${line} ` + if (parts.length === 1) return `${leftPart}`; + + if (parts[1].startsWith('"http://') || parts[1].startsWith('"https://')) + return `${leftPart}${parts[1]}`; + if (parts[1].startsWith('"')) return `${leftPart}${parts[1]}`; + + return `${leftPart}${parts[1]}`; + } + return `${line} `; } diff --git a/packages/bun-vscode/src/features/tasks/package.json.ts b/packages/bun-vscode/src/features/tasks/package.json.ts index f9a24937d9..764ea97120 100644 --- a/packages/bun-vscode/src/features/tasks/package.json.ts +++ b/packages/bun-vscode/src/features/tasks/package.json.ts @@ -189,7 +189,7 @@ function registerHoverProvider(context: vscode.ExtensionContext) { return; } - const terminal = vscode.window.createTerminal({name}); + const terminal = vscode.window.createTerminal({ name }); terminal.show(); terminal.sendText(`bun ${script}`); }), diff --git a/test/js/bun/test/expect.test.js b/test/js/bun/test/expect.test.js index 4b9e5ec22f..b6e312022e 100644 --- a/test/js/bun/test/expect.test.js +++ b/test/js/bun/test/expect.test.js @@ -2636,9 +2636,9 @@ describe("expect()", () => { expect({ a: [1, 2, 3] }).toMatchObject({ a: expect.arrayContaining([1, 2]) }); expect({ a: [1, 2, 3] }).not.toMatchObject({ a: expect.arrayContaining([4]) }); - expect({ a: ['hello', 'world'] }).toMatchObject({ a: expect.arrayContaining([]) }); - expect({ a: ['hello', 'world'] }).toMatchObject({ a: expect.arrayContaining(['world']) }); - expect({ a: ['hello', 'world'] }).not.toMatchObject({ a: expect.arrayContaining(['hello', 'mars']) }); + expect({ a: ["hello", "world"] }).toMatchObject({ a: expect.arrayContaining([]) }); + expect({ a: ["hello", "world"] }).toMatchObject({ a: expect.arrayContaining(["world"]) }); + expect({ a: ["hello", "world"] }).not.toMatchObject({ a: expect.arrayContaining(["hello", "mars"]) }); expect([]).toMatchObject([]); expect([]).toMatchObject({}); diff --git a/test/js/node/watch/fs.watch.test.ts b/test/js/node/watch/fs.watch.test.ts index 10fc754d2c..787ce413ce 100644 --- a/test/js/node/watch/fs.watch.test.ts +++ b/test/js/node/watch/fs.watch.test.ts @@ -67,7 +67,7 @@ describe("fs.watch", () => { const root = path.join(testDir, "add-directory"); try { fs.mkdirSync(root); - } catch { } + } catch {} let err: Error | undefined = undefined; const watcher = fs.watch(root, { signal: AbortSignal.timeout(3000) }); watcher.on("change", (event, filename) => { @@ -102,7 +102,7 @@ describe("fs.watch", () => { const root = path.join(testDir, "add-subdirectory"); try { fs.mkdirSync(root); - } catch { } + } catch {} const subfolder = path.join(root, "subfolder"); fs.mkdirSync(subfolder); const watcher = fs.watch(root, { recursive: true, signal: AbortSignal.timeout(3000) }); @@ -438,7 +438,7 @@ describe("fs.promises.watch", () => { const root = path.join(testDir, "add-promise-directory"); try { fs.mkdirSync(root); - } catch { } + } catch {} let success = false; let err: Error | undefined = undefined; try { @@ -480,7 +480,7 @@ describe("fs.promises.watch", () => { const root = path.join(testDir, "add-promise-subdirectory"); try { fs.mkdirSync(root); - } catch { } + } catch {} const subfolder = path.join(root, "subfolder"); fs.mkdirSync(subfolder); let success = false;