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
5 changes: 3 additions & 2 deletions oxlint.config.mts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import { defineConfig } from "oxlint";

// These rules should probably be re-enabled eventually
const temporarilyDisabledRules = [
"unicorn/no-array-for-each",
"unicorn/no-array-reverse",
// Requires es2023
"unicorn/no-array-sort",
"unicorn/no-array-reverse",
];

const disabledRules = [
Expand All @@ -26,6 +26,7 @@ const disabledRules = [
"eslint/no-continue",
"eslint/no-eq-null",
"eslint/no-lonely-if",
"eslint/no-loop-func",
"eslint/no-magic-numbers",
"eslint/no-negated-condition",
"eslint/no-plusplus",
Expand Down
4 changes: 2 additions & 2 deletions packages/app-neovim/src/registerCommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,9 @@ export function registerCommands(
"cursorless.documentationOpened": dummyCommandHandler,
};

Object.entries(commands).forEach(([commandId, callback]) => {
for (const [commandId, callback] of Object.entries(commands)) {
getNeovimRegistry().registerCommand(commandId, callback);
});
}
}

export function dummyCommandHandler(...args: any[]) {
Expand Down
4 changes: 2 additions & 2 deletions packages/app-vscode/src/ReleaseNotes.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,12 +157,12 @@ suite("release notes", () => {
sinon.restore();
});

testCases.forEach(({ input, expectedOutput }) => {
for (const { input, expectedOutput } of testCases) {
test(
getTestName(input),
asyncSafety(() => runTest(input, expectedOutput)),
);
});
}
});

function getTestName(input: Input) {
Expand Down
10 changes: 6 additions & 4 deletions packages/app-vscode/src/createScopeVisualizer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,18 @@ export function createScopeVisualizer(
);
scopeVisualizer.start();
currentScopeType = scopeType;
listeners
.slice()
.forEach((listener) => listener(scopeType, visualizationType));
for (const listener of listeners.slice()) {
listener(scopeType, visualizationType);
}
},

stop() {
scopeVisualizer?.dispose();
scopeVisualizer = undefined;
currentScopeType = undefined;
listeners.slice().forEach((listener) => listener(undefined, undefined));
for (const listener of listeners.slice()) {
listener(undefined, undefined);
}
},

get scopeType() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,29 +62,27 @@ export class VscodeFancyRangeHighlighterRenderer {
b.differentiatedStyle.differentiationIndex,
);

decoratedRanges.forEach(
({ differentiatedStyle: styleParameters, ranges }) => {
const decorationType = this.decorationTypes.get(styleParameters);
for (const { differentiatedStyle, ranges } of decoratedRanges) {
const decorationType = this.decorationTypes.get(differentiatedStyle);

vscodeApi.editor.setDecorations(
editor.vscodeEditor,
decorationType,
ranges.map(toVscodeRange),
);
vscodeApi.editor.setDecorations(
editor.vscodeEditor,
decorationType,
ranges.map(toVscodeRange),
);

untouchedDecorationTypes.delete(decorationType);
},
);
untouchedDecorationTypes.delete(decorationType);
}

untouchedDecorationTypes.forEach((decorationType) => {
for (const decorationType of untouchedDecorationTypes) {
editor.vscodeEditor.setDecorations(decorationType, []);
});
}
}

dispose() {
Array.from(this.decorationTypes.values()).forEach((decorationType) => {
for (const decorationType of this.decorationTypes.values()) {
decorationType.dispose();
});
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,9 @@ export abstract class VscodeScopeVisualizer {
}

dispose() {
this.disposables.forEach((disposable) => disposable.dispose());
for (const disposable of this.disposables) {
disposable.dispose();
}
this.renderer?.dispose();
this.scopeListenerDisposable?.dispose();
}
Expand Down
4 changes: 2 additions & 2 deletions packages/app-vscode/src/ide/vscode/VscodeEdit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ export async function vscodeEdit(
edits: Edit[],
): Promise<boolean> {
return await editor.edit((editBuilder) => {
edits.forEach(({ range, text, isReplace }) => {
for (const { range, text, isReplace } of edits) {
if (text === "") {
editBuilder.delete(toVscodeRange(range));
} else if (range.isEmpty && !isReplace) {
editBuilder.insert(toVscodePosition(range.start), text);
} else {
editBuilder.replace(toVscodeRange(range), text);
}
});
}
});
}
4 changes: 2 additions & 2 deletions packages/app-vscode/src/ide/vscode/VscodeFlashHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,12 @@ export class VscodeFlashHandler {
): void {
const editorRangeMap = groupBy(ranges, ({ editor }) => editor.id);

this.ide.visibleTextEditors.forEach((editor) => {
for (const editor of this.ide.visibleTextEditors) {
const ranges = (editorRangeMap.get(editor.id) ?? []).map(
({ range }) => range,
);
void this.highlights.setHighlightRanges(style, editor, ranges);
});
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export async function vscodeToggleBreakpoint(
const toAdd: vscode.Breakpoint[] = [];
const toRemove: vscode.Breakpoint[] = [];

ranges.forEach((range) => {
for (const range of ranges) {
const existing = getBreakpoints(uri, range);

if (existing.length > 0) {
Expand All @@ -34,7 +34,7 @@ export async function vscodeToggleBreakpoint(
),
);
}
});
}

vscode.debug.addBreakpoints(toAdd);
vscode.debug.removeBreakpoints(toRemove);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,9 +180,9 @@ export class VscodeHatRenderer {
}

private destroyDecorations() {
Object.values(this.decorationMap).forEach((decoration) => {
for (const decoration of Object.values(this.decorationMap)) {
decoration.dispose();
});
}
}

private async recomputeDecorations() {
Expand Down Expand Up @@ -495,7 +495,9 @@ export class VscodeHatRenderer {
dispose() {
this.destroyDecorations();
this.hatsDirWatcherDisposable?.dispose();
this.disposables.forEach(({ dispose }) => dispose());
for (const disposable of this.disposables) {
disposable.dispose();
}
}
}

Expand Down
12 changes: 6 additions & 6 deletions packages/app-vscode/src/ide/vscode/hats/VscodeHats.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,20 +107,20 @@ export class VscodeHats implements Hats {
]),
);

this.hatRanges.forEach(({ editor, range, styleName }) => {
for (const { editor, range, styleName } of this.hatRanges) {
decorationRanges.get(editor)?.[styleName]?.push(range);
});
}

decorationRanges.forEach((ranges, editor) => {
hatStyleNames.forEach((hatStyleName) => {
for (const [editor, ranges] of decorationRanges) {
for (const hatStyleName of hatStyleNames) {
(editor as VscodeTextEditor).vscodeEditor.setDecorations(
this.hatRenderer.getDecorationType(
hatStyleName as VscodeHatStyleName,
)!,
ranges[hatStyleName]?.map((range) => toVscodeRange(range)) ?? [],
);
});
});
}
}
}

get enabledHatStyles(): HatStyleMap {
Expand Down
4 changes: 2 additions & 2 deletions packages/app-vscode/src/ide/vscode/textLine.vscode.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ const whiteSpaceTests: [string, number | undefined, number | undefined][] = [
suite("TextLine", function () {
this.timeout("100s");
this.retries(5);
whiteSpaceTests.forEach(([text, trimmedStart, trimmedEnd]) => {
for (const [text, trimmedStart, trimmedEnd] of whiteSpaceTests) {
test(`whitespace '${text}'`, async () => {
const editor = await getReusableEditor(text);
const line = new VscodeTextLine(editor.document.lineAt(0));

assert.equal(line.rangeTrimmed?.start?.character, trimmedStart);
assert.equal(line.rangeTrimmed?.end?.character, trimmedEnd);
});
});
}
});
12 changes: 7 additions & 5 deletions packages/app-vscode/src/keyboard/KeyboardHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,9 @@ export class KeyboardHandler {
}

dispose() {
this.disposables.forEach(({ dispose }) => dispose());
for (const disposable of this.disposables) {
disposable.dispose();
}
}

/**
Expand All @@ -150,10 +152,10 @@ export class KeyboardHandler {
// one. Eg if you're in the middle of typing a command and we turn off
// the modal mode, we want to cancel the command
if (index !== -1) {
this.listeners
.slice(index + 1)
.reverse()
.forEach(({ listener }) => listener.handleCancelled());
const listenersToCancel = this.listeners.slice(index + 1).reverse();
for (const entry of listenersToCancel) {
entry.listener.handleCancelled();
}
this.listeners.splice(index);
}
this.ensureState();
Expand Down
4 changes: 2 additions & 2 deletions packages/app-vscode/src/keyboard/buildSuffixTrie.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ const testCases: TestCase[] = [
];

suite("buildSuffixTrie", () => {
testCases.forEach(({ input, expected, expectedConflicts }) => {
for (const { input, expected, expectedConflicts } of testCases) {
test(`input: ${input}`, () => {
const { trie, conflicts } = buildSuffixTrie<string>(
input.map((key) => [key, key]),
Expand All @@ -138,7 +138,7 @@ suite("buildSuffixTrie", () => {
(expectedConflicts ?? []).map(sortEntries),
);
});
});
}
});

function sortEntries(entries: KeyValuePair<string>[]) {
Expand Down
13 changes: 9 additions & 4 deletions packages/app-vscode/src/keyboard/buildSuffixTrie.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,9 @@ export function buildSuffixTrie<T>(entries: [string, T][]): BuildTrieReturn<T> {

if (isTopLevel) {
// If we're top-level, we mark every conflicting entry as bad
conflicting.forEach(({ id }) => badEntries.add(id));
for (const entry of conflicting) {
badEntries.add(entry.id);
}

const conflictingTopLevel = conflicting.filter(
({ isTopLevel }) => isTopLevel,
Expand All @@ -94,9 +96,12 @@ export function buildSuffixTrie<T>(entries: [string, T][]): BuildTrieReturn<T> {
);
} else {
// If we're not top-level, we only mark other non-top-level entries as bad
conflicting
.filter(({ isTopLevel }) => !isTopLevel)
.forEach(({ id }) => badEntries.add(id));
const nonTopLevelEntries = conflicting.filter(
(entry) => !entry.isTopLevel,
);
for (const entry of nonTopLevelEntries) {
badEntries.add(entry.id);
}
}

// If we got here, we have a conflict, so we mark ourselves as bad
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ suite("keyboard.getAcceptableTokenTypes", () => {
parser = new nearley.Parser(nearley.Grammar.fromCompiled(grammar));
});

testCases.forEach(({ tokens, expected }) => {
for (const { tokens, expected } of testCases) {
test(`after \`${stringifyTokens(tokens)}\``, () => {
parser.feed(tokens);
for (const value of expected) {
Expand All @@ -160,5 +160,5 @@ suite("keyboard.getAcceptableTokenTypes", () => {
);
}
});
});
}
});
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
Expand Up @@ -184,12 +184,12 @@ suite("keyboard grammar", () => {
parser = new nearley.Parser(nearley.Grammar.fromCompiled(grammar));
});

testCases.forEach(({ tokens, expected }) => {
for (const { tokens, expected } of testCases) {
test(`should parse \`${stringifyTokens(tokens)}\``, () => {
parser.feed(tokens);

assert.equal(parser.results.length, 1);
assert.deepEqual(parser.results[0], expected);
});
});
}
});
4 changes: 2 additions & 2 deletions packages/app-vscode/src/logQuickActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ export async function logQuickActions(kind?: string) {
}),
);

availableCodeActions.forEach((availableCodeAction) => {
for (const availableCodeAction of availableCodeActions) {
console.log(JSON.stringify(availableCodeAction, null, 2));
});
}

void window.showInformationMessage(
"Run command 'Developer: Toggle Developer Tools' to see available code actions",
Expand Down
7 changes: 4 additions & 3 deletions packages/app-vscode/src/scripts/hatAdjustments/average.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ function main() {
}),
);

(["value", "originalAdjustment", "newAdjustment"] as const).forEach((key) => {
const keys = ["value", "originalAdjustment", "newAdjustment"] as const;
for (const key of keys) {
const map = Object.fromEntries(
HAT_SHAPES.map((shape) => {
return [
Expand All @@ -66,10 +67,10 @@ function main() {
},
];
}),
) as IndividualHatAdjustmentMap;
);
console.log(`${key}: `);
console.log(JSON.stringify(map, null, 2));
});
}
}

main();
4 changes: 2 additions & 2 deletions packages/app-vscode/src/scripts/initLaunchSandbox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ async function main() {
// Read cli tool name from arguments, assume tool name is 'code' if not present
let cliToolName = vsCodeToolName;

process.argv.forEach((argument) => {
for (const argument of process.argv) {
if (validCliToolParams.has(argument)) {
cliToolName = argument.replace("--", "");
console.log(`Cli tool name manually set to ${cliToolName}`);
}
});
}

const extensions = [
...extensionDependencies,
Expand Down
Loading
Loading