diff --git a/oxlint.config.mts b/oxlint.config.mts index ac3d1d3637d..a23119805e2 100644 --- a/oxlint.config.mts +++ b/oxlint.config.mts @@ -2,10 +2,6 @@ import type { OxlintConfig } from "oxlint"; import { defineConfig } from "oxlint"; const disabledRules = [ - // Temporarily disabled - "eslint/prefer-named-capture-group", - "unicorn/import-style", - "eslint/arrow-body-style", "eslint/capitalized-comments", "eslint/class-methods-use-this", @@ -33,6 +29,7 @@ const disabledRules = [ "eslint/no-use-before-define", "eslint/no-void", "eslint/prefer-destructuring", + "eslint/prefer-named-capture-group", "eslint/sort-imports", "eslint/sort-keys", "eslint/sort-vars", diff --git a/packages/app-talonjs/src/extension.ts b/packages/app-talonjs/src/extension.ts index 2dda01bc8a3..fbe93de784b 100644 --- a/packages/app-talonjs/src/extension.ts +++ b/packages/app-talonjs/src/extension.ts @@ -1,4 +1,4 @@ -import * as talon from "talon"; +import talon from "talon"; import type { RunMode } from "@cursorless/lib-common"; import { activate as activateCore } from "@cursorless/lib-talonjs-core"; diff --git a/packages/app-vscode/src/InstallationDependencies.ts b/packages/app-vscode/src/InstallationDependencies.ts index 6978f9e2fa3..4b53826b737 100644 --- a/packages/app-vscode/src/InstallationDependencies.ts +++ b/packages/app-vscode/src/InstallationDependencies.ts @@ -1,8 +1,8 @@ -import * as fs from "node:fs"; -import * as os from "node:os"; -import * as path from "node:path"; +import fs from "node:fs"; +import os from "node:os"; +import path from "node:path"; import glob from "fast-glob"; -import * as vscode from "vscode"; +import vscode from "vscode"; import { isWindows } from "@cursorless/lib-node-common"; import { COMMAND_SERVER_EXTENSION_ID } from "@cursorless/lib-vscode-common"; diff --git a/packages/app-vscode/src/ReleaseNotes.test.ts b/packages/app-vscode/src/ReleaseNotes.test.ts index 81f30941f1a..ce971fd1b6f 100644 --- a/packages/app-vscode/src/ReleaseNotes.test.ts +++ b/packages/app-vscode/src/ReleaseNotes.test.ts @@ -1,4 +1,4 @@ -import * as sinon from "sinon"; +import { fake, restore, assert, match } from "sinon"; import type { ExtensionContext, Uri } from "vscode"; import type { MessageType, Messages } from "@cursorless/lib-common"; import { asyncSafety } from "@cursorless/lib-common"; @@ -154,7 +154,7 @@ const testCases: TestCase[] = [ suite("release notes", () => { teardown(() => { - sinon.restore(); + restore(); }); for (const { input, expectedOutput } of testCases) { @@ -192,9 +192,9 @@ async function runTest(input: Input, expectedOutput: Output) { await new ReleaseNotes(vscodeApi, extensionContext, messages).maybeShow(); if (expectedOutput.storedVersion === false) { - sinon.assert.notCalled(update); + assert.notCalled(update); } else { - sinon.assert.calledOnceWithExactly( + assert.calledOnceWithExactly( update, VERSION_KEY, expectedOutput.storedVersion, @@ -202,26 +202,26 @@ async function runTest(input: Input, expectedOutput: Output) { } if (expectedOutput.showedMessage) { - sinon.assert.calledOnceWithExactly( + assert.calledOnceWithExactly( showMessage, - sinon.match.any, + match.any, "releaseNotes", - sinon.match.any, - sinon.match.any, + match.any, + match.any, ); if (expectedOutput.openedUrl) { - sinon.assert.calledOnce(openExternal); + assert.calledOnce(openExternal); } else { - sinon.assert.notCalled(openExternal); + assert.notCalled(openExternal); } } else { - sinon.assert.notCalled(showMessage); + assert.notCalled(showMessage); } } function getFakes(input: Input) { - const openExternal = sinon.fake.resolves<[Uri], Promise>(true); + const openExternal = fake.resolves<[Uri], Promise>(true); const vscodeApi = { window: { state: { @@ -233,7 +233,7 @@ function getFakes(input: Input) { }, } as unknown as VscodeApi; - const update = sinon.fake<[string, string], Promise>(); + const update = fake<[string, string], Promise>(); const extensionContext = { globalState: { get() { @@ -248,7 +248,7 @@ function getFakes(input: Input) { }, } as unknown as ExtensionContext; - const showMessage = sinon.fake.resolves< + const showMessage = fake.resolves< [MessageType, string, string, ...string[]], Promise >(input.pressedButton ? WHATS_NEW : undefined); diff --git a/packages/app-vscode/src/ReleaseNotes.ts b/packages/app-vscode/src/ReleaseNotes.ts index 656786018f6..cb064e00626 100644 --- a/packages/app-vscode/src/ReleaseNotes.ts +++ b/packages/app-vscode/src/ReleaseNotes.ts @@ -1,4 +1,4 @@ -import * as semver from "semver"; +import semver from "semver"; import type { ExtensionContext } from "vscode"; import { URI } from "vscode-uri"; import type { Messages } from "@cursorless/lib-common"; diff --git a/packages/app-vscode/src/StatusBarItem.ts b/packages/app-vscode/src/StatusBarItem.ts index 59dd3dc383e..b101d343867 100644 --- a/packages/app-vscode/src/StatusBarItem.ts +++ b/packages/app-vscode/src/StatusBarItem.ts @@ -1,4 +1,4 @@ -import * as vscode from "vscode"; +import vscode from "vscode"; const DEFAULT_TEXT = "$(cursorless-icon) Cursorless"; diff --git a/packages/app-vscode/src/VscodeSnippets.ts b/packages/app-vscode/src/VscodeSnippets.ts index cfa5450f7ae..7a25b3b764a 100644 --- a/packages/app-vscode/src/VscodeSnippets.ts +++ b/packages/app-vscode/src/VscodeSnippets.ts @@ -1,5 +1,5 @@ import { open } from "node:fs/promises"; -import { join } from "node:path"; +import path from "node:path"; import type { IDE, TextEditor } from "@cursorless/lib-common"; import type { Snippets } from "@cursorless/lib-engine"; import { isEexistError } from "@cursorless/lib-node-common"; @@ -11,7 +11,7 @@ export class VscodeSnippets implements Snippets { snippetName: string, directory: string, ): Promise { - const snippetPath = join(directory, `${snippetName}.snippet`); + const snippetPath = path.join(directory, `${snippetName}.snippet`); await createNewFile(snippetPath); return this.ide.openTextDocument(snippetPath); } diff --git a/packages/app-vscode/src/commands.ts b/packages/app-vscode/src/commands.ts index 1521e32f012..e0486f2b575 100644 --- a/packages/app-vscode/src/commands.ts +++ b/packages/app-vscode/src/commands.ts @@ -1,4 +1,4 @@ -import * as vscode from "vscode"; +import vscode from "vscode"; import { CURSORLESS_ORG_URL, DOCS_URL } from "@cursorless/lib-common"; export const showDocumentation = () => { diff --git a/packages/app-vscode/src/createVscodeIde.ts b/packages/app-vscode/src/createVscodeIde.ts index 75762be8d5a..9fb8f90f5bd 100644 --- a/packages/app-vscode/src/createVscodeIde.ts +++ b/packages/app-vscode/src/createVscodeIde.ts @@ -1,6 +1,6 @@ -import * as crypto from "node:crypto"; -import * as os from "node:os"; -import * as path from "node:path"; +import crypto from "node:crypto"; +import os from "node:os"; +import path from "node:path"; import type { ExtensionContext } from "vscode"; import { FakeFontMeasurements } from "./ide/vscode/hats/FakeFontMeasurements"; import { FontMeasurementsImpl } from "./ide/vscode/hats/FontMeasurementsImpl"; diff --git a/packages/app-vscode/src/ide/vscode/VscodeCapabilities.ts b/packages/app-vscode/src/ide/vscode/VscodeCapabilities.ts index 3d65df0f5a5..64f20560420 100644 --- a/packages/app-vscode/src/ide/vscode/VscodeCapabilities.ts +++ b/packages/app-vscode/src/ide/vscode/VscodeCapabilities.ts @@ -1,5 +1,5 @@ -import * as semver from "semver"; -import * as vscode from "vscode"; +import semver from "semver"; +import vscode from "vscode"; import type { Capabilities, CommandCapabilityMap, diff --git a/packages/app-vscode/src/ide/vscode/VscodeClipboard.ts b/packages/app-vscode/src/ide/vscode/VscodeClipboard.ts index baa7cbb26b5..bf630955331 100644 --- a/packages/app-vscode/src/ide/vscode/VscodeClipboard.ts +++ b/packages/app-vscode/src/ide/vscode/VscodeClipboard.ts @@ -1,4 +1,4 @@ -import * as vscode from "vscode"; +import vscode from "vscode"; import type { Clipboard } from "@cursorless/lib-common"; export class VscodeClipboard implements Clipboard { diff --git a/packages/app-vscode/src/ide/vscode/VscodeConfiguration.ts b/packages/app-vscode/src/ide/vscode/VscodeConfiguration.ts index 445b8005539..329477f1fda 100644 --- a/packages/app-vscode/src/ide/vscode/VscodeConfiguration.ts +++ b/packages/app-vscode/src/ide/vscode/VscodeConfiguration.ts @@ -1,5 +1,5 @@ -import * as os from "node:os"; -import * as vscode from "vscode"; +import os from "node:os"; +import vscode from "vscode"; import type { Configuration, ConfigurationScope, diff --git a/packages/app-vscode/src/ide/vscode/VscodeEnabledHatStyleManager.ts b/packages/app-vscode/src/ide/vscode/VscodeEnabledHatStyleManager.ts index c3253ff24fc..faf2054208c 100644 --- a/packages/app-vscode/src/ide/vscode/VscodeEnabledHatStyleManager.ts +++ b/packages/app-vscode/src/ide/vscode/VscodeEnabledHatStyleManager.ts @@ -1,5 +1,5 @@ import { pickBy } from "lodash-es"; -import * as vscode from "vscode"; +import vscode from "vscode"; import type { HatStyleInfo, HatStyleMap, diff --git a/packages/app-vscode/src/ide/vscode/VscodeEvents.ts b/packages/app-vscode/src/ide/vscode/VscodeEvents.ts index 48eb7485424..83d4cc6d4f6 100644 --- a/packages/app-vscode/src/ide/vscode/VscodeEvents.ts +++ b/packages/app-vscode/src/ide/vscode/VscodeEvents.ts @@ -1,4 +1,4 @@ -import * as vscode from "vscode"; +import vscode from "vscode"; import type { Disposable, Event, diff --git a/packages/app-vscode/src/ide/vscode/VscodeFileSystem.ts b/packages/app-vscode/src/ide/vscode/VscodeFileSystem.ts index 6e86112d141..c9971e66a5f 100644 --- a/packages/app-vscode/src/ide/vscode/VscodeFileSystem.ts +++ b/packages/app-vscode/src/ide/vscode/VscodeFileSystem.ts @@ -1,5 +1,5 @@ -import { isAbsolute, join } from "node:path"; -import * as vscode from "vscode"; +import path from "node:path"; +import vscode from "vscode"; import type { Disposable, FileSystem, @@ -19,8 +19,11 @@ export class VscodeFileSystem implements FileSystem { private readonly runMode: RunMode, private readonly cursorlessDir: string, ) { - this.cursorlessTalonStateJsonPath = join(this.cursorlessDir, "state.json"); - this.cursorlessCommandHistoryDirPath = join( + this.cursorlessTalonStateJsonPath = path.join( + this.cursorlessDir, + "state.json", + ); + this.cursorlessCommandHistoryDirPath = path.join( this.cursorlessDir, "commandHistory", ); @@ -60,24 +63,27 @@ export class VscodeFileSystem implements FileSystem { } } - private resolveBundledPath(path: string) { - if (isAbsolute(path)) { + private resolveBundledPath(bundledPath: string) { + if (path.isAbsolute(bundledPath)) { if (this.runMode !== "development") { throw new Error( "Absolute paths are not supported outside of development mode", ); } - return vscode.Uri.file(path); + return vscode.Uri.file(bundledPath); } - return vscode.Uri.joinPath(this.extensionContext.extensionUri, path); + return vscode.Uri.joinPath(this.extensionContext.extensionUri, bundledPath); } - public watchDir(path: string, onDidChange: PathChangeListener): Disposable { + public watchDir( + dirPath: string, + onDidChange: PathChangeListener, + ): Disposable { // FIXME: Support globs? const watcher = vscode.workspace.createFileSystemWatcher( - new vscode.RelativePattern(path, "**"), + new vscode.RelativePattern(dirPath, "**"), ); watcher.onDidChange(onDidChange); diff --git a/packages/app-vscode/src/ide/vscode/VscodeFold.ts b/packages/app-vscode/src/ide/vscode/VscodeFold.ts index 58c7636686f..1796d2f0900 100644 --- a/packages/app-vscode/src/ide/vscode/VscodeFold.ts +++ b/packages/app-vscode/src/ide/vscode/VscodeFold.ts @@ -1,4 +1,4 @@ -import * as vscode from "vscode"; +import vscode from "vscode"; import type { Range } from "@cursorless/lib-common"; import type { VscodeIDE } from "./VscodeIDE"; import type { VscodeTextEditor } from "./VscodeTextEditor"; diff --git a/packages/app-vscode/src/ide/vscode/VscodeHighlights.ts b/packages/app-vscode/src/ide/vscode/VscodeHighlights.ts index 5d9ebf2ea85..2c16142febe 100644 --- a/packages/app-vscode/src/ide/vscode/VscodeHighlights.ts +++ b/packages/app-vscode/src/ide/vscode/VscodeHighlights.ts @@ -1,5 +1,5 @@ import type { ExtensionContext } from "vscode"; -import * as vscode from "vscode"; +import { Range } from "vscode"; import type { CharacterRange, GeneralizedRange, @@ -65,18 +65,13 @@ export class VscodeHighlights { tokenDecorationType, tokenRanges.map( ({ start, end }) => - new vscode.Range( - start.line, - start.character, - end.line, - end.character, - ), + new Range(start.line, start.character, end.line, end.character), ), ); editor.vscodeEditor.setDecorations( lineDecorationType, - lineRanges.map((range) => new vscode.Range(range.start, 0, range.end, 0)), + lineRanges.map((range) => new Range(range.start, 0, range.end, 0)), ); } } diff --git a/packages/app-vscode/src/ide/vscode/VscodeIDE.ts b/packages/app-vscode/src/ide/vscode/VscodeIDE.ts index 795033a3320..a5feb138722 100644 --- a/packages/app-vscode/src/ide/vscode/VscodeIDE.ts +++ b/packages/app-vscode/src/ide/vscode/VscodeIDE.ts @@ -1,8 +1,11 @@ import { pull } from "lodash-es"; import { v4 as uuid } from "uuid"; -import type { ExtensionContext, WorkspaceFolder } from "vscode"; -import * as vscode from "vscode"; -import { window, workspace } from "vscode"; +import type { + ExtensionContext, + WorkspaceFolder, + TextEditor as VsTextEditor, +} from "vscode"; +import { commands, window, workspace } from "vscode"; import type { Disposable, EditableTextEditor, @@ -58,7 +61,7 @@ export class VscodeIDE implements IDE { this.highlights = new VscodeHighlights(extensionContext); this.flashHandler = new VscodeFlashHandler(this, this.highlights); this.capabilities = new VscodeCapabilities(); - this.editorMap = new WeakMap(); + this.editorMap = new WeakMap(); } showQuickPick( @@ -124,7 +127,7 @@ export class VscodeIDE implements IDE { } get visibleNotebookEditors(): NotebookEditor[] { - return vscode.window.visibleNotebookEditors.map( + return window.visibleNotebookEditors.map( (editor) => new VscodeNotebookEditorImpl(editor), ); } @@ -140,13 +143,13 @@ export class VscodeIDE implements IDE { if (editor != null && !editor.isActive) { await this.getEditableTextEditor(editor).focus(); } - await vscode.commands.executeCommand("editor.actions.findWithArgs", { + await commands.executeCommand("editor.actions.findWithArgs", { searchString: query, }); } public async findInWorkspace(query: string): Promise { - await vscode.commands.executeCommand("workbench.action.findInFiles", { + await commands.executeCommand("workbench.action.findInFiles", { query, }); } @@ -166,14 +169,14 @@ export class VscodeIDE implements IDE { public async showInputBox( options?: InputBoxOptions, ): Promise { - return await vscode.window.showInputBox(options); + return await window.showInputBox(options); } public async executeCommand( command: string, ...args: any[] ): Promise { - return await vscode.commands.executeCommand(command, ...args); + return await commands.executeCommand(command, ...args); } public onDidChangeTextDocument( @@ -213,7 +216,7 @@ export class VscodeIDE implements IDE { }), ); - public fromVscodeEditor(editor: vscode.TextEditor): VscodeTextEditor { + public fromVscodeEditor(editor: VsTextEditor): VscodeTextEditor { if (!this.editorMap.has(editor)) { this.editorMap.set(editor, new VscodeTextEditor(uuid(), this, editor)); } @@ -224,12 +227,12 @@ export class VscodeIDE implements IDE { if (error instanceof OutdatedExtensionError) { void this.showUpdateExtensionErrorMessage(error); } else { - void vscode.window.showErrorMessage(getErrorMessage(error)); + void window.showErrorMessage(getErrorMessage(error)); } } private async showUpdateExtensionErrorMessage(error: OutdatedExtensionError) { - const item = await vscode.window.showErrorMessage( + const item = await window.showErrorMessage( error.message, "Check for updates", ); @@ -238,7 +241,7 @@ export class VscodeIDE implements IDE { return; } - await vscode.commands.executeCommand( + await commands.executeCommand( "workbench.extensions.action.checkForUpdates", ); } diff --git a/packages/app-vscode/src/ide/vscode/VscodeInsertSnippets.ts b/packages/app-vscode/src/ide/vscode/VscodeInsertSnippets.ts index 558f0295a6d..eb785adb16e 100644 --- a/packages/app-vscode/src/ide/vscode/VscodeInsertSnippets.ts +++ b/packages/app-vscode/src/ide/vscode/VscodeInsertSnippets.ts @@ -1,4 +1,4 @@ -import * as vscode from "vscode"; +import vscode from "vscode"; import type { Range } from "@cursorless/lib-common"; import { Selection } from "@cursorless/lib-common"; import type { VscodeTextEditor } from "./VscodeTextEditor"; diff --git a/packages/app-vscode/src/ide/vscode/VscodeOpenLink.ts b/packages/app-vscode/src/ide/vscode/VscodeOpenLink.ts index 3210e5a9bca..d45ce1cf9ee 100644 --- a/packages/app-vscode/src/ide/vscode/VscodeOpenLink.ts +++ b/packages/app-vscode/src/ide/vscode/VscodeOpenLink.ts @@ -1,4 +1,4 @@ -import * as vscode from "vscode"; +import vscode from "vscode"; import type { OpenLinkOptions, Range } from "@cursorless/lib-common"; import { Selection } from "@cursorless/lib-common"; import { toVscodePositionOrRange } from "@cursorless/lib-vscode-common"; diff --git a/packages/app-vscode/src/ide/vscode/VscodeRevealLine.ts b/packages/app-vscode/src/ide/vscode/VscodeRevealLine.ts index 17fd67839fd..2bee9f569b1 100644 --- a/packages/app-vscode/src/ide/vscode/VscodeRevealLine.ts +++ b/packages/app-vscode/src/ide/vscode/VscodeRevealLine.ts @@ -1,4 +1,4 @@ -import * as vscode from "vscode"; +import vscode from "vscode"; import { RevealLineAt } from "@cursorless/lib-common"; import type { VscodeTextEditor } from "./VscodeTextEditor"; diff --git a/packages/app-vscode/src/ide/vscode/VscodeTextDocument.ts b/packages/app-vscode/src/ide/vscode/VscodeTextDocument.ts index 4009859b914..22fb29ee017 100644 --- a/packages/app-vscode/src/ide/vscode/VscodeTextDocument.ts +++ b/packages/app-vscode/src/ide/vscode/VscodeTextDocument.ts @@ -1,4 +1,4 @@ -import * as path from "node:path"; +import path from "node:path"; import type * as vscode from "vscode"; import type { URI } from "vscode-uri"; import type { diff --git a/packages/app-vscode/src/ide/vscode/VscodeTextEditor.ts b/packages/app-vscode/src/ide/vscode/VscodeTextEditor.ts index 44546c83702..fd3d5f7d536 100644 --- a/packages/app-vscode/src/ide/vscode/VscodeTextEditor.ts +++ b/packages/app-vscode/src/ide/vscode/VscodeTextEditor.ts @@ -1,4 +1,4 @@ -import * as vscode from "vscode"; +import vscode from "vscode"; import type { Edit, EditableTextEditor, diff --git a/packages/app-vscode/src/ide/vscode/VscodeToggleBreakpoint.ts b/packages/app-vscode/src/ide/vscode/VscodeToggleBreakpoint.ts index ecc644bf502..4b76753d317 100644 --- a/packages/app-vscode/src/ide/vscode/VscodeToggleBreakpoint.ts +++ b/packages/app-vscode/src/ide/vscode/VscodeToggleBreakpoint.ts @@ -1,4 +1,4 @@ -import * as vscode from "vscode"; +import vscode from "vscode"; import type { GeneralizedRange, Position } from "@cursorless/lib-common"; import { toVscodePosition } from "@cursorless/lib-vscode-common"; import type { VscodeTextEditor } from "./VscodeTextEditor"; diff --git a/packages/app-vscode/src/ide/vscode/hats/FontMeasurementsImpl.ts b/packages/app-vscode/src/ide/vscode/hats/FontMeasurementsImpl.ts index 56b76666957..8a91498ad1a 100644 --- a/packages/app-vscode/src/ide/vscode/hats/FontMeasurementsImpl.ts +++ b/packages/app-vscode/src/ide/vscode/hats/FontMeasurementsImpl.ts @@ -1,4 +1,4 @@ -import * as vscode from "vscode"; +import vscode from "vscode"; import type { FontMeasurements } from "./FontMeasurements"; /** diff --git a/packages/app-vscode/src/ide/vscode/hats/VscodeHatRenderer.ts b/packages/app-vscode/src/ide/vscode/hats/VscodeHatRenderer.ts index 9622f035bdb..5116c5786b1 100644 --- a/packages/app-vscode/src/ide/vscode/hats/VscodeHatRenderer.ts +++ b/packages/app-vscode/src/ide/vscode/hats/VscodeHatRenderer.ts @@ -1,7 +1,7 @@ -import * as fs from "node:fs/promises"; -import * as path from "node:path"; +import fs from "node:fs/promises"; +import path from "node:path"; import { isEqual } from "lodash-es"; -import * as vscode from "vscode"; +import vscode from "vscode"; import type { Listener, Messages, diff --git a/packages/app-vscode/src/ide/vscode/hats/VscodeHats.ts b/packages/app-vscode/src/ide/vscode/hats/VscodeHats.ts index e1f83bd85fe..51f244f0001 100644 --- a/packages/app-vscode/src/ide/vscode/hats/VscodeHats.ts +++ b/packages/app-vscode/src/ide/vscode/hats/VscodeHats.ts @@ -1,4 +1,4 @@ -import * as vscode from "vscode"; +import vscode from "vscode"; import type { Disposable } from "vscode"; import type { HatRange, diff --git a/packages/app-vscode/src/ide/vscode/hats/getHatThemeColors.ts b/packages/app-vscode/src/ide/vscode/hats/getHatThemeColors.ts index 8164c7e640b..24a57a2b3b0 100644 --- a/packages/app-vscode/src/ide/vscode/hats/getHatThemeColors.ts +++ b/packages/app-vscode/src/ide/vscode/hats/getHatThemeColors.ts @@ -1,4 +1,4 @@ -import * as vscode from "vscode"; +import vscode from "vscode"; import type { HatColor } from "../hatStyles.types"; interface OldDecorationColorSetting { diff --git a/packages/app-vscode/src/ide/vscode/hats/performPr1868ShapeUpdateInit.ts b/packages/app-vscode/src/ide/vscode/hats/performPr1868ShapeUpdateInit.ts index f85b4a4567e..570fe99a51f 100644 --- a/packages/app-vscode/src/ide/vscode/hats/performPr1868ShapeUpdateInit.ts +++ b/packages/app-vscode/src/ide/vscode/hats/performPr1868ShapeUpdateInit.ts @@ -1,4 +1,4 @@ -import * as vscode from "vscode"; +import vscode from "vscode"; import type { Messages } from "@cursorless/lib-common"; import { showInfo } from "@cursorless/lib-common"; import type { VscodeApi } from "@cursorless/lib-vscode-common"; diff --git a/packages/app-vscode/src/ide/vscode/textLine.vscode.test.ts b/packages/app-vscode/src/ide/vscode/textLine.vscode.test.ts index 0aa7f8ec9d1..4d39231160e 100644 --- a/packages/app-vscode/src/ide/vscode/textLine.vscode.test.ts +++ b/packages/app-vscode/src/ide/vscode/textLine.vscode.test.ts @@ -1,4 +1,4 @@ -import * as assert from "node:assert/strict"; +import assert from "node:assert/strict"; import { getReusableEditor } from "@cursorless/lib-vscode-common"; import { VscodeTextLine } from "./VscodeTextLine"; diff --git a/packages/app-vscode/src/ide/vscode/vscodeShowQuickPick.ts b/packages/app-vscode/src/ide/vscode/vscodeShowQuickPick.ts index 7451add07fa..c447fbeae92 100644 --- a/packages/app-vscode/src/ide/vscode/vscodeShowQuickPick.ts +++ b/packages/app-vscode/src/ide/vscode/vscodeShowQuickPick.ts @@ -1,4 +1,4 @@ -import * as vscode from "vscode"; +import vscode from "vscode"; import type { QuickPickOptions } from "@cursorless/lib-common"; /** diff --git a/packages/app-vscode/src/keyboard/KeyboardCommandHandler.ts b/packages/app-vscode/src/keyboard/KeyboardCommandHandler.ts index 5342ae49cf3..0c920e32dcf 100644 --- a/packages/app-vscode/src/keyboard/KeyboardCommandHandler.ts +++ b/packages/app-vscode/src/keyboard/KeyboardCommandHandler.ts @@ -1,5 +1,5 @@ import { isString } from "lodash-es"; -import * as vscode from "vscode"; +import vscode from "vscode"; import type { Modifier, PartialMark, diff --git a/packages/app-vscode/src/keyboard/KeyboardCommandsModal.ts b/packages/app-vscode/src/keyboard/KeyboardCommandsModal.ts index 8c63816fd06..5ff1f5b9bf7 100644 --- a/packages/app-vscode/src/keyboard/KeyboardCommandsModal.ts +++ b/packages/app-vscode/src/keyboard/KeyboardCommandsModal.ts @@ -1,6 +1,6 @@ import { pick, sortedUniq, toPairs } from "lodash-es"; import nearley from "nearley"; -import * as vscode from "vscode"; +import vscode from "vscode"; import { CompositeKeyMap, getErrorMessage } from "@cursorless/lib-common"; import type { VscodeApi } from "@cursorless/lib-vscode-common"; import { getTokenTypeKeyMaps } from "./getTokenTypeKeyMaps"; diff --git a/packages/app-vscode/src/keyboard/KeyboardCommandsModalLayer.ts b/packages/app-vscode/src/keyboard/KeyboardCommandsModalLayer.ts index 0d987774910..621e5986848 100644 --- a/packages/app-vscode/src/keyboard/KeyboardCommandsModalLayer.ts +++ b/packages/app-vscode/src/keyboard/KeyboardCommandsModalLayer.ts @@ -1,5 +1,5 @@ import type TrieSearch from "trie-search"; -import * as vscode from "vscode"; +import vscode from "vscode"; import type { KeyValuePair } from "./buildSuffixTrie"; import { buildSuffixTrie } from "./buildSuffixTrie"; import type { KeyboardHandler } from "./KeyboardHandler"; diff --git a/packages/app-vscode/src/keyboard/KeyboardCommandsTargeted.ts b/packages/app-vscode/src/keyboard/KeyboardCommandsTargeted.ts index 8749539ca98..092d7bf0e45 100644 --- a/packages/app-vscode/src/keyboard/KeyboardCommandsTargeted.ts +++ b/packages/app-vscode/src/keyboard/KeyboardCommandsTargeted.ts @@ -1,4 +1,4 @@ -import * as vscode from "vscode"; +import vscode from "vscode"; import type { ActionDescriptor, Modifier, diff --git a/packages/app-vscode/src/keyboard/KeyboardHandler.ts b/packages/app-vscode/src/keyboard/KeyboardHandler.ts index 83826483186..7240c5a7345 100644 --- a/packages/app-vscode/src/keyboard/KeyboardHandler.ts +++ b/packages/app-vscode/src/keyboard/KeyboardHandler.ts @@ -1,5 +1,5 @@ import { pull } from "lodash-es"; -import * as vscode from "vscode"; +import vscode from "vscode"; import type { Disposable } from "vscode"; import type { StatusBarItem } from "../StatusBarItem"; diff --git a/packages/app-vscode/src/keyboard/buildSuffixTrie.test.ts b/packages/app-vscode/src/keyboard/buildSuffixTrie.test.ts index 129de01eb33..0674c43b289 100644 --- a/packages/app-vscode/src/keyboard/buildSuffixTrie.test.ts +++ b/packages/app-vscode/src/keyboard/buildSuffixTrie.test.ts @@ -1,4 +1,4 @@ -import * as assert from "node:assert/strict"; +import assert from "node:assert/strict"; import { isEqual, sortBy, uniq, uniqWith } from "lodash-es"; import type { KeyValuePair } from "./buildSuffixTrie"; import { buildSuffixTrie } from "./buildSuffixTrie"; diff --git a/packages/app-vscode/src/keyboard/grammar/getAcceptableTokenTypes.test.ts b/packages/app-vscode/src/keyboard/grammar/getAcceptableTokenTypes.test.ts index 2ab050b9399..9dcd77799a4 100644 --- a/packages/app-vscode/src/keyboard/grammar/getAcceptableTokenTypes.test.ts +++ b/packages/app-vscode/src/keyboard/grammar/getAcceptableTokenTypes.test.ts @@ -1,4 +1,4 @@ -import * as assert from "node:assert/strict"; +import assert from "node:assert/strict"; import { isEqual } from "lodash-es"; import nearley from "nearley"; import type { KeyDescriptor } from "../TokenTypeHelpers"; diff --git a/packages/app-vscode/src/keyboard/grammar/grammar.test.ts b/packages/app-vscode/src/keyboard/grammar/grammar.test.ts index 778848ba916..bdad0ffc5cf 100644 --- a/packages/app-vscode/src/keyboard/grammar/grammar.test.ts +++ b/packages/app-vscode/src/keyboard/grammar/grammar.test.ts @@ -1,4 +1,4 @@ -import * as assert from "node:assert/strict"; +import assert from "node:assert/strict"; import nearley from "nearley"; import type { KeyboardCommandHandler } from "../KeyboardCommandHandler"; import type { KeyboardCommand } from "../KeyboardCommandTypeHelpers"; diff --git a/packages/app-vscode/src/registerCommands.ts b/packages/app-vscode/src/registerCommands.ts index 04b4c5329f6..3109b3216e3 100644 --- a/packages/app-vscode/src/registerCommands.ts +++ b/packages/app-vscode/src/registerCommands.ts @@ -1,4 +1,4 @@ -import * as vscode from "vscode"; +import vscode from "vscode"; import type { CommandHistoryStorage, CursorlessCommandId, diff --git a/packages/app-vscode/src/scripts/initLaunchSandbox.ts b/packages/app-vscode/src/scripts/initLaunchSandbox.ts index 3c5b1b2f0a6..a47e0685e2f 100644 --- a/packages/app-vscode/src/scripts/initLaunchSandbox.ts +++ b/packages/app-vscode/src/scripts/initLaunchSandbox.ts @@ -1,4 +1,4 @@ -import * as cp from "node:child_process"; +import cp from "node:child_process"; import { exit } from "node:process"; /** * This script creates a VSCode settings profile for Cursorless development, diff --git a/packages/app-vscode/src/scripts/populateDist/populateDist.ts b/packages/app-vscode/src/scripts/populateDist/populateDist.ts index 17ccf07cead..c3a2b2ed1e2 100644 --- a/packages/app-vscode/src/scripts/populateDist/populateDist.ts +++ b/packages/app-vscode/src/scripts/populateDist/populateDist.ts @@ -1,6 +1,6 @@ // Copies files into `dist` directory for packaging import { lstat, mkdir, readFile, rm, writeFile } from "node:fs/promises"; -import * as path from "node:path"; +import path from "node:path"; import { copy, exists } from "fs-extra"; import { assets } from "./assets"; import type { Context } from "./context"; diff --git a/packages/app-vscode/src/scripts/populateDist/transformPackageJson.ts b/packages/app-vscode/src/scripts/populateDist/transformPackageJson.ts index 0e6cbe35f1a..cb7edac264e 100644 --- a/packages/app-vscode/src/scripts/populateDist/transformPackageJson.ts +++ b/packages/app-vscode/src/scripts/populateDist/transformPackageJson.ts @@ -1,4 +1,4 @@ -import * as semver from "semver"; +import semver from "semver"; import type { Context } from "./context"; import { runCommand } from "./runCommand"; diff --git a/packages/app-vscode/src/scripts/preprocessSvgHats.ts b/packages/app-vscode/src/scripts/preprocessSvgHats.ts index 354aed8dabe..4e0763600d0 100644 --- a/packages/app-vscode/src/scripts/preprocessSvgHats.ts +++ b/packages/app-vscode/src/scripts/preprocessSvgHats.ts @@ -1,12 +1,13 @@ -import { promises as fsp, readdirSync } from "node:fs"; -import * as path from "node:path"; -import * as parser from "fast-xml-parser"; +import { readdirSync } from "node:fs"; +import fsp from "node:fs/promises"; +import path from "node:path"; +import { XMLParser, XMLBuilder } from "fast-xml-parser"; import { getCursorlessRepoRoot } from "@cursorless/lib-node-common"; async function main() { const directory = path.join(getCursorlessRepoRoot(), "resources/images/hats"); - const dumper = new parser.XMLBuilder({ + const dumper = new XMLBuilder({ ignoreAttributes: false, suppressEmptyNode: true, format: true, @@ -18,9 +19,7 @@ async function main() { } const filePath = path.join(directory, dirent.name); const rawSvg = await fsp.readFile(filePath, { encoding: "utf8" }); - const svgJson = new parser.XMLParser({ ignoreAttributes: false }).parse( - rawSvg, - ); + const svgJson = new XMLParser({ ignoreAttributes: false }).parse(rawSvg); svgJson.svg["@_width"] = "1em"; svgJson.svg["@_height"] = "1em"; diff --git a/packages/app-web-docs/docusaurus.config.mts b/packages/app-web-docs/docusaurus.config.mts index 39ee657db95..1c301883df6 100644 --- a/packages/app-web-docs/docusaurus.config.mts +++ b/packages/app-web-docs/docusaurus.config.mts @@ -1,5 +1,5 @@ import { createRequire } from "node:module"; -import * as path from "node:path"; +import path from "node:path"; import { fileURLToPath } from "node:url"; import type { Config } from "@docusaurus/types"; import type { Root } from "mdast"; diff --git a/packages/app-web-docs/src/docs/components/flattenHighlights.test.ts b/packages/app-web-docs/src/docs/components/flattenHighlights.test.ts index 382631ea707..24a1d1594cf 100644 --- a/packages/app-web-docs/src/docs/components/flattenHighlights.test.ts +++ b/packages/app-web-docs/src/docs/components/flattenHighlights.test.ts @@ -1,4 +1,4 @@ -import * as assert from "node:assert/strict"; +import assert from "node:assert/strict"; import { BorderStyle, Range } from "@cursorless/lib-common"; import { flattenHighlights } from "./flattenHighlights"; import type { Highlight, Scope } from "./types"; diff --git a/packages/app-web-docs/src/plugins/scope-tests-plugin.ts b/packages/app-web-docs/src/plugins/scope-tests-plugin.ts index f0b668ba5c7..6eba614734e 100644 --- a/packages/app-web-docs/src/plugins/scope-tests-plugin.ts +++ b/packages/app-web-docs/src/plugins/scope-tests-plugin.ts @@ -1,5 +1,5 @@ -import * as fs from "node:fs"; -import * as path from "node:path"; +import fs from "node:fs"; +import path from "node:path"; import { fileURLToPath } from "node:url"; import type { LoadContext, Plugin, PluginOptions } from "@docusaurus/types"; import type { ScopeTestPath } from "@cursorless/lib-node-common"; diff --git a/packages/lib-common/scripts/c-tsx.js b/packages/lib-common/scripts/c-tsx.js index 05dc951e5b2..dc9aa070183 100755 --- a/packages/lib-common/scripts/c-tsx.js +++ b/packages/lib-common/scripts/c-tsx.js @@ -4,7 +4,7 @@ // This script runs a TypeScript file using tsx after setting repo-specific // environment variables. -import { join } from "node:path"; +import path from "node:path"; import { spawn } from "cross-spawn"; /** @@ -37,7 +37,7 @@ function main() { const [fileToRun, ...childArgs] = args; - const repoRoot = join(import.meta.dirname, "..", "..", ".."); + const repoRoot = path.join(import.meta.dirname, "..", "..", ".."); const nodeProcess = runCommand( "tsx", diff --git a/packages/lib-common/src/ide/inMemoryTextEditor/test/InMemoryTextDocument.test.ts b/packages/lib-common/src/ide/inMemoryTextEditor/test/InMemoryTextDocument.test.ts index 8c6964de816..08db9ecf4cd 100644 --- a/packages/lib-common/src/ide/inMemoryTextEditor/test/InMemoryTextDocument.test.ts +++ b/packages/lib-common/src/ide/inMemoryTextEditor/test/InMemoryTextDocument.test.ts @@ -1,4 +1,4 @@ -import * as assert from "node:assert/strict"; +import assert from "node:assert/strict"; import { URI } from "vscode-uri"; import { Position } from "../../../types/Position"; import { Range } from "../../../types/Range"; diff --git a/packages/lib-common/src/ide/inMemoryTextEditor/test/InMemoryTextDocumentEdit.test.ts b/packages/lib-common/src/ide/inMemoryTextEditor/test/InMemoryTextDocumentEdit.test.ts index 0eb77892094..100c66709be 100644 --- a/packages/lib-common/src/ide/inMemoryTextEditor/test/InMemoryTextDocumentEdit.test.ts +++ b/packages/lib-common/src/ide/inMemoryTextEditor/test/InMemoryTextDocumentEdit.test.ts @@ -1,4 +1,4 @@ -import * as assert from "node:assert/strict"; +import assert from "node:assert/strict"; import { Range } from "../../../types/Range"; import { getErrorMessage } from "../../../util/getErrorMessage"; import { createTestDocument } from "./createTestDocument"; diff --git a/packages/lib-common/src/ide/inMemoryTextEditor/test/InMemoryTextDocumentLineAt.test.ts b/packages/lib-common/src/ide/inMemoryTextEditor/test/InMemoryTextDocumentLineAt.test.ts index bfcd3db01c9..a8039cce9e3 100644 --- a/packages/lib-common/src/ide/inMemoryTextEditor/test/InMemoryTextDocumentLineAt.test.ts +++ b/packages/lib-common/src/ide/inMemoryTextEditor/test/InMemoryTextDocumentLineAt.test.ts @@ -1,4 +1,4 @@ -import * as assert from "node:assert/strict"; +import assert from "node:assert/strict"; import { range } from "lodash-es"; import { createTestDocument } from "./createTestDocument"; diff --git a/packages/lib-common/src/scopeVisualizerUtil/generateDecorationsForCharacterRange/handleMultipleLines.test.ts b/packages/lib-common/src/scopeVisualizerUtil/generateDecorationsForCharacterRange/handleMultipleLines.test.ts index 2839720468d..d4132f7f373 100644 --- a/packages/lib-common/src/scopeVisualizerUtil/generateDecorationsForCharacterRange/handleMultipleLines.test.ts +++ b/packages/lib-common/src/scopeVisualizerUtil/generateDecorationsForCharacterRange/handleMultipleLines.test.ts @@ -1,4 +1,4 @@ -import * as assert from "node:assert/strict"; +import assert from "node:assert/strict"; import { map } from "itertools"; import { Range } from "../../types/Range"; import { BorderStyle } from "../decorationStyle.types"; diff --git a/packages/lib-common/src/testUtil/serialize.ts b/packages/lib-common/src/testUtil/serialize.ts index 93cd00e3fd5..870476879ad 100644 --- a/packages/lib-common/src/testUtil/serialize.ts +++ b/packages/lib-common/src/testUtil/serialize.ts @@ -2,16 +2,17 @@ // This file ensures that simple objects and arrays (ie without array or object // children) will be serialized inline, and also ensures that "fullTargets" will be inlined as well -import * as yaml from "js-yaml"; +import { dump, Type, DEFAULT_SCHEMA } from "js-yaml"; +import type { DumpOptions } from "js-yaml"; class CustomDump { constructor( private readonly data: unknown, - private readonly opts: yaml.DumpOptions, + private readonly opts: DumpOptions, ) {} represent(): string { - let result = yaml.dump(this.data, { replacer, schema, ...this.opts }); + let result = dump(this.data, { replacer, schema, ...this.opts }); result = result.trim(); if (result.includes("\n")) { result = `\n${result}`; @@ -20,14 +21,14 @@ class CustomDump { } } -const customDumpType = new yaml.Type("!format", { +const customDumpType = new Type("!format", { kind: "scalar", resolve: () => false, instanceOf: CustomDump, represent: (d: unknown) => (d as CustomDump).represent(), }); -const schema = yaml.DEFAULT_SCHEMA.extend({ implicit: [customDumpType] }); +const schema = DEFAULT_SCHEMA.extend({ implicit: [customDumpType] }); const isObject = (value: unknown): value is object => typeof value === "object" && value != null; diff --git a/packages/lib-common/src/types/generalizedRangeContains.test.ts b/packages/lib-common/src/types/generalizedRangeContains.test.ts index 19c7f11d9bb..f861be74391 100644 --- a/packages/lib-common/src/types/generalizedRangeContains.test.ts +++ b/packages/lib-common/src/types/generalizedRangeContains.test.ts @@ -1,4 +1,4 @@ -import * as assert from "node:assert/strict"; +import assert from "node:assert/strict"; import { generalizedRangeContains } from "./GeneralizedRange"; import { Position } from "./Position"; diff --git a/packages/lib-common/src/types/generalizedRangeTouches.test.ts b/packages/lib-common/src/types/generalizedRangeTouches.test.ts index 562577abda3..87aab86a24c 100644 --- a/packages/lib-common/src/types/generalizedRangeTouches.test.ts +++ b/packages/lib-common/src/types/generalizedRangeTouches.test.ts @@ -1,4 +1,4 @@ -import * as assert from "node:assert/strict"; +import assert from "node:assert/strict"; import type { GeneralizedRange } from "./GeneralizedRange"; import { generalizedRangeTouches } from "./GeneralizedRange"; import { Position } from "./Position"; diff --git a/packages/lib-common/src/types/isGeneralizedRangeEqual.test.ts b/packages/lib-common/src/types/isGeneralizedRangeEqual.test.ts index de76df64e4d..73495b82e3a 100644 --- a/packages/lib-common/src/types/isGeneralizedRangeEqual.test.ts +++ b/packages/lib-common/src/types/isGeneralizedRangeEqual.test.ts @@ -1,4 +1,4 @@ -import * as assert from "node:assert/strict"; +import assert from "node:assert/strict"; import { isGeneralizedRangeEqual } from "./GeneralizedRange"; import { Position } from "./Position"; diff --git a/packages/lib-common/src/types/position.test.ts b/packages/lib-common/src/types/position.test.ts index 6fabbc72bfe..c2722b9b998 100644 --- a/packages/lib-common/src/types/position.test.ts +++ b/packages/lib-common/src/types/position.test.ts @@ -1,4 +1,4 @@ -import * as assert from "node:assert/strict"; +import assert from "node:assert/strict"; import { Position } from "./Position"; suite("Position", () => { diff --git a/packages/lib-common/src/types/range.test.ts b/packages/lib-common/src/types/range.test.ts index 96b167a8840..37ff4622d36 100644 --- a/packages/lib-common/src/types/range.test.ts +++ b/packages/lib-common/src/types/range.test.ts @@ -1,4 +1,4 @@ -import * as assert from "node:assert/strict"; +import assert from "node:assert/strict"; import { Position } from "./Position"; import { Range } from "./Range"; import { Selection } from "./Selection"; diff --git a/packages/lib-common/src/types/selection.test.ts b/packages/lib-common/src/types/selection.test.ts index 02eb4062724..17daa3c828b 100644 --- a/packages/lib-common/src/types/selection.test.ts +++ b/packages/lib-common/src/types/selection.test.ts @@ -1,4 +1,4 @@ -import * as assert from "node:assert/strict"; +import assert from "node:assert/strict"; import { Position } from "./Position"; import { Selection } from "./Selection"; diff --git a/packages/lib-common/src/util/uniqWithHash.test.ts b/packages/lib-common/src/util/uniqWithHash.test.ts index fde8bcca8c8..57c9e4a9f2b 100644 --- a/packages/lib-common/src/util/uniqWithHash.test.ts +++ b/packages/lib-common/src/util/uniqWithHash.test.ts @@ -1,4 +1,4 @@ -import * as assert from "node:assert/strict"; +import assert from "node:assert/strict"; import * as fc from "fast-check"; import { uniqWith } from "lodash-es"; import { uniqWithHash } from "./uniqWithHash"; diff --git a/packages/lib-engine/package.json b/packages/lib-engine/package.json index e95480dca7d..411241e9824 100644 --- a/packages/lib-engine/package.json +++ b/packages/lib-engine/package.json @@ -31,12 +31,10 @@ "zod": "^4.4.3" }, "devDependencies": { - "@types/js-yaml": "^4.0.9", "@types/lodash-es": "^4.17.12", "@types/mocha": "^10.0.10", "@types/moo": "^0.5.10", "@types/nearley": "^2.11.5", - "js-yaml": "^4.2.0", "web-tree-sitter": "^0.26.9" } } diff --git a/packages/lib-engine/src/core/UndoStack.test.ts b/packages/lib-engine/src/core/UndoStack.test.ts index 27f2c6dd269..98d7d596f45 100644 --- a/packages/lib-engine/src/core/UndoStack.test.ts +++ b/packages/lib-engine/src/core/UndoStack.test.ts @@ -1,4 +1,4 @@ -import * as assert from "node:assert/strict"; +import assert from "node:assert/strict"; import { UndoStack } from "./UndoStack"; suite("UndoStack", () => { diff --git a/packages/lib-engine/src/core/getPreferredSnippet.test.ts b/packages/lib-engine/src/core/getPreferredSnippet.test.ts index 8927d597fa0..b87789c8af5 100644 --- a/packages/lib-engine/src/core/getPreferredSnippet.test.ts +++ b/packages/lib-engine/src/core/getPreferredSnippet.test.ts @@ -1,4 +1,4 @@ -import * as assert from "node:assert/strict"; +import assert from "node:assert/strict"; import type { CustomInsertSnippetArg, CustomWrapWithSnippetArg, diff --git a/packages/lib-engine/src/core/updateSelections/updateSelections.test.ts b/packages/lib-engine/src/core/updateSelections/updateSelections.test.ts index b950f0375dd..36589135cd2 100644 --- a/packages/lib-engine/src/core/updateSelections/updateSelections.test.ts +++ b/packages/lib-engine/src/core/updateSelections/updateSelections.test.ts @@ -1,4 +1,4 @@ -import * as assert from "node:assert/strict"; +import assert from "node:assert/strict"; import type { Disposable, TextDocumentChangeEvent, diff --git a/packages/lib-engine/src/customCommandGrammar/grammarAction.test.ts b/packages/lib-engine/src/customCommandGrammar/grammarAction.test.ts index bce9abf0061..54847ee1e72 100644 --- a/packages/lib-engine/src/customCommandGrammar/grammarAction.test.ts +++ b/packages/lib-engine/src/customCommandGrammar/grammarAction.test.ts @@ -1,4 +1,4 @@ -import * as assert from "node:assert/strict"; +import assert from "node:assert/strict"; import type { ActionDescriptor } from "@cursorless/lib-common"; import { parseAction } from "./parseCommand"; import type { WithPlaceholders } from "./WithPlaceholders"; diff --git a/packages/lib-engine/src/customCommandGrammar/grammarScopeType.test.ts b/packages/lib-engine/src/customCommandGrammar/grammarScopeType.test.ts index 6300e17d370..0a1b20d40f9 100644 --- a/packages/lib-engine/src/customCommandGrammar/grammarScopeType.test.ts +++ b/packages/lib-engine/src/customCommandGrammar/grammarScopeType.test.ts @@ -1,4 +1,4 @@ -import * as assert from "node:assert/strict"; +import assert from "node:assert/strict"; import type { ScopeType } from "@cursorless/lib-common"; import { parseScopeType } from "./parseCommand"; diff --git a/packages/lib-engine/src/customCommandGrammar/lexer.test.ts b/packages/lib-engine/src/customCommandGrammar/lexer.test.ts index eda25764a87..157b726c1b2 100644 --- a/packages/lib-engine/src/customCommandGrammar/lexer.test.ts +++ b/packages/lib-engine/src/customCommandGrammar/lexer.test.ts @@ -1,4 +1,4 @@ -import * as assert from "node:assert/strict"; +import assert from "node:assert/strict"; import type { NearleyLexer, NearleyToken } from "./CommandLexer"; import { lexer } from "./lexer"; diff --git a/packages/lib-engine/src/generateSpokenForm/CustomSpokenFormGeneratorImpl.test.ts b/packages/lib-engine/src/generateSpokenForm/CustomSpokenFormGeneratorImpl.test.ts index 0658fc9fdbe..648266e30aa 100644 --- a/packages/lib-engine/src/generateSpokenForm/CustomSpokenFormGeneratorImpl.test.ts +++ b/packages/lib-engine/src/generateSpokenForm/CustomSpokenFormGeneratorImpl.test.ts @@ -1,4 +1,4 @@ -import * as assert from "node:assert/strict"; +import assert from "node:assert/strict"; import { FakeIDE, LATEST_VERSION, asyncSafety } from "@cursorless/lib-common"; import { CustomSpokenFormGeneratorImpl } from "./CustomSpokenFormGeneratorImpl"; diff --git a/packages/lib-engine/src/generateSpokenForm/generateSpokenForm.test.ts b/packages/lib-engine/src/generateSpokenForm/generateSpokenForm.test.ts index 2a301d026f3..f944fba623c 100644 --- a/packages/lib-engine/src/generateSpokenForm/generateSpokenForm.test.ts +++ b/packages/lib-engine/src/generateSpokenForm/generateSpokenForm.test.ts @@ -1,12 +1,10 @@ -import * as assert from "node:assert/strict"; +import assert from "node:assert/strict"; import { promises as fsp } from "node:fs"; -import * as yaml from "js-yaml"; -import type { TestCaseFixtureLegacy } from "@cursorless/lib-common"; import { serializeTestFixture, shouldUpdateFixtures, } from "@cursorless/lib-common"; -import { getRecordedTestPaths } from "@cursorless/lib-node-common"; +import { getRecordedTestPaths, loadFixture } from "@cursorless/lib-node-common"; import { SpokenFormGenerator } from "."; import { canonicalizeAndValidateCommand } from "../core/commandVersionUpgrades/canonicalizeAndValidateCommand"; import { defaultSpokenFormInfoMap } from "../spokenForms/defaultSpokenFormMap"; @@ -59,9 +57,7 @@ suite("Generate spoken forms", () => { }); async function runTest(file: string) { - const buffer = await fsp.readFile(file); - const fixture = yaml.load(buffer.toString()) as TestCaseFixtureLegacy; - + const fixture = await loadFixture(file); const generator = new SpokenFormGenerator(spokenFormMap); const generatedSpokenForm = generator.processCommand( diff --git a/packages/lib-engine/src/languages/TreeSitterQuery/checkCaptureStartEnd.test.ts b/packages/lib-engine/src/languages/TreeSitterQuery/checkCaptureStartEnd.test.ts index e4cc17b33f4..0d35ebc3ebb 100644 --- a/packages/lib-engine/src/languages/TreeSitterQuery/checkCaptureStartEnd.test.ts +++ b/packages/lib-engine/src/languages/TreeSitterQuery/checkCaptureStartEnd.test.ts @@ -1,4 +1,4 @@ -import * as assert from "node:assert/strict"; +import assert from "node:assert/strict"; import type { Messages } from "@cursorless/lib-common"; import { Range } from "@cursorless/lib-common"; import { checkCaptureStartEnd } from "./checkCaptureStartEnd"; diff --git a/packages/lib-engine/src/languages/TreeSitterQuery/parsePredicates.test.ts b/packages/lib-engine/src/languages/TreeSitterQuery/parsePredicates.test.ts index 84b24ec12ea..b22b373aff3 100644 --- a/packages/lib-engine/src/languages/TreeSitterQuery/parsePredicates.test.ts +++ b/packages/lib-engine/src/languages/TreeSitterQuery/parsePredicates.test.ts @@ -1,4 +1,4 @@ -import * as assert from "node:assert/strict"; +import assert from "node:assert/strict"; import type { QueryPredicate } from "web-tree-sitter"; import { parsePredicates } from "./parsePredicates"; diff --git a/packages/lib-engine/src/languages/TreeSitterQuery/rewriteStartOfEndOf.test.ts b/packages/lib-engine/src/languages/TreeSitterQuery/rewriteStartOfEndOf.test.ts index 67074184bd1..3f21aee5e59 100644 --- a/packages/lib-engine/src/languages/TreeSitterQuery/rewriteStartOfEndOf.test.ts +++ b/packages/lib-engine/src/languages/TreeSitterQuery/rewriteStartOfEndOf.test.ts @@ -1,4 +1,4 @@ -import * as assert from "node:assert/strict"; +import assert from "node:assert/strict"; import { Range } from "@cursorless/lib-common"; import type { MutableQueryCapture, QueryCapture } from "./QueryCapture"; import { diff --git a/packages/lib-engine/src/languages/TreeSitterQuery/validateQueryCaptures.test.ts b/packages/lib-engine/src/languages/TreeSitterQuery/validateQueryCaptures.test.ts index 9113912078f..a967beaae1d 100644 --- a/packages/lib-engine/src/languages/TreeSitterQuery/validateQueryCaptures.test.ts +++ b/packages/lib-engine/src/languages/TreeSitterQuery/validateQueryCaptures.test.ts @@ -1,4 +1,4 @@ -import * as assert from "node:assert/strict"; +import assert from "node:assert/strict"; import { FakeIDE } from "@cursorless/lib-common"; import { validateQueryCaptures } from "./validateQueryCaptures"; diff --git a/packages/lib-engine/src/processTargets/modifiers/scopeHandlers/BaseScopeHandler.test.ts b/packages/lib-engine/src/processTargets/modifiers/scopeHandlers/BaseScopeHandler.test.ts index 300e5426d07..ca448debfcc 100644 --- a/packages/lib-engine/src/processTargets/modifiers/scopeHandlers/BaseScopeHandler.test.ts +++ b/packages/lib-engine/src/processTargets/modifiers/scopeHandlers/BaseScopeHandler.test.ts @@ -1,4 +1,4 @@ -import * as assert from "node:assert/strict"; +import assert from "node:assert/strict"; import type { TextEditor, Direction } from "@cursorless/lib-common"; import { Position, Range } from "@cursorless/lib-common"; import { BaseScopeHandler } from "./BaseScopeHandler"; diff --git a/packages/lib-engine/src/processTargets/modifiers/scopeHandlers/util/OneWayNestedRangeFinder.test.ts b/packages/lib-engine/src/processTargets/modifiers/scopeHandlers/util/OneWayNestedRangeFinder.test.ts index 4c9b108dd01..c597876ecfc 100644 --- a/packages/lib-engine/src/processTargets/modifiers/scopeHandlers/util/OneWayNestedRangeFinder.test.ts +++ b/packages/lib-engine/src/processTargets/modifiers/scopeHandlers/util/OneWayNestedRangeFinder.test.ts @@ -1,4 +1,4 @@ -import * as assert from "node:assert/strict"; +import assert from "node:assert/strict"; import { Range } from "@cursorless/lib-common"; import { OneWayNestedRangeFinder } from "./OneWayNestedRangeFinder"; diff --git a/packages/lib-engine/src/scripts/transformRecordedTests/checkMarks.ts b/packages/lib-engine/src/scripts/transformRecordedTests/checkMarks.ts index 660a5e97646..0ca33da06d0 100644 --- a/packages/lib-engine/src/scripts/transformRecordedTests/checkMarks.ts +++ b/packages/lib-engine/src/scripts/transformRecordedTests/checkMarks.ts @@ -1,4 +1,4 @@ -import * as assert from "node:assert/strict"; +import assert from "node:assert/strict"; import { uniq } from "lodash-es"; import type { TestCaseFixtureLegacy } from "@cursorless/lib-common"; import { FakeIDE } from "@cursorless/lib-common"; diff --git a/packages/lib-engine/src/scripts/transformRecordedTests/moveFile.ts b/packages/lib-engine/src/scripts/transformRecordedTests/moveFile.ts index 904861e96ce..913c3aa6016 100644 --- a/packages/lib-engine/src/scripts/transformRecordedTests/moveFile.ts +++ b/packages/lib-engine/src/scripts/transformRecordedTests/moveFile.ts @@ -1,16 +1,13 @@ -import { promises as fsp } from "node:fs"; import { mkdir, rename } from "node:fs/promises"; -import * as path from "node:path"; -import * as yaml from "js-yaml"; -import type { TestCaseFixture } from "@cursorless/lib-common"; +import path from "node:path"; +import { loadFixture } from "@cursorless/lib-node-common"; /** * Can be used to organize files into directories based on eg language id * @param file The file to move */ export async function moveFile(file: string) { - const buffer = await fsp.readFile(file); - const inputFixture = yaml.load(buffer.toString()) as TestCaseFixture; + const inputFixture = await loadFixture(file); const parent = path.dirname(file); if (path.basename(parent) !== "surroundingPair") { return; diff --git a/packages/lib-engine/src/scripts/transformRecordedTests/transformFile.ts b/packages/lib-engine/src/scripts/transformRecordedTests/transformFile.ts index efce2c4709d..0b88458c342 100644 --- a/packages/lib-engine/src/scripts/transformRecordedTests/transformFile.ts +++ b/packages/lib-engine/src/scripts/transformRecordedTests/transformFile.ts @@ -1,15 +1,13 @@ -import * as fs from "node:fs/promises"; -import * as yaml from "js-yaml"; -import type { TestCaseFixture } from "@cursorless/lib-common"; +import fs from "node:fs/promises"; import { serializeTestFixture } from "@cursorless/lib-common"; +import { loadFixture } from "@cursorless/lib-node-common"; import type { FixtureTransformation } from "./types"; export async function transformFile( transformation: FixtureTransformation, file: string, ) { - const buffer = await fs.readFile(file); - const inputFixture = yaml.load(buffer.toString()) as TestCaseFixture; + const inputFixture = await loadFixture(file); const outputFixture = transformation(inputFixture); if (outputFixture != null) { await fs.writeFile(file, serializeTestFixture(outputFixture)); diff --git a/packages/lib-engine/src/snippets/snippetParser.test.ts b/packages/lib-engine/src/snippets/snippetParser.test.ts index d8c6a50ec18..fe45e636308 100644 --- a/packages/lib-engine/src/snippets/snippetParser.test.ts +++ b/packages/lib-engine/src/snippets/snippetParser.test.ts @@ -2,7 +2,7 @@ * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. See https://github.com/microsoft/vscode/blob/6915debdd61d3db26c39e831babf70b573b1baf0/LICENSE.txt for license information. *--------------------------------------------------------------------------------------------*/ -import * as assert from "node:assert/strict"; +import assert from "node:assert/strict"; import { SnippetParser } from "./vendor/vscodeSnippet/snippetParser"; suite("SnippetParser", () => { diff --git a/packages/lib-engine/src/test/scopes.test.ts b/packages/lib-engine/src/test/scopes.test.ts index 95e8007c5db..e879045e34a 100644 --- a/packages/lib-engine/src/test/scopes.test.ts +++ b/packages/lib-engine/src/test/scopes.test.ts @@ -1,4 +1,4 @@ -import * as assert from "node:assert/strict"; +import assert from "node:assert/strict"; import { promises as fsp } from "node:fs"; import { groupBy, uniq } from "lodash-es"; import type { diff --git a/packages/lib-engine/src/test/sentenceSegmenter.test.ts b/packages/lib-engine/src/test/sentenceSegmenter.test.ts index fe4a7154224..0c70455d0e8 100644 --- a/packages/lib-engine/src/test/sentenceSegmenter.test.ts +++ b/packages/lib-engine/src/test/sentenceSegmenter.test.ts @@ -1,4 +1,4 @@ -import * as assert from "node:assert/strict"; +import assert from "node:assert/strict"; import { SentenceSegmenter } from "../processTargets/modifiers/scopeHandlers/SentenceScopeHandler/SentenceSegmenter"; import { sentenceSegmenterFixture } from "./fixtures/sentenceSegmeter.fixture"; diff --git a/packages/lib-engine/src/test/spokenForms.talon.test.ts b/packages/lib-engine/src/test/spokenForms.talon.test.ts index 63171100c49..b675699d92b 100644 --- a/packages/lib-engine/src/test/spokenForms.talon.test.ts +++ b/packages/lib-engine/src/test/spokenForms.talon.test.ts @@ -1,13 +1,7 @@ -import * as assert from "node:assert/strict"; -import { promises as fsp } from "node:fs"; -import * as yaml from "js-yaml"; -import type { - Command, - CommandLatest, - TestCaseFixtureLegacy, -} from "@cursorless/lib-common"; +import assert from "node:assert/strict"; +import type { Command, CommandLatest } from "@cursorless/lib-common"; import { asyncSafety } from "@cursorless/lib-common"; -import { getRecordedTestPaths } from "@cursorless/lib-node-common"; +import { getRecordedTestPaths, loadFixture } from "@cursorless/lib-node-common"; import { canonicalizeAndValidateCommand } from "../core/commandVersionUpgrades/canonicalizeAndValidateCommand"; import { getHatMapCommand } from "../generateSpokenForm/getHatMapCommand"; import { TalonRepl } from "../testUtil/TalonRepl"; @@ -52,8 +46,7 @@ suite("Talon spoken forms", () => { }); async function runRecordedFixture(repl: TalonRepl, file: string) { - const buffer = await fsp.readFile(file); - const fixture = yaml.load(buffer.toString()) as TestCaseFixtureLegacy; + const fixture = await loadFixture(file); if (fixture.spokenFormError != null) { return; diff --git a/packages/lib-engine/src/test/subtoken.test.ts b/packages/lib-engine/src/test/subtoken.test.ts index 69940f2a753..0731e2a705a 100644 --- a/packages/lib-engine/src/test/subtoken.test.ts +++ b/packages/lib-engine/src/test/subtoken.test.ts @@ -1,4 +1,4 @@ -import * as assert from "node:assert/strict"; +import assert from "node:assert/strict"; import { FakeIDE } from "@cursorless/lib-common"; import { WordTokenizer } from "../processTargets/modifiers/scopeHandlers/WordScopeHandler/WordTokenizer"; import { subtokenFixture } from "./fixtures/subtoken.fixture"; diff --git a/packages/lib-engine/src/testUtil/TalonRepl.ts b/packages/lib-engine/src/testUtil/TalonRepl.ts index ff183858b04..379f7dfd609 100644 --- a/packages/lib-engine/src/testUtil/TalonRepl.ts +++ b/packages/lib-engine/src/testUtil/TalonRepl.ts @@ -1,5 +1,5 @@ -import * as childProcess from "node:child_process"; -import * as os from "node:os"; +import childProcess from "node:child_process"; +import os from "node:os"; import { isWindows } from "@cursorless/lib-node-common"; const MAX_OUTPUT_TO_EAT = 20; diff --git a/packages/lib-engine/src/testUtil/TestFileSystem.ts b/packages/lib-engine/src/testUtil/TestFileSystem.ts index 1fd6c4240e4..b10f39a165c 100644 --- a/packages/lib-engine/src/testUtil/TestFileSystem.ts +++ b/packages/lib-engine/src/testUtil/TestFileSystem.ts @@ -1,5 +1,5 @@ import fs from "node:fs/promises"; -import { join } from "node:path"; +import path from "node:path"; import type { Disposable, FileSystem, @@ -19,8 +19,11 @@ export class TestFileSystem implements FileSystem { private readonly runMode: RunMode, private readonly cursorlessDir: string, ) { - this.cursorlessTalonStateJsonPath = join(this.cursorlessDir, "state.json"); - this.cursorlessCommandHistoryDirPath = join( + this.cursorlessTalonStateJsonPath = path.join( + this.cursorlessDir, + "state.json", + ); + this.cursorlessCommandHistoryDirPath = path.join( this.cursorlessDir, "commandHistory", ); @@ -30,8 +33,8 @@ export class TestFileSystem implements FileSystem { return Promise.resolve(); } - public async readBundledFile(path: string): Promise { - const absolutePath = join(getCursorlessRepoRoot(), path); + public async readBundledFile(filePath: string): Promise { + const absolutePath = path.join(getCursorlessRepoRoot(), filePath); try { return await fs.readFile(absolutePath, "utf8"); } catch (error) { diff --git a/packages/lib-engine/src/testUtil/TestTreeSitter.ts b/packages/lib-engine/src/testUtil/TestTreeSitter.ts index 54e425da14f..7ca893710ca 100644 --- a/packages/lib-engine/src/testUtil/TestTreeSitter.ts +++ b/packages/lib-engine/src/testUtil/TestTreeSitter.ts @@ -1,4 +1,4 @@ -import * as path from "node:path"; +import path from "node:path"; import type { Tree } from "web-tree-sitter"; import { Parser, Query, Language } from "web-tree-sitter"; import type { TextDocument, TreeSitter } from "@cursorless/lib-common"; diff --git a/packages/lib-engine/src/tokenGraphemeSplitter/tokenGraphemeSplitter.test.ts b/packages/lib-engine/src/tokenGraphemeSplitter/tokenGraphemeSplitter.test.ts index caa10c26936..9f66b50b954 100644 --- a/packages/lib-engine/src/tokenGraphemeSplitter/tokenGraphemeSplitter.test.ts +++ b/packages/lib-engine/src/tokenGraphemeSplitter/tokenGraphemeSplitter.test.ts @@ -1,5 +1,5 @@ // oxlint-disable no-inline-comments -import * as assert from "node:assert/strict"; +import assert from "node:assert/strict"; import type { TokenHatSplittingMode } from "@cursorless/lib-common"; import { FakeIDE } from "@cursorless/lib-common"; import { TokenGraphemeSplitter, UNKNOWN } from "./tokenGraphemeSplitter"; diff --git a/packages/lib-engine/src/tokenizer/tokenizer.test.ts b/packages/lib-engine/src/tokenizer/tokenizer.test.ts index 45687869793..e3ad740b127 100644 --- a/packages/lib-engine/src/tokenizer/tokenizer.test.ts +++ b/packages/lib-engine/src/tokenizer/tokenizer.test.ts @@ -1,4 +1,4 @@ -import * as assert from "node:assert/strict"; +import assert from "node:assert/strict"; import { range } from "lodash-es"; import { FakeIDE } from "@cursorless/lib-common"; import { tokenize } from "."; diff --git a/packages/lib-engine/src/util/allocateHats/maxByFirstDiffering.test.ts b/packages/lib-engine/src/util/allocateHats/maxByFirstDiffering.test.ts index c00957a2952..de72f916138 100644 --- a/packages/lib-engine/src/util/allocateHats/maxByFirstDiffering.test.ts +++ b/packages/lib-engine/src/util/allocateHats/maxByFirstDiffering.test.ts @@ -1,4 +1,4 @@ -import * as assert from "node:assert/strict"; +import assert from "node:assert/strict"; import { maxByAllowingTies } from "./maxByFirstDiffering"; // known good but slow diff --git a/packages/lib-neovim-common/src/ide/neovim/NeovimIDE.ts b/packages/lib-neovim-common/src/ide/neovim/NeovimIDE.ts index 4f17880259b..c286cc9044b 100644 --- a/packages/lib-neovim-common/src/ide/neovim/NeovimIDE.ts +++ b/packages/lib-neovim-common/src/ide/neovim/NeovimIDE.ts @@ -1,4 +1,4 @@ -import * as path from "node:path"; +import path from "node:path"; import { pull } from "lodash-es"; import type { Buffer, NeovimClient, Window } from "neovim"; import { v4 as uuid } from "uuid"; diff --git a/packages/lib-node-common/src/Cheatsheet.ts b/packages/lib-node-common/src/Cheatsheet.ts index d0c69f5268f..d1d89fb08bf 100644 --- a/packages/lib-node-common/src/Cheatsheet.ts +++ b/packages/lib-node-common/src/Cheatsheet.ts @@ -1,5 +1,5 @@ import { readFile, writeFile } from "node:fs/promises"; -import * as path from "node:path"; +import path from "node:path"; import { produce } from "immer"; import { sortBy } from "lodash-es"; import { parse } from "node-html-parser"; diff --git a/packages/lib-node-common/src/FileSystemCommandHistoryStorage.ts b/packages/lib-node-common/src/FileSystemCommandHistoryStorage.ts index 2e2a5bfe5f7..524bae33b7f 100644 --- a/packages/lib-node-common/src/FileSystemCommandHistoryStorage.ts +++ b/packages/lib-node-common/src/FileSystemCommandHistoryStorage.ts @@ -1,5 +1,5 @@ -import * as fs from "node:fs/promises"; -import * as path from "node:path"; +import fs from "node:fs/promises"; +import path from "node:path"; import glob from "fast-glob"; import type { CommandHistoryEntry, diff --git a/packages/lib-node-common/src/FileSystemRawTreeSitterQueryProvider.ts b/packages/lib-node-common/src/FileSystemRawTreeSitterQueryProvider.ts index ead878516ec..968b85ecbe2 100644 --- a/packages/lib-node-common/src/FileSystemRawTreeSitterQueryProvider.ts +++ b/packages/lib-node-common/src/FileSystemRawTreeSitterQueryProvider.ts @@ -1,4 +1,4 @@ -import * as path from "node:path"; +import path from "node:path"; import { Notifier } from "@cursorless/lib-common"; import type { Disposable, diff --git a/packages/lib-node-common/src/FileSystemTalonSpokenForms.ts b/packages/lib-node-common/src/FileSystemTalonSpokenForms.ts index 430e748e317..471374d40af 100644 --- a/packages/lib-node-common/src/FileSystemTalonSpokenForms.ts +++ b/packages/lib-node-common/src/FileSystemTalonSpokenForms.ts @@ -1,5 +1,5 @@ import { readFile } from "node:fs/promises"; -import * as path from "node:path"; +import path from "node:path"; import type { Disposable, FileSystem, diff --git a/packages/lib-node-common/src/FileSystemTutorialContentProvider.ts b/packages/lib-node-common/src/FileSystemTutorialContentProvider.ts index a0788aa6264..2371a0ee62d 100644 --- a/packages/lib-node-common/src/FileSystemTutorialContentProvider.ts +++ b/packages/lib-node-common/src/FileSystemTutorialContentProvider.ts @@ -1,5 +1,5 @@ import { readFile, readdir } from "node:fs/promises"; -import * as path from "node:path"; +import path from "node:path"; import type { RawTutorialContent, TestCaseFixtureLegacy, diff --git a/packages/lib-node-common/src/getFixturePaths.ts b/packages/lib-node-common/src/getFixturePaths.ts index 6b2a50d20f5..e0b6a699ad7 100644 --- a/packages/lib-node-common/src/getFixturePaths.ts +++ b/packages/lib-node-common/src/getFixturePaths.ts @@ -1,4 +1,4 @@ -import * as path from "node:path"; +import path from "node:path"; import type { PlaintextScopeSupportFacet, ScopeSupportFacet, diff --git a/packages/lib-node-common/src/isOS.ts b/packages/lib-node-common/src/isOS.ts index fb3fe64699b..2f9c744af7b 100644 --- a/packages/lib-node-common/src/isOS.ts +++ b/packages/lib-node-common/src/isOS.ts @@ -1,4 +1,4 @@ -import * as os from "node:os"; +import os from "node:os"; export function isWindows() { return os.platform() === "win32"; diff --git a/packages/lib-node-common/src/loadFixture.ts b/packages/lib-node-common/src/loadFixture.ts index 6d6250f5481..106bf59db31 100644 --- a/packages/lib-node-common/src/loadFixture.ts +++ b/packages/lib-node-common/src/loadFixture.ts @@ -1,10 +1,12 @@ -import { readFile } from "node:fs/promises"; -import * as yaml from "js-yaml"; +import fsp from "node:fs/promises"; +import { load } from "js-yaml"; import type { TestCaseFixtureLegacy } from "@cursorless/lib-common"; -export async function loadFixture( - path: string, -): Promise { - const buffer = await readFile(path); - return yaml.load(buffer.toString()) as TestCaseFixtureLegacy; +export function loadFixture(file: string): Promise { + return loadYamlFile(file); +} + +async function loadYamlFile(file: string): Promise { + const buffer = await fsp.readFile(file); + return load(buffer.toString()) as T; } diff --git a/packages/lib-node-common/src/runRecordedTest.ts b/packages/lib-node-common/src/runRecordedTest.ts index 6266a0054b7..2155cfe8b22 100644 --- a/packages/lib-node-common/src/runRecordedTest.ts +++ b/packages/lib-node-common/src/runRecordedTest.ts @@ -1,4 +1,4 @@ -import * as assert from "node:assert/strict"; +import assert from "node:assert/strict"; import { promises as fsp } from "node:fs"; import { isUndefined } from "lodash-es"; import type { diff --git a/packages/lib-node-common/src/walkAsync.ts b/packages/lib-node-common/src/walkAsync.ts index fd0374acdc2..b47b31cdea6 100644 --- a/packages/lib-node-common/src/walkAsync.ts +++ b/packages/lib-node-common/src/walkAsync.ts @@ -1,5 +1,5 @@ import { readdir } from "node:fs/promises"; -import * as path from "node:path"; +import path from "node:path"; import { flatten } from "lodash-es"; /** diff --git a/packages/lib-node-common/src/walkSync.ts b/packages/lib-node-common/src/walkSync.ts index 822e4565bca..c8d46985e16 100644 --- a/packages/lib-node-common/src/walkSync.ts +++ b/packages/lib-node-common/src/walkSync.ts @@ -1,5 +1,5 @@ import { readdirSync } from "node:fs"; -import * as path from "node:path"; +import path from "node:path"; /** * Note: Returns full paths diff --git a/packages/lib-sentence-parser/src/sbd.ts b/packages/lib-sentence-parser/src/sbd.ts index 361797003d9..78c25d053f1 100644 --- a/packages/lib-sentence-parser/src/sbd.ts +++ b/packages/lib-sentence-parser/src/sbd.ts @@ -1,6 +1,18 @@ // oxlint-disable max-depth -import * as Match from "./Match"; -import * as stringHelper from "./stringHelper"; +import { + isBoundaryChar, + isCommonAbbreviation, + isConcatenated, + isCustomAbbreviation, + isDottedAbbreviation, + isNameAbbreviation, + isNumber, + isPhoneNr, + isSentenceStarter, + isTimeAbbreviation, + isURL, + setAbbreviations, +} from "./Match"; const newline_placeholder = " @~@ "; const newline_placeholder_t = newline_placeholder.trim(); @@ -42,7 +54,7 @@ export function getSentences( ...userOptions, }; - Match.setAbbreviations(options.abbreviations); + setAbbreviations(options.abbreviations); if (options.newlineBoundaries) { text = text.replace(addNewLineBoundaries, newline_placeholder); @@ -89,8 +101,9 @@ export function getSentences( } if ( - Match.isBoundaryChar(words[i]) || - stringHelper.endsWithChar(words[i], "?!") || + isBoundaryChar(words[i]) || + words[i].endsWith("?") || + words[i].endsWith("!") || words[i] === newline_placeholder_t ) { if (options.newlineBoundaries && words[i] === newline_placeholder_t) { @@ -105,17 +118,14 @@ export function getSentences( continue; } - if ( - stringHelper.endsWithChar(words[i], '"') || - stringHelper.endsWithChar(words[i], "”") - ) { + if (words[i].endsWith('"') || words[i].endsWith("”")) { words[i] = words[i].slice(0, -1); } // A dot might indicate the end sentences // Exception: The next sentence starts with a word (non abbreviation) // that has a capital letter. - if (stringHelper.endsWithChar(words[i], ".")) { + if (words[i].endsWith(".")) { // Check if there is a next word // This probably needs to be improved with machine learning if (i + 1 < L) { @@ -125,40 +135,40 @@ export function getSentences( } // Common abbr. that often do not end sentences - if (Match.isCommonAbbreviation(words[i])) { + if (isCommonAbbreviation(words[i])) { continue; } // Next word starts with capital word, but current sentence is // quite short - if (Match.isSentenceStarter(words[i + 1])) { - if (Match.isTimeAbbreviation(words[i], words[i + 1])) { + if (isSentenceStarter(words[i + 1])) { + if (isTimeAbbreviation(words[i], words[i + 1])) { continue; } // Dealing with names at the start of sentences - if (Match.isNameAbbreviation(wordCount, words.slice(i, 6))) { + if (isNameAbbreviation(wordCount, words.slice(i, 6))) { continue; } - if (Match.isNumber(words[i + 1])) { - if (Match.isCustomAbbreviation(words[i])) { + if (isNumber(words[i + 1])) { + if (isCustomAbbreviation(words[i])) { continue; } } } else { // Skip ellipsis - if (stringHelper.endsWith(words[i], "..")) { + if (words[i].endsWith("..")) { continue; } //// Skip abbreviations // Short words + dot or a dot after each letter - if (Match.isDottedAbbreviation(words[i])) { + if (isDottedAbbreviation(words[i])) { continue; } - if (Match.isNameAbbreviation(wordCount, words.slice(i, 5))) { + if (isNameAbbreviation(wordCount, words.slice(i, 5))) { continue; } } @@ -173,22 +183,22 @@ export function getSentences( // Check if the word has a dot in it if ((index = words[i].indexOf(".")) > -1) { - if (Match.isNumber(words[i], index)) { + if (isNumber(words[i], index)) { continue; } // Custom dotted abbreviations (like K.L.M or I.C.T) - if (Match.isDottedAbbreviation(words[i])) { + if (isDottedAbbreviation(words[i])) { continue; } // Skip urls / emails and the like - if (Match.isURL(words[i]) || Match.isPhoneNr(words[i])) { + if (isURL(words[i]) || isPhoneNr(words[i])) { continue; } } - if ((temp = Match.isConcatenated(words[i]))) { + if ((temp = isConcatenated(words[i]))) { current.pop(); current.push(temp[0]); sentences.push(current); diff --git a/packages/lib-sentence-parser/src/stringHelper.ts b/packages/lib-sentence-parser/src/stringHelper.ts deleted file mode 100644 index 4a3e053f76a..00000000000 --- a/packages/lib-sentence-parser/src/stringHelper.ts +++ /dev/null @@ -1,11 +0,0 @@ -export function endsWithChar(word: string, c: string) { - if (c.length > 1) { - return c.includes(word.slice(-1)); - } - - return word.slice(-1) === c; -} - -export function endsWith(word: string, end: string) { - return word.slice(word.length - end.length) === end; -} diff --git a/packages/lib-sentence-parser/src/test/abbr.test.ts b/packages/lib-sentence-parser/src/test/abbr.test.ts index d16c75ea499..a59d46266d2 100644 --- a/packages/lib-sentence-parser/src/test/abbr.test.ts +++ b/packages/lib-sentence-parser/src/test/abbr.test.ts @@ -1,11 +1,12 @@ -import * as assert from "node:assert/strict"; -import * as parser from ".."; +import assert from "node:assert/strict"; +import { getSentences } from ".."; +import type { SentenceParserOptions } from ".."; suite("sentence-parser: Abbreviations in sentences", () => { suite("Skip dotted abbreviations", () => { const entry = "Lorem ipsum, dolor sed amat frequentor minimus In I.C.T we have multiple challenges! There should only be two sentences."; - const sentences = parser.getSentences(entry); + const sentences = getSentences(entry); test("should get 2 sentences", () => { assert.equal(sentences.length, 2); @@ -15,7 +16,7 @@ suite("sentence-parser: Abbreviations in sentences", () => { suite("Skip dotted abbreviations (B)", () => { const entry = "From amat frequentor minimus hello there at 8 a.m. there p.m. should only be two sentences."; - const sentences = parser.getSentences(entry); + const sentences = getSentences(entry); test("should get 1 sentence", () => { assert.equal(sentences.length, 1); @@ -25,7 +26,7 @@ suite("sentence-parser: Abbreviations in sentences", () => { suite("Skip dotted abbreviations (C)", () => { const entry = "The school, called Booker T and Stevie Ray's Wrestling and Mixed Mart Arts Academy, will have an open house 2-6 p.m. Saturday."; - const sentences = parser.getSentences(entry); + const sentences = getSentences(entry); test("should get 1 sentence", () => { assert.equal(sentences.length, 1); @@ -35,7 +36,7 @@ suite("sentence-parser: Abbreviations in sentences", () => { suite("Skip common abbreviations", () => { const entry = "Fig. 2. displays currency rates i.e. something libsum. Currencies widely available (i.e. euro, dollar, pound), or alternatively (e.g. €, $, etc.)"; - const sentences = parser.getSentences(entry); + const sentences = getSentences(entry); test("should get 2 sentences", () => { assert.equal(sentences.length, 2); @@ -45,7 +46,7 @@ suite("sentence-parser: Abbreviations in sentences", () => { suite("Skip two worded abbreviations", () => { const entry = "Claims 1–6 and 15–26 are rejected under pre-AIA 35 USC § 103(a) as being unpatentable over Chalana et al. (US 2012/0179503) in view of Oh (US 2013/0013993)."; - const sentences = parser.getSentences(entry); + const sentences = getSentences(entry); test("should get 1 sentence", () => { assert.equal(sentences.length, 1); @@ -55,7 +56,7 @@ suite("sentence-parser: Abbreviations in sentences", () => { suite("Skip two worded abbreviations", () => { const entry = "Et al. is an abbreviation of the Latin loanphrase et alii, meaning and others. It is similar to etc. (short for et cetera, meaning and the rest), but whereas etc. applies to things, et al. applies to people."; - const sentences = parser.getSentences(entry); + const sentences = getSentences(entry); test("should get 2 sentences", () => { assert.equal(sentences.length, 2); @@ -63,7 +64,7 @@ suite("sentence-parser: Abbreviations in sentences", () => { }); suite("Use other languages (accented)", () => { - const options: parser.SentenceParserOptions = { + const options: SentenceParserOptions = { newlineBoundaries: true, preserveWhitespace: true, abbreviations: ["pré"], @@ -71,7 +72,7 @@ suite("sentence-parser: Abbreviations in sentences", () => { const entry = "Random words pré. other words and things. Different status updates all assigned"; - const sentences = parser.getSentences(entry, options); + const sentences = getSentences(entry, options); test("should get 2 sentences", () => { assert.equal(sentences.length, 2); @@ -81,8 +82,8 @@ suite("sentence-parser: Abbreviations in sentences", () => { suite("Use other languages", () => { const entry = "Trzeba tu coś napisać, np. fragment odnoszący się do pkt. 3 wcześniejszego tekstu."; - const sentencesEN = parser.getSentences(entry); - const sentencesPL = parser.getSentences(entry, { + const sentencesEN = getSentences(entry); + const sentencesPL = getSentences(entry, { abbreviations: ["np", "pkt"], }); @@ -92,7 +93,7 @@ suite("sentence-parser: Abbreviations in sentences", () => { }); test("should not permanently override abbreviations", () => { - const sentences = parser.getSentences(entry); + const sentences = getSentences(entry); assert.equal(sentences.length, 3); }); }); @@ -106,7 +107,7 @@ suite("sentence-parser: Abbreviations in sentences", () => { const entry = "матрицю SWOT- аналізу (табл. hello). Факторами макросередовища (рис. 5.8.). Things on a new line"; - const sentencesCyrillic = parser.getSentences(entry, options); + const sentencesCyrillic = getSentences(entry, options); test("should get 3 sentences", () => { assert.equal(sentencesCyrillic.length, 3); diff --git a/packages/lib-sentence-parser/src/test/empty.test.ts b/packages/lib-sentence-parser/src/test/empty.test.ts index b3623ca4adb..ae25a5e65cd 100644 --- a/packages/lib-sentence-parser/src/test/empty.test.ts +++ b/packages/lib-sentence-parser/src/test/empty.test.ts @@ -1,17 +1,17 @@ -import * as assert from "node:assert/strict"; -import * as parser from ".."; +import assert from "node:assert/strict"; +import { getSentences } from ".."; suite("sentence-parser: Empty", () => { suite("string", () => { let entry = ""; - let sentences = parser.getSentences(entry); + let sentences = getSentences(entry); test("should not get a sentence", () => { assert.equal(sentences.length, 0); }); entry = " \n\n "; - sentences = parser.getSentences(entry); + sentences = getSentences(entry); test("should not get a sentence from whitespace", () => { assert.equal(sentences.length, 0); @@ -20,7 +20,7 @@ suite("sentence-parser: Empty", () => { suite("symbols only", () => { const entry = "^&%(*&"; - const sentences = parser.getSentences(entry); + const sentences = getSentences(entry); test("should not single entry", () => { assert.equal(sentences.length, 1); diff --git a/packages/lib-sentence-parser/src/test/lists.test.ts b/packages/lib-sentence-parser/src/test/lists.test.ts index 1d5b3ed7c56..9efe4c32515 100644 --- a/packages/lib-sentence-parser/src/test/lists.test.ts +++ b/packages/lib-sentence-parser/src/test/lists.test.ts @@ -1,10 +1,10 @@ -import * as assert from "node:assert/strict"; -import * as parser from ".."; +import assert from "node:assert/strict"; +import { getSentences } from ".."; suite("sentence-parser: Lists", () => { suite("It should skip list enumeration", () => { const entry = "1. The item\n2. Another item"; - const sentences = parser.getSentences(entry, { newlineBoundaries: true }); + const sentences = getSentences(entry, { newlineBoundaries: true }); test("should get 2 sentences", () => { assert.equal(sentences.length, 2); @@ -13,7 +13,7 @@ suite("sentence-parser: Lists", () => { suite("It should skip alternative list enumeration", () => { const entry = "a. The item\nab. Another item\n(1.) Third item"; - const sentences = parser.getSentences(entry, { newlineBoundaries: true }); + const sentences = getSentences(entry, { newlineBoundaries: true }); test("should get 3 sentences", () => { assert.equal(sentences.length, 3); @@ -22,7 +22,7 @@ suite("sentence-parser: Lists", () => { suite("It should keep empty list enumeration", () => { const entry = "a. The item\nzz.\nab.\ncd. Hello"; - const sentences = parser.getSentences(entry, { newlineBoundaries: true }); + const sentences = getSentences(entry, { newlineBoundaries: true }); test("should get 4 sentences", () => { assert.equal(sentences.length, 4); diff --git a/packages/lib-sentence-parser/src/test/multiple_sentences.test.ts b/packages/lib-sentence-parser/src/test/multiple_sentences.test.ts index bc85ce18255..a1613667da5 100644 --- a/packages/lib-sentence-parser/src/test/multiple_sentences.test.ts +++ b/packages/lib-sentence-parser/src/test/multiple_sentences.test.ts @@ -1,10 +1,10 @@ -import * as assert from "node:assert/strict"; -import * as parser from ".."; +import assert from "node:assert/strict"; +import { getSentences } from ".."; suite("sentence-parser: Multiple sentences", () => { suite("Include ellipsis as ending if starts with capital", () => { const entry = "First sentence... Another sentence"; - const sentences = parser.getSentences(entry); + const sentences = getSentences(entry); test("should get two sentences", () => { assert.equal(sentences.length, 2); @@ -14,7 +14,7 @@ suite("sentence-parser: Multiple sentences", () => { suite("Two sentences", () => { const entry = "Lorem ipsum, dolor sed amat frequentor minimus. Second sentence."; - const sentences = parser.getSentences(entry); + const sentences = getSentences(entry); test("should get 2 sentences", () => { assert.equal(sentences.length, 2); @@ -24,7 +24,7 @@ suite("sentence-parser: Multiple sentences", () => { suite("Difficult two sentences (A)", () => { const entry = "On Jan. 20, former Sen. Barack Obama became the 44th President of the U.S. Millions attended the Inauguration."; - const sentences = parser.getSentences(entry); + const sentences = getSentences(entry); test("should get two sentences", () => { assert.equal(sentences.length, 2); @@ -34,7 +34,7 @@ suite("sentence-parser: Multiple sentences", () => { suite("Difficult two sentences (B)", () => { const entry = "Sen. Barack Obama became the 44th President of the US. Millions attended."; - const sentences = parser.getSentences(entry); + const sentences = getSentences(entry); test("should get two sentence", () => { assert.equal(sentences.length, 2); @@ -44,7 +44,7 @@ suite("sentence-parser: Multiple sentences", () => { suite("Difficult two sentences (C)", () => { const entry = "Barack Obama, previously Sen. of lorem ipsum, became the 44th President of the U.S. Millions attended."; - const sentences = parser.getSentences(entry); + const sentences = getSentences(entry); test("should get two sentence", () => { assert.equal(sentences.length, 2); @@ -54,7 +54,7 @@ suite("sentence-parser: Multiple sentences", () => { suite("Difficult two sentences (D)", () => { const entry = "Baril, a Richmond lawyer once nominated for a federal prosecutors job, endorsed a faith-based drug initiative in local jails patterned after the Henrico County jails therapeutic program called Project R.I.S.E. Just as important, he had a great foil across the net."; - const sentences = parser.getSentences(entry); + const sentences = getSentences(entry); test("should get two sentence", () => { assert.equal(sentences.length, 2); @@ -64,7 +64,7 @@ suite("sentence-parser: Multiple sentences", () => { suite("Difficult two sentences (E)", () => { const entry = "Newsletter AIDs CARE, EDUCATION AND TRAINING Issue No. 7. Acet Home Care, which moves into the building in July, will share the offices with two other AIDS charities, P.A.L.S. (Portsmouth AIDS Link Support) and the Link Project."; - const sentences = parser.getSentences(entry); + const sentences = getSentences(entry); test("should get two sentence", () => { assert.equal(sentences.length, 2); @@ -74,7 +74,7 @@ suite("sentence-parser: Multiple sentences", () => { suite("Difficult two sentences (F)", () => { const entry = "Another is expanded hours of operation -- from fewer than five hours a day to 9:30 a.m. to 4 p.m. Monday through Saturday. Sunday remains closed."; - const sentences = parser.getSentences(entry); + const sentences = getSentences(entry); test("should get two sentence", () => { assert.equal(sentences.length, 2); @@ -84,7 +84,7 @@ suite("sentence-parser: Multiple sentences", () => { suite("Difficult two sentences (G)", () => { const entry = "Gold Wing Road Rider's Association - Coffee break, Guzzardo's Italian Villa, eat, 6 p.m.; ride, 7 p.m. Then at 9 p.m. go home."; - const sentences = parser.getSentences(entry); + const sentences = getSentences(entry); test("should get two sentence", () => { assert.equal(sentences.length, 2); @@ -95,7 +95,7 @@ suite("sentence-parser: Multiple sentences", () => { "Dot in middle of word is not skipped if followed by capital letter", () => { const entry = "Hello Barney.The bird in the word."; - const sentences = parser.getSentences(entry); + const sentences = getSentences(entry); test("should get 2 sentences", () => { assert.equal(sentences.length, 2); @@ -106,7 +106,7 @@ suite("sentence-parser: Multiple sentences", () => { suite("Question- and exlamation mark", () => { const entry = "Hello this is my first sentence? There is also a second! A third"; - const sentences = parser.getSentences(entry); + const sentences = getSentences(entry); test("should get 3 sentences", () => { assert.equal(sentences.length, 3); @@ -115,7 +115,7 @@ suite("sentence-parser: Multiple sentences", () => { suite("It should skip keywords/code with a dot in it", () => { const entry = "HELLO A.TOP IS NICE"; - const sentences = parser.getSentences(entry); + const sentences = getSentences(entry); test("should get 2 sentences", () => { assert.equal(sentences.length, 1); @@ -125,7 +125,7 @@ suite("sentence-parser: Multiple sentences", () => { suite("If newlines are boundaries", () => { const entry = "Search on http://google.com\n\nThen send me an email: gg@gggg.kk"; - const sentences = parser.getSentences(entry, { newlineBoundaries: true }); + const sentences = getSentences(entry, { newlineBoundaries: true }); test("should get 2 sentences", () => { assert.equal(sentences.length, 2); @@ -135,7 +135,7 @@ suite("sentence-parser: Multiple sentences", () => { suite("Sentences with quotations", () => { const entry = "“If there’s no balance and your boss doesn’t provide support and work that’s meaningful, your chances of burning out are great.” What bothers most people in situations like these is “the lack of boundaries,” says Nancy Rothbard, the David Pottruck Professor of Management at the University of Pennsylvania’s Wharton School."; - const sentences = parser.getSentences(entry, { newlineBoundaries: true }); + const sentences = getSentences(entry, { newlineBoundaries: true }); test("should get 2 sentences", () => { assert.equal(sentences.length, 2); @@ -145,7 +145,7 @@ suite("sentence-parser: Multiple sentences", () => { suite("Sentences with quotations", () => { const entry = "“If there’s no balance! And your boss doesn’t provide support and work that’s meaningful, your chances of burning out are great.” What bothers most people in situations like these is “the lack of boundaries,” says Nancy Rothbard, the David Pottruck Professor of Management at the University of Pennsylvania’s Wharton School."; - const sentences = parser.getSentences(entry, { newlineBoundaries: true }); + const sentences = getSentences(entry, { newlineBoundaries: true }); test("should get 3 sentences", () => { assert.equal(sentences.length, 3); @@ -154,7 +154,7 @@ suite("sentence-parser: Multiple sentences", () => { suite("Sentences with a name ending a sentence", () => { const entry = `If your boss assumes he can interrupt you any time and it’s "impacting the way you do your job," you should communicate that "you feel stretched," says Hill. A growing body of research shows that being “always on” hurts results.`; - const sentences = parser.getSentences(entry, { newlineBoundaries: true }); + const sentences = getSentences(entry, { newlineBoundaries: true }); test("should get 2 sentences", () => { assert.equal(sentences.length, 2); @@ -164,7 +164,7 @@ suite("sentence-parser: Multiple sentences", () => { suite("If newlines are boundaries (B)", () => { const entry = "FAMILIY HISTORY ========================================== Nothing interesting"; - const sentences = parser.getSentences(entry, { newlineBoundaries: true }); + const sentences = getSentences(entry, { newlineBoundaries: true }); test("should get 2 sentences", () => { assert.equal(sentences.length, 2); diff --git a/packages/lib-sentence-parser/src/test/newline.test.ts b/packages/lib-sentence-parser/src/test/newline.test.ts index 6d034b4e7f3..f02f577381e 100644 --- a/packages/lib-sentence-parser/src/test/newline.test.ts +++ b/packages/lib-sentence-parser/src/test/newline.test.ts @@ -1,11 +1,11 @@ -import * as assert from "node:assert/strict"; -import * as parser from ".."; +import assert from "node:assert/strict"; +import { getSentences } from ".."; suite("sentence-parser: Save newlines", () => { suite("Basic", () => { const entry = "First sentence... Another list: \n - green \n - blue \n - red"; - const sentences = parser.getSentences(entry); + const sentences = getSentences(entry); test("second sentence should have newlines", () => { assert.equal(sentences[1], "Another list: \n - green \n - blue \n - red"); @@ -15,7 +15,7 @@ suite("sentence-parser: Save newlines", () => { suite("Sentence without lists", () => { const entry = "First sentence... Another sentence.\nThis is a new paragraph."; - const sentences = parser.getSentences(entry); + const sentences = getSentences(entry); test("second sentence should have newlines", () => { assert.equal(sentences.length, 3); @@ -25,7 +25,7 @@ suite("sentence-parser: Save newlines", () => { suite("With option to use newlines as sentence boundaries", () => { const entry = "First sentence... Another list: \n - green \n - blue \n - red"; - const sentences = parser.getSentences(entry, { newlineBoundaries: true }); + const sentences = getSentences(entry, { newlineBoundaries: true }); test("second sentence should have newlines", () => { assert.equal(sentences.length, 5); @@ -39,7 +39,7 @@ suite("sentence-parser: Save newlines", () => { \ Peter Piper Picked a peck of pickled peppers. A peck of pickled peppers peter piper picked."; - const sentences = parser.getSentences(entry); + const sentences = getSentences(entry); test("Should have 3 sentences ending in periods", () => { assert.equal(sentences[0], "How now brown cow."); @@ -55,7 +55,7 @@ suite("sentence-parser: Save newlines", () => { Peter Piper Picked a peck of pickled peppers. A peck of pickled peppers peter piper picked.`; - const sentences = parser.getSentences(entry, { newlineBoundaries: true }); + const sentences = getSentences(entry, { newlineBoundaries: true }); test("Should have 3 sentences ending in periods", () => { assert.equal(sentences[0], "How now brown cow."); diff --git a/packages/lib-sentence-parser/src/test/preserve_whitespace.test.ts b/packages/lib-sentence-parser/src/test/preserve_whitespace.test.ts index 0b28bfe19b0..b95f561e31a 100644 --- a/packages/lib-sentence-parser/src/test/preserve_whitespace.test.ts +++ b/packages/lib-sentence-parser/src/test/preserve_whitespace.test.ts @@ -1,5 +1,5 @@ -import * as assert from "node:assert/strict"; -import * as parser from ".."; +import assert from "node:assert/strict"; +import { getSentences } from ".."; const options = { preserveWhitespace: true }; @@ -7,7 +7,7 @@ suite("sentence-parser: Preserve whitespace", () => { suite("Basic", () => { const entry = " This is\ta sentence with funny whitespace. And this is \tanother.\tHere is a third. "; - const sentences = parser.getSentences(entry, options); + const sentences = getSentences(entry, options); test("should get 3 sentences", () => { assert.equal(sentences.length, 3); @@ -26,7 +26,7 @@ suite("sentence-parser: Preserve whitespace", () => { suite("No effect if newline_boundaries are specified", () => { const entry = " This is\ta sentence with funny whitespace. "; - const sentences = parser.getSentences(entry, { + const sentences = getSentences(entry, { newlineBoundaries: true, ...options, }); @@ -43,7 +43,7 @@ suite("sentence-parser: Preserve whitespace", () => { suite("It should properly join single-word list sentences", () => { const entry = "iv. determining that the advertisement in the lift study is a candidate ad for the user, computing whether to include the user in a test group or a control group for the lift study ([0032]), v. based on the computation indicating that the user is in the control group, holding out the advertisement from completing the ad selection process for the user ([0032]), and vi. based on the computation indicating that the user is in the test group, allowing the advertisement to continue through the ad selection process such that the user receives either the advertisement in the lift study or another advertisement ([0032]); and "; - const sentences = parser.getSentences(entry, options); + const sentences = getSentences(entry, options); test("should get the correct sentences", () => { assert.deepEqual(sentences, [ diff --git a/packages/lib-sentence-parser/src/test/single_sentence.test.ts b/packages/lib-sentence-parser/src/test/single_sentence.test.ts index 85cd706b339..8faf75f4bbf 100644 --- a/packages/lib-sentence-parser/src/test/single_sentence.test.ts +++ b/packages/lib-sentence-parser/src/test/single_sentence.test.ts @@ -1,10 +1,10 @@ -import * as assert from "node:assert/strict"; -import * as parser from ".."; +import assert from "node:assert/strict"; +import { getSentences } from ".."; suite("sentence-parser: Single sentences", () => { suite("Basic", () => { const entry = "First sentence."; - const sentences = parser.getSentences(entry); + const sentences = getSentences(entry); test("should get one sentence", () => { assert.equal(sentences.length, 1); @@ -13,7 +13,7 @@ suite("sentence-parser: Single sentences", () => { suite("Skip ellipsis", () => { const entry = "First sentence... another sentence"; - const sentences = parser.getSentences(entry); + const sentences = getSentences(entry); test("should get one sentence", () => { assert.equal(sentences.length, 1); @@ -23,7 +23,7 @@ suite("sentence-parser: Single sentences", () => { suite("Difficult single sentence (A)", () => { const entry = "On Jan. 20, former Sen. Barack Obama became the 44th President of the U.S."; - const sentences = parser.getSentences(entry); + const sentences = getSentences(entry); test("should get one sentence", () => { assert.equal(sentences.length, 1); @@ -33,7 +33,7 @@ suite("sentence-parser: Single sentences", () => { suite("Difficult sentence (B)", () => { const entry = "It happened around 5:30 p.m. in the 500 block of W. 82nd St. Investigators say Terrence Taylor, 22, and Deontrell Sloan, 17, got into an argument over money during the game."; - const sentences = parser.getSentences(entry); + const sentences = getSentences(entry); test("should get 1 sentence", () => { assert.equal(sentences.length, 1); @@ -43,7 +43,7 @@ suite("sentence-parser: Single sentences", () => { suite("Difficult sentence (C)", () => { const entry = "GARY Mayor Scott L. King has declared a 'cash crisis' and has asked city department heads to put off all non-essential spending until June."; - const sentences = parser.getSentences(entry); + const sentences = getSentences(entry); test("should get 1 sentence", () => { assert.equal(sentences.length, 1); @@ -53,7 +53,7 @@ suite("sentence-parser: Single sentences", () => { suite("Difficult sentence (D)", () => { const entry = "HOWELL, Mich. - Blissfield was only nine outs away from ending the longest winning streak"; - const sentences = parser.getSentences(entry); + const sentences = getSentences(entry); test("should get 1 sentence", () => { assert.equal(sentences.length, 1); @@ -63,7 +63,7 @@ suite("sentence-parser: Single sentences", () => { suite("Difficult sentence (E)", () => { const entry = "33 FORT LAUDERDALE U.S. President George W Bush touted free trade as a means of strengthening democracy"; - const sentences = parser.getSentences(entry); + const sentences = getSentences(entry); test("should get 1 sentence", () => { assert.equal(sentences.length, 1); @@ -73,7 +73,7 @@ suite("sentence-parser: Single sentences", () => { suite("Difficult sentence (F)", () => { const entry = "Mike Tyler rides his bike on Del. 1 near Lewes early last month"; - const sentences = parser.getSentences(entry); + const sentences = getSentences(entry); test("should get 1 sentence", () => { assert.equal(sentences.length, 1); @@ -83,7 +83,7 @@ suite("sentence-parser: Single sentences", () => { // Questionable behavior, but can only be fixed using ML? suite("Dot in middle of word is skipped", () => { const entry = "Hello.this is my first sentence."; - const sentences = parser.getSentences(entry); + const sentences = getSentences(entry); test("should get 1 sentences", () => { assert.equal(sentences.length, 1); @@ -93,7 +93,7 @@ suite("sentence-parser: Single sentences", () => { suite("Punctuation is skipped inside brackets", () => { const entry = "Lorem ipsum, dolor sed amat frequentor minimus with a sentence [example?] that should not (Though sometimes...) be two or more (but one!) sentences."; - const sentences = parser.getSentences(entry); + const sentences = getSentences(entry); test("should get 1 sentence", () => { assert.equal(sentences.length, 1); diff --git a/packages/lib-sentence-parser/src/test/symbols.test.ts b/packages/lib-sentence-parser/src/test/symbols.test.ts index 5ded4d80a03..099073f4c04 100644 --- a/packages/lib-sentence-parser/src/test/symbols.test.ts +++ b/packages/lib-sentence-parser/src/test/symbols.test.ts @@ -1,10 +1,10 @@ -import * as assert from "node:assert/strict"; -import * as parser from ".."; +import assert from "node:assert/strict"; +import { getSentences } from ".."; suite("sentence-parser: Sentences with symbols", () => { suite("It should skip numbers", () => { const entry = "10 times 10 = 10.00^2. 13.000 14.50 and 14,000,000.50"; - const sentences = parser.getSentences(entry); + const sentences = getSentences(entry); test("should get 2 sentences", () => { assert.equal(sentences.length, 2); @@ -14,7 +14,7 @@ suite("sentence-parser: Sentences with symbols", () => { suite("It should skip urls and emails", () => { const entry = "Search on http://google.com. Then send me an email: fabien@somedomain.com or fabien@anotherdomain.cc"; - const sentences = parser.getSentences(entry); + const sentences = getSentences(entry); test("should get 2 sentences", () => { assert.equal(sentences.length, 2); @@ -23,7 +23,7 @@ suite("sentence-parser: Sentences with symbols", () => { suite("It should skip phone numbers", () => { const entry = "Call +44.3847838 for whatever."; - const sentences = parser.getSentences(entry); + const sentences = getSentences(entry); test("should get 1 sentence", () => { assert.equal(sentences.length, 1); @@ -33,7 +33,7 @@ suite("sentence-parser: Sentences with symbols", () => { suite("It should skip money with currency indication", () => { const entry = "I paid €12.50 for that CD. Twelve dollars and fifty cent ($12.50). Ten pounds - £10.00 it is fine."; - const sentences = parser.getSentences(entry); + const sentences = getSentences(entry); test("should get 1 sentence", () => { assert.equal(sentences.length, 3); @@ -43,7 +43,7 @@ suite("sentence-parser: Sentences with symbols", () => { suite("Newlines/paragraph must be enabled to end sentences", () => { const entry = "The humble bundle sale\r\nDate: Monday-Fri starting 2015-01-01"; - const sentences = parser.getSentences(entry); + const sentences = getSentences(entry); test("should get 1 sentences", () => { assert.equal(sentences.length, 1); @@ -53,7 +53,7 @@ suite("sentence-parser: Sentences with symbols", () => { suite("Newlines/paragraph enabled ends sentences", () => { const entry = "The humble bundle sale\r\nDate: Monday-Fri starting 2015-01-01\nSales starting at ¤2,50"; - const sentences = parser.getSentences(entry, { newlineBoundaries: true }); + const sentences = getSentences(entry, { newlineBoundaries: true }); test("should get 3 sentences", () => { assert.equal(sentences.length, 3); diff --git a/packages/lib-test-case-recorder/src/ScopeTestRecorder.ts b/packages/lib-test-case-recorder/src/ScopeTestRecorder.ts index bd79015364b..1021b71e7ce 100644 --- a/packages/lib-test-case-recorder/src/ScopeTestRecorder.ts +++ b/packages/lib-test-case-recorder/src/ScopeTestRecorder.ts @@ -1,6 +1,6 @@ -import * as fs from "node:fs"; -import * as fsPromises from "node:fs/promises"; -import * as path from "node:path"; +import fs from "node:fs"; +import fsPromises from "node:fs/promises"; +import path from "node:path"; import { ScopeSupportFacetLevel, groupBy, diff --git a/packages/lib-test-case-recorder/src/TestCaseRecorder.ts b/packages/lib-test-case-recorder/src/TestCaseRecorder.ts index b97d416bbcb..0e4ab674bad 100644 --- a/packages/lib-test-case-recorder/src/TestCaseRecorder.ts +++ b/packages/lib-test-case-recorder/src/TestCaseRecorder.ts @@ -1,6 +1,6 @@ -import * as fs from "node:fs"; +import fs from "node:fs"; import { access, readFile, unlink } from "node:fs/promises"; -import * as path from "node:path"; +import path from "node:path"; import { invariant } from "immutability-helper"; import { merge } from "lodash-es"; import type { diff --git a/packages/lib-vscode-common/src/getExtensionApi.ts b/packages/lib-vscode-common/src/getExtensionApi.ts index 641cb03d28a..901cfad0b0c 100644 --- a/packages/lib-vscode-common/src/getExtensionApi.ts +++ b/packages/lib-vscode-common/src/getExtensionApi.ts @@ -1,4 +1,4 @@ -import * as vscode from "vscode"; +import vscode from "vscode"; import type { Query, Tree } from "web-tree-sitter"; import type { CommandServerApi } from "@cursorless/lib-common"; import type { VscodeTestHelpers } from "./TestHelpers"; diff --git a/packages/lib-vscode-common/src/runCommand.ts b/packages/lib-vscode-common/src/runCommand.ts index 67320116feb..09adc90fe85 100644 --- a/packages/lib-vscode-common/src/runCommand.ts +++ b/packages/lib-vscode-common/src/runCommand.ts @@ -1,4 +1,4 @@ -import * as vscode from "vscode"; +import vscode from "vscode"; import type { ActionDescriptor, Command, diff --git a/packages/lib-vscode-common/src/testUtil/openNewEditor.ts b/packages/lib-vscode-common/src/testUtil/openNewEditor.ts index 718f2cf48b2..9c68b261ff2 100644 --- a/packages/lib-vscode-common/src/testUtil/openNewEditor.ts +++ b/packages/lib-vscode-common/src/testUtil/openNewEditor.ts @@ -1,4 +1,4 @@ -import * as vscode from "vscode"; +import vscode from "vscode"; import { getTestHelpers } from "../getExtensionApi"; import { closeUiElements } from "./closeUiElements"; diff --git a/packages/lib-vscode-common/src/vscodeUtil.ts b/packages/lib-vscode-common/src/vscodeUtil.ts index 1b9145525b1..a048aad64b9 100644 --- a/packages/lib-vscode-common/src/vscodeUtil.ts +++ b/packages/lib-vscode-common/src/vscodeUtil.ts @@ -1,4 +1,4 @@ -import * as vscode from "vscode"; +import vscode from "vscode"; import type { EndOfLine } from "@cursorless/lib-common"; import { Position, Range, Selection } from "@cursorless/lib-common"; diff --git a/packages/test-neovim-e2e/package.json b/packages/test-neovim-e2e/package.json index 4a9c79cd57c..0ac73cc4801 100644 --- a/packages/test-neovim-e2e/package.json +++ b/packages/test-neovim-e2e/package.json @@ -15,10 +15,8 @@ "@cursorless/lib-node-common": "workspace:*" }, "devDependencies": { - "@types/js-yaml": "^4.0.9", "@types/mocha": "^10.0.10", "@types/sinon": "^21.0.1", - "js-yaml": "^4.2.0", "neovim": "^5.4.0", "sinon": "^22.0.0" } diff --git a/packages/test-neovim-e2e/src/endToEndTestSetup.ts b/packages/test-neovim-e2e/src/endToEndTestSetup.ts index c3b49898bee..38b20b2d733 100644 --- a/packages/test-neovim-e2e/src/endToEndTestSetup.ts +++ b/packages/test-neovim-e2e/src/endToEndTestSetup.ts @@ -1,5 +1,5 @@ import type { Context } from "mocha"; -import * as sinon from "sinon"; +import { restore } from "sinon"; import type { IDE } from "@cursorless/lib-common"; import { shouldUpdateFixtures, sleep, SpyIDE } from "@cursorless/lib-common"; import type { NeovimIDE } from "@cursorless/lib-neovim-common"; @@ -40,7 +40,7 @@ export function endToEndTestSetup(suite: Mocha.Suite) { }); teardown(() => { - sinon.restore(); + restore(); injectIde(ide); }); diff --git a/packages/test-neovim-e2e/src/suite/recorded.neovim.test.ts b/packages/test-neovim-e2e/src/suite/recorded.neovim.test.ts index 2c08219ea6a..fd097843dac 100644 --- a/packages/test-neovim-e2e/src/suite/recorded.neovim.test.ts +++ b/packages/test-neovim-e2e/src/suite/recorded.neovim.test.ts @@ -1,7 +1,4 @@ -import { promises as fsp } from "node:fs"; -import * as yaml from "js-yaml"; import type { NeovimClient } from "neovim"; -import type { TestCaseFixtureLegacy } from "@cursorless/lib-common"; import { asyncSafety } from "@cursorless/lib-common"; import type { NeovimIDE, @@ -14,6 +11,7 @@ import { } from "@cursorless/lib-neovim-common"; import { getRecordedTestPaths, + loadFixture, runRecordedTest, } from "@cursorless/lib-node-common"; import { endToEndTestSetup, sleepWithBackoff } from "../endToEndTestSetup"; @@ -34,8 +32,7 @@ suite("recorded test cases", function () { */ const client = (globalThis as any).additionalParameters.client; - const buffer = await fsp.readFile(path); - const fixture = yaml.load(buffer.toString()) as TestCaseFixtureLegacy; + const fixture = await loadFixture(path); if (!shouldRunTest(name, fixture)) { return this.ctx.skip(); } diff --git a/packages/test-runner/src/launchNeovimAndRunTests.ts b/packages/test-runner/src/launchNeovimAndRunTests.ts index bac751b345b..1f699235dfb 100644 --- a/packages/test-runner/src/launchNeovimAndRunTests.ts +++ b/packages/test-runner/src/launchNeovimAndRunTests.ts @@ -1,4 +1,4 @@ -import * as cp from "node:child_process"; +import cp from "node:child_process"; import { copyFile, mkdirSync, readdirSync } from "node:fs"; import process, { exit } from "node:process"; import { Tail } from "tail"; diff --git a/packages/test-runner/src/launchVscodeAndRunTests.ts b/packages/test-runner/src/launchVscodeAndRunTests.ts index 41e38f1a1a8..a312ea240ed 100644 --- a/packages/test-runner/src/launchVscodeAndRunTests.ts +++ b/packages/test-runner/src/launchVscodeAndRunTests.ts @@ -1,4 +1,4 @@ -import * as path from "node:path"; +import path from "node:path"; import { exit } from "node:process"; import { downloadAndUnzipVSCode, diff --git a/packages/test-runner/src/runAllTests.ts b/packages/test-runner/src/runAllTests.ts index 6f8f8292ee9..9d00f5397a9 100644 --- a/packages/test-runner/src/runAllTests.ts +++ b/packages/test-runner/src/runAllTests.ts @@ -1,4 +1,4 @@ -import * as path from "node:path"; +import path from "node:path"; import fastGlob from "fast-glob"; import Mocha from "mocha"; import { getCursorlessRepoRoot } from "@cursorless/lib-node-common"; diff --git a/packages/test-runner/src/scripts/generateTestSubsetFile.ts b/packages/test-runner/src/scripts/generateTestSubsetFile.ts index 1f695a7e932..85e31b42eb9 100644 --- a/packages/test-runner/src/scripts/generateTestSubsetFile.ts +++ b/packages/test-runner/src/scripts/generateTestSubsetFile.ts @@ -1,5 +1,5 @@ -import * as child from "node:child_process"; -import * as fs from "node:fs"; +import cp from "node:child_process"; +import fs from "node:fs"; import { exit } from "node:process"; import { testSubsetFilePath } from "../testSubset"; @@ -32,7 +32,7 @@ function run() { } if (!exists || process.argv.includes("--always-open")) { - child.execSync(`${vscodeCommand} ${testSubsetGrepPath}`); + cp.execSync(`${vscodeCommand} ${testSubsetGrepPath}`); } if (!exists && process.argv.includes("--fail-if-not-exists")) { diff --git a/packages/test-runner/src/scripts/runVscodeTestsCI.ts b/packages/test-runner/src/scripts/runVscodeTestsCI.ts index 64fe19c5fd2..42dbcafda4c 100644 --- a/packages/test-runner/src/scripts/runVscodeTestsCI.ts +++ b/packages/test-runner/src/scripts/runVscodeTestsCI.ts @@ -2,7 +2,7 @@ * This file can be run from node to run vscode tests in CI */ -import * as path from "node:path"; +import path from "node:path"; import { getCursorlessRepoRoot } from "@cursorless/lib-node-common"; import { launchVscodeAndRunTests } from "../launchVscodeAndRunTests"; diff --git a/packages/test-runner/src/testSubset.ts b/packages/test-runner/src/testSubset.ts index 9f9d9cce3e9..e9619aa86b2 100644 --- a/packages/test-runner/src/testSubset.ts +++ b/packages/test-runner/src/testSubset.ts @@ -1,5 +1,5 @@ -import * as fs from "node:fs"; -import * as path from "node:path"; +import fs from "node:fs"; +import path from "node:path"; import { getCursorlessRepoRoot } from "@cursorless/lib-node-common"; /** diff --git a/packages/test-talon-e2e/src/quickjsTest.ts b/packages/test-talon-e2e/src/quickjsTest.ts index 068fde1b4d8..d6b7c0ee020 100644 --- a/packages/test-talon-e2e/src/quickjsTest.ts +++ b/packages/test-talon-e2e/src/quickjsTest.ts @@ -1,4 +1,4 @@ -import * as std from "std"; +import { exit } from "std"; import { LATEST_VERSION } from "@cursorless/lib-common"; import type { ActionDescriptor, CommandLatest } from "@cursorless/lib-common"; import { activate } from "@cursorless/lib-talonjs-core"; @@ -19,7 +19,7 @@ async function runTests() { hasFailed = true; } - std.exit(hasFailed ? 1 : 0); + exit(hasFailed ? 1 : 0); } async function testTake() { diff --git a/packages/test-vscode-e2e/src/endToEndTestSetup.ts b/packages/test-vscode-e2e/src/endToEndTestSetup.ts index 30286a37c84..1de1f82d370 100644 --- a/packages/test-vscode-e2e/src/endToEndTestSetup.ts +++ b/packages/test-vscode-e2e/src/endToEndTestSetup.ts @@ -1,5 +1,5 @@ import type { Context } from "mocha"; -import * as sinon from "sinon"; +import { restore } from "sinon"; import type { IDE, NormalizedIDE } from "@cursorless/lib-common"; import { shouldUpdateFixtures, sleep, SpyIDE } from "@cursorless/lib-common"; import { @@ -49,7 +49,7 @@ export function endToEndTestSetup( }); teardown(() => { - sinon.restore(); + restore(); injectIde(originalIde); }); diff --git a/packages/test-vscode-e2e/src/mockPrePhraseGetVersion.ts b/packages/test-vscode-e2e/src/mockPrePhraseGetVersion.ts index 331a4d6ba6d..fb257aafd5d 100644 --- a/packages/test-vscode-e2e/src/mockPrePhraseGetVersion.ts +++ b/packages/test-vscode-e2e/src/mockPrePhraseGetVersion.ts @@ -1,11 +1,11 @@ -import * as sinon from "sinon"; +import { replace } from "sinon"; import type { CommandServerApi } from "@cursorless/lib-common"; export function mockPrePhraseGetVersion( commandServerApi: CommandServerApi, getVersion: () => Promise, ) { - sinon.replace(commandServerApi, "signals", { + replace(commandServerApi, "signals", { prePhrase: { getVersion, }, diff --git a/packages/test-vscode-e2e/src/suite/backwardCompatibility.vscode.test.ts b/packages/test-vscode-e2e/src/suite/backwardCompatibility.vscode.test.ts index 91a5ff12d40..4df263521c4 100644 --- a/packages/test-vscode-e2e/src/suite/backwardCompatibility.vscode.test.ts +++ b/packages/test-vscode-e2e/src/suite/backwardCompatibility.vscode.test.ts @@ -1,5 +1,5 @@ -import * as assert from "node:assert/strict"; -import * as vscode from "vscode"; +import assert from "node:assert/strict"; +import vscode from "vscode"; import { CURSORLESS_COMMAND_ID } from "@cursorless/lib-common"; import { getReusableEditor, diff --git a/packages/test-vscode-e2e/src/suite/breakpoints.vscode.test.ts b/packages/test-vscode-e2e/src/suite/breakpoints.vscode.test.ts index dd05e3626ac..fbb5e19a685 100644 --- a/packages/test-vscode-e2e/src/suite/breakpoints.vscode.test.ts +++ b/packages/test-vscode-e2e/src/suite/breakpoints.vscode.test.ts @@ -1,5 +1,5 @@ -import * as assert from "node:assert/strict"; -import * as vscode from "vscode"; +import assert from "node:assert/strict"; +import vscode from "vscode"; import { LATEST_VERSION } from "@cursorless/lib-common"; import { getTestHelpers, diff --git a/packages/test-vscode-e2e/src/suite/commandHistory.vscode.test.ts b/packages/test-vscode-e2e/src/suite/commandHistory.vscode.test.ts index ed10cc5f771..3a0118c1218 100644 --- a/packages/test-vscode-e2e/src/suite/commandHistory.vscode.test.ts +++ b/packages/test-vscode-e2e/src/suite/commandHistory.vscode.test.ts @@ -1,9 +1,9 @@ -import * as assert from "node:assert/strict"; +import assert from "node:assert/strict"; import { existsSync } from "node:fs"; import { readFile, readdir, rm } from "node:fs/promises"; -import * as path from "node:path"; +import path from "node:path"; import { produce } from "immer"; -import * as vscode from "vscode"; +import vscode from "vscode"; import type { CommandComplete, CommandHistoryEntry, diff --git a/packages/test-vscode-e2e/src/suite/containingTokenTwice.vscode.test.ts b/packages/test-vscode-e2e/src/suite/containingTokenTwice.vscode.test.ts index 56aedaeacae..062a1103e2c 100644 --- a/packages/test-vscode-e2e/src/suite/containingTokenTwice.vscode.test.ts +++ b/packages/test-vscode-e2e/src/suite/containingTokenTwice.vscode.test.ts @@ -1,5 +1,5 @@ -import * as assert from "node:assert/strict"; -import * as vscode from "vscode"; +import assert from "node:assert/strict"; +import vscode from "vscode"; import { LATEST_VERSION } from "@cursorless/lib-common"; import { getReusableEditor, diff --git a/packages/test-vscode-e2e/src/suite/crossCellsSetSelection.vscode.test.ts b/packages/test-vscode-e2e/src/suite/crossCellsSetSelection.vscode.test.ts index 428b9a90aed..dc40cd77967 100644 --- a/packages/test-vscode-e2e/src/suite/crossCellsSetSelection.vscode.test.ts +++ b/packages/test-vscode-e2e/src/suite/crossCellsSetSelection.vscode.test.ts @@ -1,4 +1,4 @@ -import * as assert from "node:assert/strict"; +import assert from "node:assert/strict"; import { window } from "vscode"; import { LATEST_VERSION, splitKey } from "@cursorless/lib-common"; import { diff --git a/packages/test-vscode-e2e/src/suite/editNewCell.vscode.test.ts b/packages/test-vscode-e2e/src/suite/editNewCell.vscode.test.ts index e157003432f..bb3380555ef 100644 --- a/packages/test-vscode-e2e/src/suite/editNewCell.vscode.test.ts +++ b/packages/test-vscode-e2e/src/suite/editNewCell.vscode.test.ts @@ -1,4 +1,4 @@ -import * as assert from "node:assert/strict"; +import assert from "node:assert/strict"; import { window } from "vscode"; import { LATEST_VERSION } from "@cursorless/lib-common"; import { diff --git a/packages/test-vscode-e2e/src/suite/explicitMark.vscode.test.ts b/packages/test-vscode-e2e/src/suite/explicitMark.vscode.test.ts index 6275be1af4b..1e673406721 100644 --- a/packages/test-vscode-e2e/src/suite/explicitMark.vscode.test.ts +++ b/packages/test-vscode-e2e/src/suite/explicitMark.vscode.test.ts @@ -1,4 +1,4 @@ -import * as assert from "node:assert/strict"; +import assert from "node:assert/strict"; import { Selection } from "vscode"; import { LATEST_VERSION } from "@cursorless/lib-common"; import { diff --git a/packages/test-vscode-e2e/src/suite/fold.vscode.test.ts b/packages/test-vscode-e2e/src/suite/fold.vscode.test.ts index c3cca39caa5..4fad0a330ad 100644 --- a/packages/test-vscode-e2e/src/suite/fold.vscode.test.ts +++ b/packages/test-vscode-e2e/src/suite/fold.vscode.test.ts @@ -1,5 +1,5 @@ -import * as assert from "node:assert/strict"; -import * as vscode from "vscode"; +import assert from "node:assert/strict"; +import vscode from "vscode"; import { LATEST_VERSION } from "@cursorless/lib-common"; import { getReusableEditor, diff --git a/packages/test-vscode-e2e/src/suite/followLink.vscode.test.ts b/packages/test-vscode-e2e/src/suite/followLink.vscode.test.ts index 55fe186506b..49ebc0dbb20 100644 --- a/packages/test-vscode-e2e/src/suite/followLink.vscode.test.ts +++ b/packages/test-vscode-e2e/src/suite/followLink.vscode.test.ts @@ -1,5 +1,5 @@ -import * as assert from "node:assert/strict"; -import * as vscode from "vscode"; +import assert from "node:assert/strict"; +import vscode from "vscode"; import { LATEST_VERSION } from "@cursorless/lib-common"; import { getFixturePath, isWindows } from "@cursorless/lib-node-common"; import { diff --git a/packages/test-vscode-e2e/src/suite/groupByDocument.vscode.test.ts b/packages/test-vscode-e2e/src/suite/groupByDocument.vscode.test.ts index e2abcac3ca2..3e08e113f11 100644 --- a/packages/test-vscode-e2e/src/suite/groupByDocument.vscode.test.ts +++ b/packages/test-vscode-e2e/src/suite/groupByDocument.vscode.test.ts @@ -1,5 +1,5 @@ -import * as assert from "node:assert/strict"; -import * as vscode from "vscode"; +import assert from "node:assert/strict"; +import vscode from "vscode"; import { LATEST_VERSION, splitKey } from "@cursorless/lib-common"; import { getTestHelpers, diff --git a/packages/test-vscode-e2e/src/suite/instanceAcrossSplit.vscode.test.ts b/packages/test-vscode-e2e/src/suite/instanceAcrossSplit.vscode.test.ts index 3ef3a83f229..650dda9a567 100644 --- a/packages/test-vscode-e2e/src/suite/instanceAcrossSplit.vscode.test.ts +++ b/packages/test-vscode-e2e/src/suite/instanceAcrossSplit.vscode.test.ts @@ -1,4 +1,4 @@ -import * as assert from "node:assert/strict"; +import assert from "node:assert/strict"; import { Selection } from "vscode"; import type { Modifier, SpyIDE } from "@cursorless/lib-common"; import { diff --git a/packages/test-vscode-e2e/src/suite/keyboard/basic.vscode.test.ts b/packages/test-vscode-e2e/src/suite/keyboard/basic.vscode.test.ts index 60049a17a3f..92163655568 100644 --- a/packages/test-vscode-e2e/src/suite/keyboard/basic.vscode.test.ts +++ b/packages/test-vscode-e2e/src/suite/keyboard/basic.vscode.test.ts @@ -1,8 +1,8 @@ -import * as assert from "node:assert/strict"; +import assert from "node:assert/strict"; import { readFile } from "node:fs/promises"; -import * as path from "node:path"; -import * as sinon from "sinon"; -import * as vscode from "vscode"; +import path from "node:path"; +import { fake, replace } from "sinon"; +import vscode from "vscode"; import { getCursorlessRepoRoot } from "@cursorless/lib-node-common"; import { getReusableEditor, @@ -324,16 +324,16 @@ async function injectFakes(): Promise { const keyboardConfig = JSON.parse(await readFile(keyboardConfigPath, "utf8")); - const getConfigurationValue = sinon.fake((sectionName) => { + const getConfigurationValue = fake((sectionName) => { return keyboardConfig[ `cursorless.experimental.keyboard.modal.keybindings.${sectionName}` ]; }); - sinon.replace( + replace( vscodeApi.workspace, "getConfiguration", - sinon.fake((section) => { + fake((section) => { if ( !section?.startsWith( "cursorless.experimental.keyboard.modal.keybindings", diff --git a/packages/test-vscode-e2e/src/suite/performance.vscode.test.ts b/packages/test-vscode-e2e/src/suite/performance.vscode.test.ts index 7dda5a93840..0163b62a04b 100644 --- a/packages/test-vscode-e2e/src/suite/performance.vscode.test.ts +++ b/packages/test-vscode-e2e/src/suite/performance.vscode.test.ts @@ -1,5 +1,5 @@ import assert from "node:assert/strict"; -import * as vscode from "vscode"; +import vscode from "vscode"; import type { ActionDescriptor, Modifier, diff --git a/packages/test-vscode-e2e/src/suite/pourAcrossSplit.vscode.test.ts b/packages/test-vscode-e2e/src/suite/pourAcrossSplit.vscode.test.ts index 13a4982459e..18adb5b7f4f 100644 --- a/packages/test-vscode-e2e/src/suite/pourAcrossSplit.vscode.test.ts +++ b/packages/test-vscode-e2e/src/suite/pourAcrossSplit.vscode.test.ts @@ -1,4 +1,4 @@ -import * as assert from "node:assert/strict"; +import assert from "node:assert/strict"; import { LATEST_VERSION } from "@cursorless/lib-common"; import { getTestHelpers, diff --git a/packages/test-vscode-e2e/src/suite/prePhraseSnapshot.vscode.test.ts b/packages/test-vscode-e2e/src/suite/prePhraseSnapshot.vscode.test.ts index c36f5aeacdd..ec402c7792b 100644 --- a/packages/test-vscode-e2e/src/suite/prePhraseSnapshot.vscode.test.ts +++ b/packages/test-vscode-e2e/src/suite/prePhraseSnapshot.vscode.test.ts @@ -1,5 +1,5 @@ -import * as assert from "node:assert/strict"; -import * as vscode from "vscode"; +import assert from "node:assert/strict"; +import vscode from "vscode"; import { HatStability, LATEST_VERSION, diff --git a/packages/test-vscode-e2e/src/suite/recorded.vscode.test.ts b/packages/test-vscode-e2e/src/suite/recorded.vscode.test.ts index 243681df625..67a42847df8 100644 --- a/packages/test-vscode-e2e/src/suite/recorded.vscode.test.ts +++ b/packages/test-vscode-e2e/src/suite/recorded.vscode.test.ts @@ -1,4 +1,4 @@ -import * as vscode from "vscode"; +import vscode from "vscode"; import type { TextEditor } from "@cursorless/lib-common"; import { DEFAULT_TEXT_EDITOR_OPTIONS_FOR_TEST, diff --git a/packages/test-vscode-e2e/src/suite/revealRange.vscode.test.ts b/packages/test-vscode-e2e/src/suite/revealRange.vscode.test.ts index 998407a9ae0..431f907da85 100644 --- a/packages/test-vscode-e2e/src/suite/revealRange.vscode.test.ts +++ b/packages/test-vscode-e2e/src/suite/revealRange.vscode.test.ts @@ -1,5 +1,5 @@ import assert from "node:assert/strict"; -import * as vscode from "vscode"; +import vscode from "vscode"; import { LATEST_VERSION } from "@cursorless/lib-common"; import { getReusableEditor, diff --git a/packages/test-vscode-e2e/src/suite/scopeProvider/assertCalledWithScopeInfo.ts b/packages/test-vscode-e2e/src/suite/scopeProvider/assertCalledWithScopeInfo.ts index 7bc53928cdc..debc03c8724 100644 --- a/packages/test-vscode-e2e/src/suite/scopeProvider/assertCalledWithScopeInfo.ts +++ b/packages/test-vscode-e2e/src/suite/scopeProvider/assertCalledWithScopeInfo.ts @@ -1,4 +1,4 @@ -import * as assert from "node:assert/strict"; +import assert from "node:assert/strict"; import { isEqual } from "lodash-es"; import type { SinonSpy } from "sinon"; import type { ScopeType, ScopeTypeInfo } from "@cursorless/lib-common"; diff --git a/packages/test-vscode-e2e/src/suite/scopeProvider/runBasicScopeInfoTest.ts b/packages/test-vscode-e2e/src/suite/scopeProvider/runBasicScopeInfoTest.ts index f881eb96c02..b5132d92f70 100644 --- a/packages/test-vscode-e2e/src/suite/scopeProvider/runBasicScopeInfoTest.ts +++ b/packages/test-vscode-e2e/src/suite/scopeProvider/runBasicScopeInfoTest.ts @@ -1,4 +1,4 @@ -import * as sinon from "sinon"; +import { fake } from "sinon"; import type { TextDocument } from "vscode"; import { Position, Range, commands } from "vscode"; import type { ScopeSupportInfo } from "@cursorless/lib-common"; @@ -15,30 +15,30 @@ import { assertCalledWithScopeInfo } from "./assertCalledWithScopeInfo"; */ export async function runBasicScopeInfoTest() { const { scopeProvider } = await getTestHelpers(); - const fake = sinon.fake<[scopeInfos: ScopeSupportInfo[]], void>(); + const faked = fake<[scopeInfos: ScopeSupportInfo[]], void>(); await commands.executeCommand("workbench.action.closeAllEditors"); - const disposable = scopeProvider.onDidChangeScopeSupport(fake); + const disposable = scopeProvider.onDidChangeScopeSupport(faked); try { - await assertCalledWithScopeInfo(fake, unsupported); + await assertCalledWithScopeInfo(faked, unsupported); const editor = await getReusableEditor("", "typescript"); - await assertCalledWithScopeInfo(fake, supported); + await assertCalledWithScopeInfo(faked, supported); await editor.edit((editBuilder) => { editBuilder.insert(new Position(0, 0), contents); }); - await assertCalledWithScopeInfo(fake, present); + await assertCalledWithScopeInfo(faked, present); await editor.edit((editBuilder) => { editBuilder.delete(getDocumentRange(editor.document)); }); - await assertCalledWithScopeInfo(fake, supported); + await assertCalledWithScopeInfo(faked, supported); await commands.executeCommand("workbench.action.closeAllEditors"); - await assertCalledWithScopeInfo(fake, unsupported); + await assertCalledWithScopeInfo(faked, unsupported); } finally { disposable.dispose(); } diff --git a/packages/test-vscode-e2e/src/suite/scopeProvider/runCustomRegexScopeInfoTest.ts b/packages/test-vscode-e2e/src/suite/scopeProvider/runCustomRegexScopeInfoTest.ts index c2598cb7e85..af6e006737e 100644 --- a/packages/test-vscode-e2e/src/suite/scopeProvider/runCustomRegexScopeInfoTest.ts +++ b/packages/test-vscode-e2e/src/suite/scopeProvider/runCustomRegexScopeInfoTest.ts @@ -1,5 +1,5 @@ import { stat, unlink, writeFile } from "node:fs/promises"; -import * as sinon from "sinon"; +import { fake } from "sinon"; import { commands } from "vscode"; import type { ScopeSupportInfo, ScopeType } from "@cursorless/lib-common"; import { ScopeSupport, sleep } from "@cursorless/lib-common"; @@ -16,26 +16,26 @@ import { export async function runCustomRegexScopeInfoTest() { const { scopeProvider, cursorlessTalonStateJsonPath } = await getTestHelpers(); - const fake = sinon.fake<[scopeInfos: ScopeSupportInfo[]], void>(); + const faked = fake<[scopeInfos: ScopeSupportInfo[]], void>(); await commands.executeCommand("workbench.action.closeAllEditors"); - const disposable = scopeProvider.onDidChangeScopeSupport(fake); + const disposable = scopeProvider.onDidChangeScopeSupport(faked); try { - await assertCalledWithoutScopeInfo(fake, scopeType); + await assertCalledWithoutScopeInfo(faked, scopeType); await writeFile( cursorlessTalonStateJsonPath, JSON.stringify(spokenFormJsonContents), ); - await assertCalledWithScopeInfo(fake, unsupported); + await assertCalledWithScopeInfo(faked, unsupported); await openNewEditor(contents); - await assertCalledWithScopeInfo(fake, present); + await assertCalledWithScopeInfo(faked, present); await unlink(cursorlessTalonStateJsonPath); - await assertCalledWithoutScopeInfo(fake, scopeType); + await assertCalledWithoutScopeInfo(faked, scopeType); } finally { disposable.dispose(); diff --git a/packages/test-vscode-e2e/src/suite/scopeProvider/runCustomSpokenFormScopeInfoTest.ts b/packages/test-vscode-e2e/src/suite/scopeProvider/runCustomSpokenFormScopeInfoTest.ts index 06444b65276..77f8fc939eb 100644 --- a/packages/test-vscode-e2e/src/suite/scopeProvider/runCustomSpokenFormScopeInfoTest.ts +++ b/packages/test-vscode-e2e/src/suite/scopeProvider/runCustomSpokenFormScopeInfoTest.ts @@ -1,5 +1,5 @@ import { stat, unlink, writeFile } from "node:fs/promises"; -import * as sinon from "sinon"; +import { fake } from "sinon"; import type { ScopeTypeInfo } from "@cursorless/lib-common"; import { DOCS_URL, sleep } from "@cursorless/lib-common"; import { getTestHelpers } from "@cursorless/lib-vscode-common"; @@ -11,13 +11,13 @@ import { assertCalledWithScopeInfo } from "./assertCalledWithScopeInfo"; export async function runCustomSpokenFormScopeInfoTest() { const { scopeProvider, cursorlessTalonStateJsonPath } = await getTestHelpers(); - const fake = sinon.fake<[scopeInfos: ScopeTypeInfo[]], void>(); + const faked = fake<[scopeInfos: ScopeTypeInfo[]], void>(); - const disposable = scopeProvider.onDidChangeScopeInfo(fake); + const disposable = scopeProvider.onDidChangeScopeInfo(faked); try { await assertCalledWithScopeInfo( - fake, + faked, roundStandard, namedFunctionStandard, lambdaStandard, @@ -30,7 +30,7 @@ export async function runCustomSpokenFormScopeInfoTest() { JSON.stringify(spokenFormJsonContents), ); await assertCalledWithScopeInfo( - fake, + faked, roundCustom, namedFunctionCustom, lambdaCustom, @@ -40,7 +40,7 @@ export async function runCustomSpokenFormScopeInfoTest() { await unlink(cursorlessTalonStateJsonPath); await assertCalledWithScopeInfo( - fake, + faked, roundStandard, namedFunctionStandard, lambdaStandard, diff --git a/packages/test-vscode-e2e/src/suite/scopeProvider/runSurroundingPairScopeInfoTest.ts b/packages/test-vscode-e2e/src/suite/scopeProvider/runSurroundingPairScopeInfoTest.ts index fb181dc1af5..11e725cc542 100644 --- a/packages/test-vscode-e2e/src/suite/scopeProvider/runSurroundingPairScopeInfoTest.ts +++ b/packages/test-vscode-e2e/src/suite/scopeProvider/runSurroundingPairScopeInfoTest.ts @@ -1,4 +1,4 @@ -import * as sinon from "sinon"; +import { fake } from "sinon"; import { Position, commands } from "vscode"; import type { ScopeSupportInfo } from "@cursorless/lib-common"; import { ScopeSupport } from "@cursorless/lib-common"; @@ -11,25 +11,25 @@ import { assertCalledWithScopeInfo } from "./assertCalledWithScopeInfo"; */ export async function runSurroundingPairScopeInfoTest() { const { scopeProvider } = await getTestHelpers(); - const fake = sinon.fake<[scopeInfos: ScopeSupportInfo[]], void>(); + const faked = fake<[scopeInfos: ScopeSupportInfo[]], void>(); await commands.executeCommand("workbench.action.closeAllEditors"); - const disposable = scopeProvider.onDidChangeScopeSupport(fake); + const disposable = scopeProvider.onDidChangeScopeSupport(faked); try { - await assertCalledWithScopeInfo(fake, unsupported); + await assertCalledWithScopeInfo(faked, unsupported); const editor = await openNewEditor(""); - await assertCalledWithScopeInfo(fake, supported); + await assertCalledWithScopeInfo(faked, supported); await editor.edit((editBuilder) => { editBuilder.insert(new Position(0, 0), "()"); }); - await assertCalledWithScopeInfo(fake, present); + await assertCalledWithScopeInfo(faked, present); await commands.executeCommand("workbench.action.closeAllEditors"); - await assertCalledWithScopeInfo(fake, unsupported); + await assertCalledWithScopeInfo(faked, unsupported); } finally { disposable.dispose(); } diff --git a/packages/test-vscode-e2e/src/suite/scopeVisualizer/checkAndResetFakes.ts b/packages/test-vscode-e2e/src/suite/scopeVisualizer/checkAndResetFakes.ts index a4f5feff9a7..1826c6a8ce3 100644 --- a/packages/test-vscode-e2e/src/suite/scopeVisualizer/checkAndResetFakes.ts +++ b/packages/test-vscode-e2e/src/suite/scopeVisualizer/checkAndResetFakes.ts @@ -1,4 +1,4 @@ -import * as assert from "node:assert/strict"; +import assert from "node:assert/strict"; import type * as sinon from "sinon"; import type { Fakes, ExpectedArgs } from "./scopeVisualizerTest.types"; import { diff --git a/packages/test-vscode-e2e/src/suite/scopeVisualizer/injectFakes.ts b/packages/test-vscode-e2e/src/suite/scopeVisualizer/injectFakes.ts index d10164ca275..d40f35f6b84 100644 --- a/packages/test-vscode-e2e/src/suite/scopeVisualizer/injectFakes.ts +++ b/packages/test-vscode-e2e/src/suite/scopeVisualizer/injectFakes.ts @@ -1,4 +1,4 @@ -import * as sinon from "sinon"; +import { fake, replace } from "sinon"; import type { DecorationRenderOptions, WorkspaceConfiguration } from "vscode"; import { getTestHelpers } from "@cursorless/lib-vscode-common"; import type { VscodeApi } from "@cursorless/lib-vscode-common"; @@ -12,10 +12,10 @@ import type { export async function injectFakes(): Promise { const { vscodeApi } = await getTestHelpers(); - const dispose = sinon.fake<[number], void>(); + const dispose = fake<[number], void>(); let decorationIndex = 0; - const createTextEditorDecorationType = sinon.fake< + const createTextEditorDecorationType = fake< Parameters, MockDecorationType >((_options: DecorationRenderOptions) => { @@ -28,23 +28,23 @@ export async function injectFakes(): Promise { }; }); - const setDecorations = sinon.fake< + const setDecorations = fake< SetDecorationsParameters, ReturnType >(); - const getConfigurationValue = sinon.fake.returns(COLOR_CONFIG); + const getConfigurationValue = fake.returns(COLOR_CONFIG); - sinon.replace( + replace( vscodeApi.window, "createTextEditorDecorationType", createTextEditorDecorationType as any, ); - sinon.replace(vscodeApi.editor, "setDecorations", setDecorations as any); - sinon.replace( + replace(vscodeApi.editor, "setDecorations", setDecorations as any); + replace( vscodeApi.workspace, "getConfiguration", - sinon.fake.returns({ + fake.returns({ get: getConfigurationValue, } as unknown as WorkspaceConfiguration), ); diff --git a/packages/test-vscode-e2e/src/suite/scopeVisualizer/runBasicMultilineContentTest.ts b/packages/test-vscode-e2e/src/suite/scopeVisualizer/runBasicMultilineContentTest.ts index 133473384ce..a66153507d5 100644 --- a/packages/test-vscode-e2e/src/suite/scopeVisualizer/runBasicMultilineContentTest.ts +++ b/packages/test-vscode-e2e/src/suite/scopeVisualizer/runBasicMultilineContentTest.ts @@ -1,4 +1,4 @@ -import * as vscode from "vscode"; +import vscode from "vscode"; import { openNewEditor } from "@cursorless/lib-vscode-common"; import { checkAndResetFakes } from "./checkAndResetFakes"; import { injectFakes } from "./injectFakes"; diff --git a/packages/test-vscode-e2e/src/suite/scopeVisualizer/runBasicRemovalTest.ts b/packages/test-vscode-e2e/src/suite/scopeVisualizer/runBasicRemovalTest.ts index 95c195a12b5..cdbeb1f9c50 100644 --- a/packages/test-vscode-e2e/src/suite/scopeVisualizer/runBasicRemovalTest.ts +++ b/packages/test-vscode-e2e/src/suite/scopeVisualizer/runBasicRemovalTest.ts @@ -1,4 +1,4 @@ -import * as vscode from "vscode"; +import vscode from "vscode"; import { openNewEditor } from "@cursorless/lib-vscode-common"; import { checkAndResetFakes } from "./checkAndResetFakes"; import { injectFakes } from "./injectFakes"; diff --git a/packages/test-vscode-e2e/src/suite/scopeVisualizer/runNestedMultilineContentTest.ts b/packages/test-vscode-e2e/src/suite/scopeVisualizer/runNestedMultilineContentTest.ts index bb6fb4db22f..9d916f4099a 100644 --- a/packages/test-vscode-e2e/src/suite/scopeVisualizer/runNestedMultilineContentTest.ts +++ b/packages/test-vscode-e2e/src/suite/scopeVisualizer/runNestedMultilineContentTest.ts @@ -1,4 +1,4 @@ -import * as vscode from "vscode"; +import vscode from "vscode"; import { openNewEditor } from "@cursorless/lib-vscode-common"; import { checkAndResetFakes } from "./checkAndResetFakes"; import { injectFakes } from "./injectFakes"; diff --git a/packages/test-vscode-e2e/src/suite/scopeVisualizer/runUpdateTest.ts b/packages/test-vscode-e2e/src/suite/scopeVisualizer/runUpdateTest.ts index 9a61e5d468e..528f053c82e 100644 --- a/packages/test-vscode-e2e/src/suite/scopeVisualizer/runUpdateTest.ts +++ b/packages/test-vscode-e2e/src/suite/scopeVisualizer/runUpdateTest.ts @@ -1,4 +1,4 @@ -import * as vscode from "vscode"; +import vscode from "vscode"; import { getReusableEditor } from "@cursorless/lib-vscode-common"; import { sleepWithBackoff } from "../../endToEndTestSetup"; import { checkAndResetFakes } from "./checkAndResetFakes"; diff --git a/packages/test-vscode-e2e/src/suite/scroll.vscode.test.ts b/packages/test-vscode-e2e/src/suite/scroll.vscode.test.ts index a63287d98ab..329c27a602e 100644 --- a/packages/test-vscode-e2e/src/suite/scroll.vscode.test.ts +++ b/packages/test-vscode-e2e/src/suite/scroll.vscode.test.ts @@ -1,4 +1,4 @@ -import * as vscode from "vscode"; +import vscode from "vscode"; import { LATEST_VERSION } from "@cursorless/lib-common"; import { getReusableEditor, diff --git a/packages/test-vscode-e2e/src/suite/shouldSkipTest.ts b/packages/test-vscode-e2e/src/suite/shouldSkipTest.ts index 409aad925f5..abc0f4089d3 100644 --- a/packages/test-vscode-e2e/src/suite/shouldSkipTest.ts +++ b/packages/test-vscode-e2e/src/suite/shouldSkipTest.ts @@ -1,5 +1,5 @@ -import * as semver from "semver"; -import * as vscode from "vscode"; +import semver from "semver"; +import vscode from "vscode"; /** * FIXME: On newer vscode versions some Tree sitter parser throws memory errors diff --git a/packages/test-vscode-e2e/src/suite/testCaseRecorder.vscode.test.ts b/packages/test-vscode-e2e/src/suite/testCaseRecorder.vscode.test.ts index 8823e7a0675..42b54612f82 100644 --- a/packages/test-vscode-e2e/src/suite/testCaseRecorder.vscode.test.ts +++ b/packages/test-vscode-e2e/src/suite/testCaseRecorder.vscode.test.ts @@ -1,9 +1,9 @@ -import * as assert from "node:assert/strict"; -import * as crypto from "node:crypto"; +import assert from "node:assert/strict"; +import crypto from "node:crypto"; import { mkdir, readFile, readdir, rm } from "node:fs/promises"; -import * as os from "node:os"; -import * as path from "node:path"; -import * as vscode from "vscode"; +import os from "node:os"; +import path from "node:path"; +import vscode from "vscode"; import type { HatTokenMap, SimpleActionName } from "@cursorless/lib-common"; import { LATEST_VERSION } from "@cursorless/lib-common"; import { diff --git a/packages/test-vscode-e2e/src/suite/toggleDecorations.vscode.test.ts b/packages/test-vscode-e2e/src/suite/toggleDecorations.vscode.test.ts index 37e0ca4a161..e729b275913 100644 --- a/packages/test-vscode-e2e/src/suite/toggleDecorations.vscode.test.ts +++ b/packages/test-vscode-e2e/src/suite/toggleDecorations.vscode.test.ts @@ -1,5 +1,5 @@ import assert from "node:assert/strict"; -import * as vscode from "vscode"; +import vscode from "vscode"; import type { HatTokenMap } from "@cursorless/lib-common"; import { getReusableEditor, diff --git a/packages/test-vscode-e2e/src/suite/tutorial/tutorial.vscode.test.ts b/packages/test-vscode-e2e/src/suite/tutorial/tutorial.vscode.test.ts index bdef9339263..53a100f369b 100644 --- a/packages/test-vscode-e2e/src/suite/tutorial/tutorial.vscode.test.ts +++ b/packages/test-vscode-e2e/src/suite/tutorial/tutorial.vscode.test.ts @@ -1,7 +1,7 @@ import assert from "node:assert/strict"; import path from "node:path"; import { isEqual } from "lodash-es"; -import * as sinon from "sinon"; +import { replace } from "sinon"; import { commands } from "vscode"; import type { SpyIDE, TestCaseFixtureLegacy } from "@cursorless/lib-common"; import { @@ -36,7 +36,7 @@ async function runBasicTutorialTest(spyIde: SpyIDE) { const { hatTokenMap, takeSnapshot, getTutorialWebviewEventLog, vscodeApi } = await getTestHelpers(); const commandsRun: string[] = []; - sinon.replace( + replace( vscodeApi.commands, "executeCommand", (command: string, ...args: any[]): Thenable => { diff --git a/packages/test-vscode-e2e/src/suite/visible.vscode.test.ts b/packages/test-vscode-e2e/src/suite/visible.vscode.test.ts index d09eaf3a4b7..1a157715016 100644 --- a/packages/test-vscode-e2e/src/suite/visible.vscode.test.ts +++ b/packages/test-vscode-e2e/src/suite/visible.vscode.test.ts @@ -1,5 +1,5 @@ -import * as assert from "node:assert/strict"; -import * as vscode from "vscode"; +import assert from "node:assert/strict"; +import vscode from "vscode"; import { LATEST_VERSION } from "@cursorless/lib-common"; import { getReusableEditor, diff --git a/packages/test-vscode-e2e/src/suite/withinCellSetSelection.vscode.test.ts b/packages/test-vscode-e2e/src/suite/withinCellSetSelection.vscode.test.ts index cad5ffe9d62..2199ac57430 100644 --- a/packages/test-vscode-e2e/src/suite/withinCellSetSelection.vscode.test.ts +++ b/packages/test-vscode-e2e/src/suite/withinCellSetSelection.vscode.test.ts @@ -1,4 +1,4 @@ -import * as assert from "node:assert/strict"; +import assert from "node:assert/strict"; import { window } from "vscode"; import { LATEST_VERSION, splitKey } from "@cursorless/lib-common"; import { diff --git a/packages/test-vscode-e2e/src/suite/wrapWithSnippetAcrossSplit.vscode.test.ts b/packages/test-vscode-e2e/src/suite/wrapWithSnippetAcrossSplit.vscode.test.ts index 5a6d7276c68..3b947c3c906 100644 --- a/packages/test-vscode-e2e/src/suite/wrapWithSnippetAcrossSplit.vscode.test.ts +++ b/packages/test-vscode-e2e/src/suite/wrapWithSnippetAcrossSplit.vscode.test.ts @@ -1,4 +1,4 @@ -import * as assert from "node:assert/strict"; +import assert from "node:assert/strict"; import { HatStability, LATEST_VERSION } from "@cursorless/lib-common"; import { getTestHelpers, diff --git a/packages/tool-meta-updater/src/textFormat.ts b/packages/tool-meta-updater/src/textFormat.ts index 4db0c748fb5..4d5bc723fec 100644 --- a/packages/tool-meta-updater/src/textFormat.ts +++ b/packages/tool-meta-updater/src/textFormat.ts @@ -1,4 +1,4 @@ -import * as fs from "node:fs/promises"; +import fs from "node:fs/promises"; import { createFormat } from "@pnpm/meta-updater"; export const textFormat = createFormat({ diff --git a/packages/tool-meta-updater/src/toPosixPath.ts b/packages/tool-meta-updater/src/toPosixPath.ts index f84128a9bcd..047040ce939 100644 --- a/packages/tool-meta-updater/src/toPosixPath.ts +++ b/packages/tool-meta-updater/src/toPosixPath.ts @@ -1,4 +1,4 @@ -import * as path from "node:path"; +import path from "node:path"; export function toPosixPath(p: string) { return p.split(path.sep).join(path.posix.sep); diff --git a/packages/tool-meta-updater/src/updateTSConfig.ts b/packages/tool-meta-updater/src/updateTSConfig.ts index 2980fe407f6..fc481c1ecfe 100644 --- a/packages/tool-meta-updater/src/updateTSConfig.ts +++ b/packages/tool-meta-updater/src/updateTSConfig.ts @@ -1,4 +1,4 @@ -import * as path from "node:path"; +import path from "node:path"; import { getLockfileImporterId } from "@pnpm/lockfile-file"; import type { FormatPluginFnOptions } from "@pnpm/meta-updater"; import { isEqual } from "lodash-es"; diff --git a/packages/tool-meta-updater/src/updateTSConfigBase.ts b/packages/tool-meta-updater/src/updateTSConfigBase.ts index e7434fe5265..5d2549f5f94 100644 --- a/packages/tool-meta-updater/src/updateTSConfigBase.ts +++ b/packages/tool-meta-updater/src/updateTSConfigBase.ts @@ -1,4 +1,4 @@ -import * as fs from "node:fs/promises"; +import fs from "node:fs/promises"; import type { FormatPluginFnOptions } from "@pnpm/meta-updater"; import type { PackageJson, TsConfigJson } from "type-fest"; import type { Context } from "./Context"; diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 758f3bea29a..1139a644a46 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -442,9 +442,6 @@ importers: specifier: ^4.4.3 version: 4.4.3 devDependencies: - '@types/js-yaml': - specifier: ^4.0.9 - version: 4.0.9 '@types/lodash-es': specifier: ^4.17.12 version: 4.17.12 @@ -457,9 +454,6 @@ importers: '@types/nearley': specifier: ^2.11.5 version: 2.11.5(patch_hash=72ccc6b9fd704c6d457027e12d6e1d005695ab3508558a08c6aaf73fb608ef69) - js-yaml: - specifier: ^4.2.0 - version: 4.2.0 web-tree-sitter: specifier: ^0.26.9 version: 0.26.9 @@ -632,18 +626,12 @@ importers: specifier: workspace:* version: link:../lib-node-common devDependencies: - '@types/js-yaml': - specifier: ^4.0.9 - version: 4.0.9 '@types/mocha': specifier: ^10.0.10 version: 10.0.10 '@types/sinon': specifier: ^21.0.1 version: 21.0.1 - js-yaml: - specifier: ^4.2.0 - version: 4.2.0 neovim: specifier: ^5.4.0 version: 5.4.0