Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .oxlintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@
"eslint/no-restricted-imports": [
"warn",
{
"paths": [
{
"name": "node:assert",
"message": "Use node:assert/strict instead"
}
],
"patterns": [
{
"group": ["../*/src", "../*/src/*", "../../*/src", "../../*/src/*"],
Expand Down Expand Up @@ -77,6 +83,7 @@
"typescript/restrict-template-expressions": "off",
"typescript/unbound-method": "off",
"unicorn/prefer-module": "warn",
"unicorn/prefer-node-protocol": "warn",
"unicorn/throw-new-error": "warn"
},
"overrides": [
Expand Down
2 changes: 1 addition & 1 deletion packages/app-vscode/src/createVscodeIde.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as crypto from "crypto";
import * as crypto from "node:crypto";
import * as os from "node:os";
import * as path from "node:path";
import type { ExtensionContext } from "vscode";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as assert from "assert";
import * as assert from "node:assert/strict";
import { getReusableEditor } from "@cursorless/lib-vscode-common";
import VscodeTextLine from "./VscodeTextLine";

Expand Down
6 changes: 3 additions & 3 deletions packages/app-vscode/src/keyboard/buildSuffixTrie.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import assert from "node:assert";
import * as assert from "node:assert/strict";
import type { KeyValuePair } from "./buildSuffixTrie";
import { buildSuffixTrie } from "./buildSuffixTrie";
import { isEqual, sortBy, uniq, uniqWith } from "lodash-es";
Expand Down Expand Up @@ -130,8 +130,8 @@ suite("buildSuffixTrie", () => {
sortEntries(chars.flatMap((char) => trie.search(char))),
isEqual,
).map(({ key, value }) => ({ key, value }));
assert.deepStrictEqual(actual, sortEntries(expected));
assert.deepStrictEqual(
assert.deepEqual(actual, sortEntries(expected));
assert.deepEqual(
sortBy(conflicts.map(sortEntries), (conflict) =>
JSON.stringify(conflict),
),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import assert from "assert";
import * as assert from "node:assert/strict";
import nearley from "nearley";
import type { KeyDescriptor } from "../TokenTypeHelpers";
import grammar from "./generated/grammar";
Expand Down Expand Up @@ -153,7 +153,7 @@ suite("keyboard.getAcceptableTokenTypes", () => {
arg: value.partialArg,
},
};
assert(
assert.ok(
candidates.some((result) => isEqual(result, fullValue)),
"Relevant candidates (note that symbols will be missing):\n" +
JSON.stringify(candidates, null, 2),
Expand Down
4 changes: 2 additions & 2 deletions packages/app-vscode/src/keyboard/grammar/grammar.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import nearley from "nearley";
import grammar from "./generated/grammar";
import assert from "assert";
import * as assert from "node:assert/strict";
import type { KeyDescriptor } from "../TokenTypeHelpers";
import type { KeyboardCommandHandler } from "../KeyboardCommandHandler";
import type { KeyboardCommand } from "../KeyboardCommandTypeHelpers";
Expand Down Expand Up @@ -189,7 +189,7 @@ suite("keyboard grammar", () => {
parser.feed(tokens);

assert.equal(parser.results.length, 1);
assert.deepStrictEqual(parser.results[0], expected);
assert.deepEqual(parser.results[0], expected);
});
});
});
2 changes: 1 addition & 1 deletion packages/app-vscode/src/scripts/initLaunchSandbox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* developing the Cursorless VSCode extension locally.
*/
import { extensionDependencies } from "@cursorless/lib-common";
import * as cp from "child_process";
import * as cp from "node:child_process";

const vsCodeToolName: string = "code";
const validCliToolParams: Array<string> = ["--code", "--codium"];
Expand Down
4 changes: 2 additions & 2 deletions packages/app-vscode/src/scripts/populateDist/runCommand.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { exec } from "child_process";
import { promisify } from "util";
import { exec } from "node:child_process";
import { promisify } from "node:util";

const execAsync = promisify(exec);

Expand Down
2 changes: 1 addition & 1 deletion packages/app-web-docs/docusaurus.config.mts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { Config } from "@docusaurus/types";
import type { Root } from "mdast";
import { createRequire } from "node:module";
import { fileURLToPath } from "node:url";
import { dirname, extname, relative, resolve } from "path";
import { dirname, extname, relative, resolve } from "node:path";
import { themes } from "prism-react-renderer";
import type { Transformer } from "unified";
import { visit } from "unist-util-visit";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { BorderStyle, Range } from "@cursorless/lib-common";
import * as assert from "node:assert";
import * as assert from "node:assert/strict";
import { flattenHighlights } from "./flattenHighlights";
import type { Highlight, Scope } from "./types";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as assert from "node:assert";
import * as assert from "node:assert/strict";
import { URI } from "vscode-uri";
import { Position } from "../../../types/Position";
import { Range } from "../../../types/Range";
Expand Down Expand Up @@ -73,7 +73,7 @@ suite("InMemoryTextDocument", () => {
test("positionAt", () => {
const document = createTestDocument("hello \n world\r\n");

assert.equal(document.positionAt(-1), "0:0");
assert.equal(document.positionAt(-1).toString(), "0:0");
assert.equal(document.positionAt(0).toString(), "0:0");
assert.equal(document.positionAt(6).toString(), "0:6");
assert.equal(document.positionAt(7).toString(), "0:7");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as assert from "node:assert";
import * as assert from "node:assert/strict";
import { Range } from "../../../types/Range";
import { createTestDocument } from "./createTestDocument";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { range } from "lodash-es";
import * as assert from "node:assert";
import * as assert from "node:assert/strict";
import { createTestDocument } from "./createTestDocument";

interface TestCaseFixture {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import assert from "assert";
import * as assert from "node:assert/strict";
import { map } from "itertools";
import { Range } from "../../types/Range";
import { BorderStyle } from "../decorationStyle.types";
Expand Down Expand Up @@ -136,7 +136,7 @@ suite("handleMultipleLines", () => {
],
);

assert.deepStrictEqual(actual, testCase.expected);
assert.deepEqual(actual, testCase.expected);
});
}
});
16 changes: 10 additions & 6 deletions packages/lib-common/src/testUtil/serialize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class CustomDump {
private readonly opts: yaml.DumpOptions,
) {}

represent() {
represent(): string {
let result = yaml.dump(
this.data,
Object.assign({ replacer, schema }, this.opts),
Expand All @@ -35,7 +35,7 @@ const schema = yaml.DEFAULT_SCHEMA.extend({ implicit: [customDumpType] });
const isObject = (value: unknown): value is object =>
typeof value === "object" && value != null;

function hasSimpleChildren(value: unknown) {
function hasSimpleChildren(value: unknown): boolean {
if (isObject(value)) {
return Object.values(value).every(
(value) => !isObject(value) && !Array.isArray(value),
Expand All @@ -44,9 +44,10 @@ function hasSimpleChildren(value: unknown) {
if (Array.isArray(value)) {
return value.every((value) => !isObject(value) && !Array.isArray(value));
}
return false;
}

function replacer(key: string, value: unknown) {
function replacer(key: string, value: unknown): unknown {
if (key === "") {
return value;
} // top-level, don't change this
Expand All @@ -58,6 +59,9 @@ function replacer(key: string, value: unknown) {
return value; // default
}

export const serialize = (obj: unknown) =>
new CustomDump(obj, { noRefs: true, quotingType: '"' }).represent().trim() +
"\n";
export function serialize(obj: unknown): string {
return (
new CustomDump(obj, { noRefs: true, quotingType: '"' }).represent().trim() +
"\n"
);
}
22 changes: 11 additions & 11 deletions packages/lib-common/src/types/generalizedRangeContains.test.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import assert from "assert";
import * as assert from "node:assert/strict";
import { generalizedRangeContains } from "./GeneralizedRange";
import { Position } from "./Position";

suite("generalizedRangeContains", () => {
test("character", () => {
assert.strictEqual(
assert.equal(
generalizedRangeContains(
{
type: "character",
Expand All @@ -19,7 +19,7 @@ suite("generalizedRangeContains", () => {
),
true,
);
assert.strictEqual(
assert.equal(
generalizedRangeContains(
{
type: "character",
Expand All @@ -34,7 +34,7 @@ suite("generalizedRangeContains", () => {
),
true,
);
assert.strictEqual(
assert.equal(
generalizedRangeContains(
{
type: "character",
Expand All @@ -52,7 +52,7 @@ suite("generalizedRangeContains", () => {
});

test("line", () => {
assert.strictEqual(
assert.equal(
generalizedRangeContains(
{
type: "line",
Expand All @@ -67,7 +67,7 @@ suite("generalizedRangeContains", () => {
),
true,
);
assert.strictEqual(
assert.equal(
generalizedRangeContains(
{
type: "line",
Expand All @@ -82,7 +82,7 @@ suite("generalizedRangeContains", () => {
),
true,
);
assert.strictEqual(
assert.equal(
generalizedRangeContains(
{
type: "line",
Expand All @@ -100,7 +100,7 @@ suite("generalizedRangeContains", () => {
});

test("mixed", () => {
assert.strictEqual(
assert.equal(
generalizedRangeContains(
{
type: "line",
Expand All @@ -115,7 +115,7 @@ suite("generalizedRangeContains", () => {
),
true,
);
assert.strictEqual(
assert.equal(
generalizedRangeContains(
{
type: "line",
Expand All @@ -130,7 +130,7 @@ suite("generalizedRangeContains", () => {
),
false,
);
assert.strictEqual(
assert.equal(
generalizedRangeContains(
{
type: "character",
Expand All @@ -145,7 +145,7 @@ suite("generalizedRangeContains", () => {
),
true,
);
assert.strictEqual(
assert.equal(
generalizedRangeContains(
{
type: "character",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import assert from "assert";
import * as assert from "node:assert/strict";
import type { GeneralizedRange } from "./GeneralizedRange";
import { generalizedRangeTouches } from "./GeneralizedRange";
import { Position } from "./Position";
Expand Down Expand Up @@ -136,6 +136,6 @@ function testRangePair(
b: GeneralizedRange,
expected: boolean,
) {
assert.strictEqual(generalizedRangeTouches(a, b), expected);
assert.strictEqual(generalizedRangeTouches(b, a), expected);
assert.equal(generalizedRangeTouches(a, b), expected);
assert.equal(generalizedRangeTouches(b, a), expected);
}
20 changes: 10 additions & 10 deletions packages/lib-common/src/types/isGeneralizedRangeEqual.test.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import assert from "assert";
import * as assert from "node:assert/strict";
import { isGeneralizedRangeEqual } from "./GeneralizedRange";
import { Position } from "./Position";

suite("isGeneralizedRangeEqual", () => {
test("character", () => {
assert.strictEqual(
assert.equal(
isGeneralizedRangeEqual(
{
type: "character",
Expand All @@ -19,7 +19,7 @@ suite("isGeneralizedRangeEqual", () => {
),
true,
);
assert.strictEqual(
assert.equal(
isGeneralizedRangeEqual(
{
type: "character",
Expand All @@ -34,7 +34,7 @@ suite("isGeneralizedRangeEqual", () => {
),
false,
);
assert.strictEqual(
assert.equal(
isGeneralizedRangeEqual(
{
type: "character",
Expand All @@ -49,7 +49,7 @@ suite("isGeneralizedRangeEqual", () => {
),
false,
);
assert.strictEqual(
assert.equal(
isGeneralizedRangeEqual(
{
type: "character",
Expand All @@ -67,21 +67,21 @@ suite("isGeneralizedRangeEqual", () => {
});

test("line", () => {
assert.strictEqual(
assert.equal(
isGeneralizedRangeEqual(
{ type: "line", start: 0, end: 0 },
{ type: "line", start: 0, end: 0 },
),
true,
);
assert.strictEqual(
assert.equal(
isGeneralizedRangeEqual(
{ type: "line", start: 0, end: 0 },
{ type: "line", start: 0, end: 1 },
),
false,
);
assert.strictEqual(
assert.equal(
isGeneralizedRangeEqual(
{ type: "line", start: 0, end: 0 },
{ type: "line", start: 1, end: 0 },
Expand All @@ -91,7 +91,7 @@ suite("isGeneralizedRangeEqual", () => {
});

test("mixed", () => {
assert.strictEqual(
assert.equal(
isGeneralizedRangeEqual(
{
type: "character",
Expand All @@ -102,7 +102,7 @@ suite("isGeneralizedRangeEqual", () => {
),
false,
);
assert.strictEqual(
assert.equal(
isGeneralizedRangeEqual(
{ type: "line", start: 0, end: 0 },
{
Expand Down
2 changes: 1 addition & 1 deletion packages/lib-common/src/types/position.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as assert from "assert";
import * as assert from "node:assert/strict";
import { Position } from "./Position";

suite("Position", () => {
Expand Down
Loading
Loading