Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main'
Browse files Browse the repository at this point in the history
  • Loading branch information
phillco committed Nov 11, 2022
2 parents b27a175 + 7a1e815 commit c3a7254
Show file tree
Hide file tree
Showing 169 changed files with 1,855 additions and 845 deletions.
3 changes: 3 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
},
"plugins": ["@typescript-eslint", "unused-imports"],
"rules": {
// Note: you must disable the base rule as it can report incorrect errors
"no-restricted-imports": "off",
"@typescript-eslint/no-restricted-imports": "error",
"@typescript-eslint/consistent-type-assertions": [
"error",
{
Expand Down
32 changes: 24 additions & 8 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,25 @@
"args": [
"--extensions-dir=${workspaceFolder}/.vscode-sandbox/extensions",
"--extensionDevelopmentPath=${workspaceFolder}",
"--extensionTestsPath=${workspaceFolder}/out/test/suite/index"
"--extensionTestsPath=${workspaceFolder}/out/test/runners/all"
],
"outFiles": ["${workspaceFolder}/out/test/**/*.js"],
"outFiles": ["${workspaceFolder}/out/**/*.js"],
"preLaunchTask": "${defaultBuildTask}",
"resolveSourceMapLocations": [
"${workspaceFolder}/**",
"!${workspaceFolder}/.vscode-sandbox/**",
"!**/node_modules/**"
]
},
{
"type": "node",
"request": "launch",
"name": "Unit tests only",
"program": "${workspaceFolder}/out/test/scripts/runUnitTestsOnly",
"env": {
"CURSORLESS_TEST": "true"
},
"outFiles": ["${workspaceFolder}/out/**/*.js"],
"preLaunchTask": "${defaultBuildTask}",
"resolveSourceMapLocations": [
"${workspaceFolder}/**",
Expand All @@ -52,9 +68,9 @@
"args": [
"--extensions-dir=${workspaceFolder}/.vscode-sandbox/extensions",
"--extensionDevelopmentPath=${workspaceFolder}",
"--extensionTestsPath=${workspaceFolder}/out/test/suite/index"
"--extensionTestsPath=${workspaceFolder}/out/test/runners/all"
],
"outFiles": ["${workspaceFolder}/out/test/**/*.js"],
"outFiles": ["${workspaceFolder}/out/**/*.js"],
"preLaunchTask": "${defaultBuildTask}",
"resolveSourceMapLocations": [
"${workspaceFolder}/**",
Expand All @@ -73,9 +89,9 @@
"args": [
"--extensions-dir=${workspaceFolder}/.vscode-sandbox/extensions",
"--extensionDevelopmentPath=${workspaceFolder}",
"--extensionTestsPath=${workspaceFolder}/out/test/suite/index"
"--extensionTestsPath=${workspaceFolder}/out/test/runners/all"
],
"outFiles": ["${workspaceFolder}/out/test/**/*.js"],
"outFiles": ["${workspaceFolder}/out/**/*.js"],
"preLaunchTask": "${defaultBuildTask}",
"resolveSourceMapLocations": [
"${workspaceFolder}/**",
Expand All @@ -95,9 +111,9 @@
"args": [
"--extensions-dir=${workspaceFolder}/.vscode-sandbox/extensions",
"--extensionDevelopmentPath=${workspaceFolder}",
"--extensionTestsPath=${workspaceFolder}/out/test/suite/index"
"--extensionTestsPath=${workspaceFolder}/out/test/runners/all"
],
"outFiles": ["${workspaceFolder}/out/test/**/*.js"],
"outFiles": ["${workspaceFolder}/out/**/*.js"],
"preLaunchTask": "${defaultBuildTask}",
"resolveSourceMapLocations": [
"${workspaceFolder}/**",
Expand Down
2 changes: 1 addition & 1 deletion docs-site/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,6 @@
"typedoc-plugin-mdn-links": "^1.0.4",
"typedoc-plugin-missing-exports": "^0.22.6",
"typedoc-plugin-rename-defaults": "^0.4.0",
"typescript": "^4.5.5"
"typescript": "4.6.3"
}
}
8 changes: 4 additions & 4 deletions docs-site/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -8257,10 +8257,10 @@ typedoc@^0.22.10:
minimatch "^3.0.4"
shiki "^0.9.12"

typescript@^4.5.5:
version "4.5.5"
resolved "https://registry.npmjs.org/typescript/-/typescript-4.5.5.tgz"
integrity sha512-TCTIul70LyWe6IJWT8QSYeA54WQe8EjQFU4wY52Fasj5UKx88LNYKCgBEHcOMOrFF1rKGbD8v/xcNWVUq9SymA==
typescript@4.6.3:
version "4.6.3"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.6.3.tgz#eefeafa6afdd31d725584c67a0eaba80f6fc6c6c"
integrity sha512-yNIatDa5iaofVozS/uQJEl3JRWLKKGJKh6Yaiv0GLGSuhpFJe7P3SbHZ8/yjAHRQwKRoA6YZqlfjXWmVzoVSMw==

ua-parser-js@^0.7.30:
version "0.7.31"
Expand Down
16 changes: 11 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -566,6 +566,10 @@
"url": "https://github.com/sponsors/pokey"
},
"funding": "https://github.com/sponsors/pokey",
"_moduleAliases": {
"@cursorless/common": "./out/libs/common/index.js",
"@cursorless/vscode-common": "./out/libs/vscode-common/index.js"
},
"scripts": {
"vscode:prepublish": "npm run -S esbuild-base -- --minify",
"update-licenses": "npx npm-license-crawler --onlyDirectDependencies --csv third-party-licenses.csv",
Expand All @@ -577,9 +581,9 @@
"watch": "tsc -watch -p ./",
"pretest": "yarn run compile && yarn run lint && yarn run esbuild",
"lint": "eslint src --ext ts",
"test": "env CURSORLESS_TEST=true node ./out/test/runTest.js",
"test": "env CURSORLESS_TEST=true node ./out/test/scripts/runTestsCI.js",
"unused-exports": "ts-unused-exports tsconfig.json --showLineNumber",
"init-launch-sandbox": "node ./out/test/initLaunchSandbox.js",
"init-launch-sandbox": "node ./out/scripts/initLaunchSandbox.js",
"prepare-for-extension-publish": "node ./out/scripts/prepareForExtensionPublish.js"
},
"devDependencies": {
Expand All @@ -603,19 +607,21 @@
"glob": "^7.1.7",
"js-yaml": "^4.1.0",
"mocha": "^8.1.3",
"module-alias": "^2.2.2",
"npm-license-crawler": "^0.2.1",
"prettier": "2.7.1",
"semver": "^7.3.7",
"sinon": "^11.1.1",
"ts-unused-exports": "8.0.0",
"typescript": "^4.5.5"
"ts-unused-exports": "^8.0.0",
"typescript": "4.6.3"
},
"dependencies": {
"@types/lodash": "^4.14.168",
"immer": "^9.0.15",
"immutability-helper": "^3.1.1",
"itertools": "^1.7.1",
"lodash": "^4.17.21",
"node-html-parser": "^5.3.3"
"node-html-parser": "^5.3.3",
"vscode-uri": "^3.0.6"
}
}
2 changes: 1 addition & 1 deletion src/actions/CommandAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
runOnTargetsForEachEditor,
} from "../util/targetUtils";
import { Action, ActionReturnValue } from "./actions.types";
import { getActiveTextEditor } from "../ide/activeTextEditor";
import { getActiveTextEditor } from "../ide/vscode/activeTextEditor";

export interface CommandOptions {
command?: string;
Expand Down
2 changes: 1 addition & 1 deletion src/actions/Fold.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Graph } from "../typings/Types";
import { focusEditor } from "../util/setSelectionsAndFocusEditor";
import { createThatMark, ensureSingleEditor } from "../util/targetUtils";
import { Action, ActionReturnValue } from "./actions.types";
import { getActiveTextEditor } from "../ide/activeTextEditor";
import { getActiveTextEditor } from "../ide/vscode/activeTextEditor";

class FoldAction implements Action {
constructor(private command: string) {
Expand Down
2 changes: 1 addition & 1 deletion src/actions/MakeshiftActions.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Target } from "../typings/target.types";
import sleep from "../util/sleep";
import sleep from "../libs/common/util/sleep";
import CommandAction from "./CommandAction";

abstract class MakeshiftAction extends CommandAction {
Expand Down
2 changes: 1 addition & 1 deletion src/actions/Paste.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
} from "../util/setSelectionsAndFocusEditor";
import { ensureSingleEditor } from "../util/targetUtils";
import { ActionReturnValue } from "./actions.types";
import { getActiveTextEditor } from "../ide/activeTextEditor";
import { getActiveTextEditor } from "../ide/vscode/activeTextEditor";

export class Paste {
constructor(private graph: Graph) {}
Expand Down
2 changes: 1 addition & 1 deletion src/actions/Scroll.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Graph } from "../typings/Types";
import { groupBy } from "../util/itertools";
import { focusEditor } from "../util/setSelectionsAndFocusEditor";
import { Action, ActionReturnValue } from "./actions.types";
import { getActiveTextEditor } from "../ide/activeTextEditor";
import { getActiveTextEditor } from "../ide/vscode/activeTextEditor";

class Scroll implements Action {
constructor(private graph: Graph, private at: string) {
Expand Down
16 changes: 16 additions & 0 deletions src/apps/cursorless-vscode-e2e/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"rules": {
"@typescript-eslint/no-restricted-imports": [
"error",
{
"patterns": [
{
"group": ["../*"],
"message": "Cursorless end-to-end tests shouldn't import from Cursorless extension",
"allowTypeImports": true
}
]
}
]
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Context, Done } from "mocha";
import type { Context, Done } from "mocha";

/**
* if an async returns after the method times out,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { IDE, sleep, SpyIDE } from "@cursorless/common";
import { getCursorlessApi } from "@cursorless/vscode-common";
import { Context } from "mocha";
import * as sinon from "sinon";
import sleep from "../../util/sleep";
import shouldUpdateFixtures from "./shouldUpdateFixtures";

/**
Expand All @@ -16,19 +17,33 @@ let retryCount = -1;
*/
let previousTestTitle = "";

export function standardSuiteSetup(suite: Mocha.Suite) {
export function endToEndTestSetup(suite: Mocha.Suite) {
suite.timeout("100s");
suite.retries(5);

teardown(() => {
sinon.restore();
});
let ide: IDE | undefined;
let injectIde: ((ide: IDE) => void) | undefined;
let spy: SpyIDE | undefined;

setup(async function (this: Context) {
const title = this.test!.fullTitle();
retryCount = title === previousTestTitle ? retryCount + 1 : 0;
previousTestTitle = title;
({ ide, injectIde } = (await getCursorlessApi()).testHelpers!);
spy = new SpyIDE(ide!);
injectIde!(spy);
});

teardown(() => {
sinon.restore();
injectIde!(ide!);
});

return {
getSpy() {
return spy;
},
};
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as path from "path";
import { walkFilesSync } from "../../testUtil/walkSync";
import { walkFilesSync } from "@cursorless/common";

export function getFixturesPath() {
return path.join(__dirname, "../../../src/test/suite/fixtures");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as sinon from "sinon";
import { Graph } from "../typings/Types";
import type { Graph } from "../../typings/Types";

export function mockPrePhraseGetVersion(
graph: Graph,
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { getParseTreeApi } from "@cursorless/vscode-common";
import * as vscode from "vscode";
import { getParseTreeApi } from "../util/getExtensionApi";

export async function openNewEditor(
content: string,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { CURSORLESS_COMMAND_ID } from "@cursorless/common";
import * as vscode from "vscode";
import { CURSORLESS_COMMAND_ID } from "../common/commandIds";
import type { Command } from "../core/commandRunner/command.types";
import type { Command } from "../../core/commandRunner/command.types";

export function runCursorlessCommand(command: Command) {
return vscode.commands.executeCommand(CURSORLESS_COMMAND_ID, command);
Expand Down
File renamed without changes.
16 changes: 16 additions & 0 deletions src/apps/cursorless-vscode-e2e/suite/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"rules": {
"@typescript-eslint/no-restricted-imports": [
"error",
{
"patterns": [
{
"group": ["../../*"],
"message": "Cursorless end-to-end tests shouldn't import from Cursorless extension",
"allowTypeImports": true
}
]
}
]
}
}
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import { CURSORLESS_COMMAND_ID } from "@cursorless/common";
import { getCursorlessApi } from "@cursorless/vscode-common";
import * as assert from "assert";
import * as vscode from "vscode";
import { CURSORLESS_COMMAND_ID } from "../../common/commandIds";
import { getCursorlessApi } from "../../util/getExtensionApi";
import { openNewEditor } from "../openNewEditor";
import { standardSuiteSetup } from "./standardSuiteSetup";
import { endToEndTestSetup } from "../endToEndTestSetup";

suite("Backward compatibility", async function () {
standardSuiteSetup(this);
endToEndTestSetup(this);

test("Backward compatibility", runTest);
});

async function runTest() {
const graph = (await getCursorlessApi()).graph!;
const { graph } = (await getCursorlessApi()).testHelpers!;

const editor = await openNewEditor("");

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { getCursorlessApi } from "@cursorless/vscode-common";
import * as assert from "assert";
import * as vscode from "vscode";
import { runCursorlessCommand } from "../../client-e2e-test/runCommand";
import { getCursorlessApi } from "../../util/getExtensionApi";
import { openNewEditor } from "../openNewEditor";
import { standardSuiteSetup } from "./standardSuiteSetup";
import { runCursorlessCommand } from "../runCommand";
import { endToEndTestSetup } from "../endToEndTestSetup";

suite("breakpoints", async function () {
standardSuiteSetup(this);
endToEndTestSetup(this);

setup(() => {
removeBreakpoints();
Expand All @@ -23,7 +23,7 @@ suite("breakpoints", async function () {
});

async function breakpointHarpAdd() {
const graph = (await getCursorlessApi()).graph!;
const { graph } = (await getCursorlessApi()).testHelpers!;
await openNewEditor(" hello");
await graph.hatTokenMap.addDecorations();

Expand All @@ -50,7 +50,7 @@ async function breakpointHarpAdd() {
}

async function breakpointTokenHarpAdd() {
const graph = (await getCursorlessApi()).graph!;
const { graph } = (await getCursorlessApi()).testHelpers!;
await openNewEditor(" hello");
await graph.hatTokenMap.addDecorations();

Expand Down Expand Up @@ -78,7 +78,7 @@ async function breakpointTokenHarpAdd() {
}

async function breakpointHarpRemove() {
const graph = (await getCursorlessApi()).graph!;
const { graph } = (await getCursorlessApi()).testHelpers!;
const editor = await openNewEditor(" hello");
await graph.hatTokenMap.addDecorations();

Expand Down Expand Up @@ -109,7 +109,7 @@ async function breakpointHarpRemove() {
}

async function breakpointTokenHarpRemove() {
const graph = (await getCursorlessApi()).graph!;
const { graph } = (await getCursorlessApi()).testHelpers!;
const editor = await openNewEditor(" hello");
await graph.hatTokenMap.addDecorations();

Expand Down
Loading

0 comments on commit c3a7254

Please sign in to comment.