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
3 changes: 2 additions & 1 deletion .oxlintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@
"variables": "suggestion"
}
}
]
],
"unicorn/require-post-message-target-origin": "allow" // false-positive
},
"overrides": [
{
Expand Down
24 changes: 15 additions & 9 deletions oxlint/baseline.config.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,6 @@
{
"$schema": "../node_modules/oxlint/configuration_schema.json",
"rules": {
// perf
"eslint/no-await-in-loop": "off",
// suspicious
"import/no-named-as-default": "off",
"eslint/no-shadow": "off",
"unicorn/require-post-message-target-origin": "off",
"unicorn/no-array-sort": "off"
},
"rules": {},
"overrides": [
{
"files": ["src/webview/**/*.ts"],
Expand All @@ -21,6 +13,20 @@
"rules": {
"eslint/no-undef": "off"
}
},

// needs refactor
{
"files": [
"src/extension/workspaceSearch.ts",
"src/backend/queries/loadCommits.ts",
"src/backend/utils/repoSearch.ts",
"src/extension/workspaceWatcher.ts"
],
"rules": {
// perf
"eslint/no-await-in-loop": "allow"
}
}
]
}
8 changes: 4 additions & 4 deletions scripts/check-l10n.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ function extractPlaceholders(text) {
}

// Return sorted array for consistent comparison
return placeholders.sort();
return placeholders.toSorted();
}

/**
Expand Down Expand Up @@ -84,13 +84,13 @@ function checkFileSet(baseDir, baseFileName, filePattern, sectionTitle) {
files = fs
.readdirSync(baseDir)
.filter((file) => file.startsWith(filePattern) && file !== baseFileName)
.sort();
.toSorted();
} else {
// For bundle.l10n files, look in l10n directory
files = fs
.readdirSync(baseDir)
.filter((file) => file.startsWith(filePattern) && file !== baseFileName)
.sort();
.toSorted();
}

if (files.length === 0) {
Expand Down Expand Up @@ -208,7 +208,7 @@ function printCoverageSummary(allStats) {
});

Object.keys(localeMap)
.sort()
.toSorted()
.forEach((locale) => {
const bundleCov =
localeMap[locale]["bundle"] !== undefined ? `${localeMap[locale]["bundle"]}%` : "N/A";
Expand Down
2 changes: 1 addition & 1 deletion src/backend/gitClient.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { SimpleGit } from "simple-git";
import simpleGit from "simple-git";
import { simpleGit } from "simple-git";

export type GitClient = ReturnType<typeof gitClientFactory>;
export type GitInstance = GitClient["getInstance"];
Expand Down
2 changes: 1 addition & 1 deletion src/backend/utils/git.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import simpleGit from "simple-git";
import { simpleGit } from "simple-git";

export async function isGitRepository(repoPath: string, gitPath: string): Promise<boolean> {
try {
Expand Down
8 changes: 4 additions & 4 deletions src/backend/utils/path.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@ import * as vscode from "vscode";

const FS_REGEX = /\\/g;

export function isDirectory(path: string) {
export function isDirectory(filePath: string) {
return new Promise<boolean>((resolve) => {
fs.stat(path, (err, stats) => {
fs.stat(filePath, (err, stats) => {
resolve(err ? false : stats.isDirectory());
});
});
}

export function doesPathExist(path: string) {
export function doesPathExist(filePath: string) {
return new Promise<boolean>((resolve) => {
fs.stat(path, (err) => resolve(!err));
fs.stat(filePath, (err) => resolve(!err));
});
}

Expand Down
6 changes: 3 additions & 3 deletions src/diffDocProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ export class DiffDocProvider implements vscode.TextDocumentContentProvider {
.show([`${request.commit}:${request.filePath}`])
.catch(() => "")
.then((data) => {
let document = new DiffDocument(data);
this.docs.set(uri.toString(), document);
return document.value;
let doc = new DiffDocument(data);
this.docs.set(uri.toString(), doc);
return doc.value;
});
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/extension/repoManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { StatusBarItem } from "@/statusBarItem";
import { GitRepoSet, GitRepoState } from "@/types";

function sortRepos(repos: GitRepoSet) {
const repoPaths = Object.keys(repos).sort();
const repoPaths = Object.keys(repos).toSorted();
const sorted: GitRepoSet = {};
for (let i = 0; i < repoPaths.length; i++) {
sorted[repoPaths[i]] = repos[repoPaths[i]];
Expand Down
4 changes: 2 additions & 2 deletions src/extensionState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ export class ExtensionState {
this.avatarStorageAvailable = true;
} else {
fs.mkdir(this.globalStoragePath, () => {
fs.mkdir(this.globalStoragePath + AVATAR_STORAGE_FOLDER, (err) => {
if (!err) this.avatarStorageAvailable = true;
fs.mkdir(this.globalStoragePath + AVATAR_STORAGE_FOLDER, (mkdirErr) => {
if (!mkdirErr) this.avatarStorageAvailable = true;
});
});
}
Expand Down
2 changes: 1 addition & 1 deletion src/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"paths": {
"@/*": ["./*"]
},
"lib": ["es2020"],
"lib": ["es2023"],
"module": "commonjs",
"outDir": "../out",
"noFallthroughCasesInSwitch": true,
Expand Down
26 changes: 13 additions & 13 deletions src/webview/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -218,8 +218,8 @@ class GitGraphView {
commits,
(a, b) =>
a.hash === b.hash &&
arraysEqual(a.refs, b.refs, (a, b) => a.name === b.name && a.type === b.type) &&
arraysEqual(a.parentHashes, b.parentHashes, (a, b) => a === b)
arraysEqual(a.refs, b.refs, (ra, rb) => ra.name === rb.name && ra.type === rb.type) &&
arraysEqual(a.parentHashes, b.parentHashes, (pa, pb) => pa === pb)
)
) {
if (this.commits.length > 0 && this.commits[0].hash === "*") {
Expand Down Expand Up @@ -612,11 +612,11 @@ class GitGraphView {
);
} else {
let options = this.commits[this.commitLookup[hash]].parentHashes.map(
(hash, index) => ({
(parentHash, index) => ({
name:
abbrevCommit(hash) +
(typeof this.commitLookup[hash] === "number"
? ": " + this.commits[this.commitLookup[hash]].message
abbrevCommit(parentHash) +
(typeof this.commitLookup[parentHash] === "number"
? ": " + this.commits[this.commitLookup[parentHash]].message
: ""),
value: (index + 1).toString()
})
Expand Down Expand Up @@ -663,11 +663,11 @@ class GitGraphView {
);
} else {
let options = this.commits[this.commitLookup[hash]].parentHashes.map(
(hash, index) => ({
(parentHash, index) => ({
name:
abbrevCommit(hash) +
(typeof this.commitLookup[hash] === "number"
? ": " + this.commits[this.commitLookup[hash]].message
abbrevCommit(parentHash) +
(typeof this.commitLookup[parentHash] === "number"
? ": " + this.commits[this.commitLookup[parentHash]].message
: ""),
value: (index + 1).toString()
})
Expand Down Expand Up @@ -1567,10 +1567,10 @@ function showContextMenu(e: MouseEvent, items: ContextMenuElement[], sourceElem:
: event.pageY - bounds.height + 2) + "px";
contextMenu.style.opacity = "1";

addListenerToClass("contextMenuItem", "click", (e) => {
e.stopPropagation();
addListenerToClass("contextMenuItem", "click", (ev) => {
ev.stopPropagation();
hideContextMenu();
items[parseInt((<HTMLElement>e.target).dataset.index!)]!.onClick();
items[parseInt((<HTMLElement>ev.target).dataset.index!)]!.onClick();
});

contextMenuSource = sourceElem;
Expand Down
2 changes: 1 addition & 1 deletion tests/backend/actions/branch/checkout.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as cp from "node:child_process";
import * as fs from "node:fs";

import simpleGit from "simple-git";
import { simpleGit } from "simple-git";
import { afterAll, beforeAll, describe, expect, it } from "vitest";

import { checkoutBranch } from "@/backend/actions/branch";
Expand Down
2 changes: 1 addition & 1 deletion tests/backend/actions/branch/create.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as cp from "node:child_process";
import * as fs from "node:fs";

import simpleGit from "simple-git";
import { simpleGit } from "simple-git";
import { afterAll, beforeAll, describe, expect, it } from "vitest";

import { createBranch } from "@/backend/actions/branch";
Expand Down
2 changes: 1 addition & 1 deletion tests/backend/actions/branch/delete.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as cp from "node:child_process";
import * as fs from "node:fs";
import * as path from "node:path";

import simpleGit from "simple-git";
import { simpleGit } from "simple-git";
import { afterAll, beforeAll, describe, expect, it } from "vitest";

import { deleteBranch } from "@/backend/actions/branch";
Expand Down
2 changes: 1 addition & 1 deletion tests/backend/actions/branch/rename.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as cp from "node:child_process";
import * as fs from "node:fs";

import simpleGit from "simple-git";
import { simpleGit } from "simple-git";
import { afterAll, beforeAll, describe, expect, it } from "vitest";

import { renameBranch } from "@/backend/actions/branch";
Expand Down
2 changes: 1 addition & 1 deletion tests/backend/actions/commit/checkout.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as cp from "node:child_process";
import * as fs from "node:fs";

import simpleGit from "simple-git";
import { simpleGit } from "simple-git";
import { afterAll, beforeAll, describe, expect, it } from "vitest";

import { checkoutCommit } from "@/backend/actions/commit";
Expand Down
2 changes: 1 addition & 1 deletion tests/backend/actions/commit/cherrypick.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as cp from "node:child_process";
import * as fs from "node:fs";
import * as path from "node:path";

import simpleGit from "simple-git";
import { simpleGit } from "simple-git";
import { afterAll, beforeAll, describe, expect, it } from "vitest";

import { cherrypickCommit } from "@/backend/actions/commit";
Expand Down
2 changes: 1 addition & 1 deletion tests/backend/actions/commit/reset.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as cp from "node:child_process";
import * as fs from "node:fs";
import * as path from "node:path";

import simpleGit from "simple-git";
import { simpleGit } from "simple-git";
import { afterAll, beforeAll, describe, expect, it } from "vitest";

import { resetToCommit } from "@/backend/actions/commit";
Expand Down
2 changes: 1 addition & 1 deletion tests/backend/actions/commit/revert.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as cp from "node:child_process";
import * as fs from "node:fs";
import * as path from "node:path";

import simpleGit from "simple-git";
import { simpleGit } from "simple-git";
import { afterAll, beforeAll, describe, expect, it } from "vitest";

import { revertCommit } from "@/backend/actions/commit";
Expand Down
2 changes: 1 addition & 1 deletion tests/backend/actions/merge/mergeBranch.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as cp from "node:child_process";
import * as fs from "node:fs";
import * as path from "node:path";

import simpleGit from "simple-git";
import { simpleGit } from "simple-git";
import { afterAll, beforeAll, describe, expect, it } from "vitest";

import { mergeBranch } from "@/backend/actions/merge";
Expand Down
2 changes: 1 addition & 1 deletion tests/backend/actions/merge/mergeCommit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as cp from "node:child_process";
import * as fs from "node:fs";
import * as path from "node:path";

import simpleGit from "simple-git";
import { simpleGit } from "simple-git";
import { afterAll, beforeAll, describe, expect, it } from "vitest";

import { mergeCommit } from "@/backend/actions/merge";
Expand Down
2 changes: 1 addition & 1 deletion tests/backend/actions/tag/add.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as cp from "node:child_process";
import * as fs from "node:fs";

import simpleGit from "simple-git";
import { simpleGit } from "simple-git";
import { afterAll, beforeAll, describe, expect, it } from "vitest";

import { addTag } from "@/backend/actions/tag";
Expand Down
2 changes: 1 addition & 1 deletion tests/backend/actions/tag/delete.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as cp from "node:child_process";
import * as fs from "node:fs";

import simpleGit from "simple-git";
import { simpleGit } from "simple-git";
import { afterAll, beforeAll, describe, expect, it } from "vitest";

import { deleteTag } from "@/backend/actions/tag";
Expand Down
2 changes: 1 addition & 1 deletion tests/backend/actions/tag/push.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import * as fs from "node:fs";
import * as os from "node:os";
import * as path from "node:path";

import simpleGit from "simple-git";
import { simpleGit } from "simple-git";
import { afterAll, beforeAll, describe, expect, it } from "vitest";

import { pushTag } from "@/backend/actions/tag";
Expand Down
2 changes: 1 addition & 1 deletion tests/backend/queries/commitDetails/get.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as cp from "node:child_process";
import * as fs from "node:fs";
import * as path from "node:path";

import simpleGit from "simple-git";
import { simpleGit } from "simple-git";
import { afterAll, beforeAll, describe, expect, it } from "vitest";

import { commitDetails } from "@/backend/queries/commitDetails";
Expand Down
2 changes: 1 addition & 1 deletion tests/backend/queries/loadBranches/list.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as cp from "node:child_process";
import * as fs from "node:fs";
import * as os from "node:os";

import simpleGit from "simple-git";
import { simpleGit } from "simple-git";
import { afterAll, beforeAll, describe, expect, it } from "vitest";

import { loadBranches } from "@/backend/queries/loadBranches";
Expand Down
2 changes: 1 addition & 1 deletion tests/backend/queries/loadCommits/list.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as fs from "node:fs";
import * as path from "node:path";

import simpleGit from "simple-git";
import { simpleGit } from "simple-git";
import { afterAll, beforeAll, describe, expect, it } from "vitest";

import { loadCommits } from "@/backend/queries/loadCommits";
Expand Down
2 changes: 1 addition & 1 deletion tests/backend/utils/repoSearch.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ describe("searchDirectoryForRepos", () => {

it("finds nested repos when depth allows", async () => {
const result = await searchDirectoryForRepos(tmpDir, 2, "git", []);
expect(result.sort()).toEqual([repoA, repoB].sort());
expect(result.toSorted()).toEqual([repoA, repoB].toSorted());
});

it("does not return .git subdirectory as a repo", async () => {
Expand Down
2 changes: 1 addition & 1 deletion tests/extension/extension.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ suite("GitGraphPanel", () => {
await vscode.commands.executeCommand("neo-git-graph.view");
const deadline = Date.now() + 2000;
while (!isPanelOpen() && Date.now() < deadline) {
await new Promise((r) => setTimeout(r, 50));
await new Promise((r) => setTimeout(r, 50)); // eslint-disable-line no-await-in-loop
}
}

Expand Down
1 change: 0 additions & 1 deletion tests/extension/workspaceWatcher.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ function makeStubs(initialFolders: string[] = []) {
const config = { maxDepthOfRepoSearch: () => 2 };

// Capture watcher handles and folder-change handler so tests can fire events
type StubUri = { fsPath: string };
type WatcherHandle = {
pattern: string;
fireCreate: (uri: StubUri) => void;
Expand Down
2 changes: 1 addition & 1 deletion tests/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
},
"module": "commonjs",
"target": "es6",
"lib": ["es2020", "dom"],
"lib": ["es2023", "dom"],
"strict": true,
"noImplicitAny": true,
"skipLibCheck": true
Expand Down
Loading