diff --git a/packages/analysis-engine/src/csm.ts b/packages/analysis-engine/src/csm.ts index f9e369b7..7ee25cb9 100644 --- a/packages/analysis-engine/src/csm.ts +++ b/packages/analysis-engine/src/csm.ts @@ -23,6 +23,7 @@ const buildCSMNode = (baseCommitNode: CommitNode, commitDict: CommitDict, stemDi const squashStemId = squashStartNode.stemId!; const squashStem = stemDict.get(squashStemId); if (!squashStem) { + // eslint-disable-next-line no-continue continue; } diff --git a/packages/analysis-engine/src/index.ts b/packages/analysis-engine/src/index.ts index 612589ca..034fc70b 100644 --- a/packages/analysis-engine/src/index.ts +++ b/packages/analysis-engine/src/index.ts @@ -53,19 +53,22 @@ export class AnalysisEngine { const commitRaws = getCommitRaws(this.gitLog); if (this.isDebugMode) console.log("commitRaws: ", commitRaws); - + const commitDict = buildCommitDict(commitRaws); if (this.isDebugMode) console.log("commitDict: ", commitDict); - const pullRequests = await this.octokit.getPullRequests().catch((err) => { - console.error(err); - isPRSuccess = false; - return []; - }).then((pullRequests) => { - console.log("success, pr = ", pullRequests); - return pullRequests; - }); - if (this.isDebugMode) console.log("pullRequests: ", pullRequests, ); + const pullRequests = await this.octokit + .getPullRequests() + .catch((err) => { + console.error(err); + isPRSuccess = false; + return []; + }) + .then((result) => { + console.log("success, pr = ", result); + return result; + }); + if (this.isDebugMode) console.log("pullRequests: ", pullRequests); const stemDict = buildStemDict(commitDict, this.baseBranchName); if (this.isDebugMode) console.log("stemDict: ", stemDict); @@ -74,7 +77,7 @@ export class AnalysisEngine { return { isPRSuccess, - csmDict + csmDict, }; }; diff --git a/packages/analysis-engine/src/parser.spec.ts b/packages/analysis-engine/src/parser.spec.ts index 50feb085..7308624b 100644 --- a/packages/analysis-engine/src/parser.spec.ts +++ b/packages/analysis-engine/src/parser.spec.ts @@ -1,5 +1,5 @@ import { getCommitMessageType } from "./commit.util"; -import getCommitRaws from "./parser"; +import getCommitRaws from "./parser"; import type { CommitRaw, DifferenceStatistic } from "./types"; describe("commit message type", () => { @@ -34,85 +34,79 @@ describe("commit message type", () => { }); }); -describe('getCommitRaws', () => { +describe("getCommitRaws", () => { const testCommitLines = [ "commit a b (HEAD)", "commit a b (HEAD -> main, origin/main, origin/HEAD)", "commit a b (HEAD, tag: v1.0.0)", "commit a b (HEAD -> main, origin/main, origin/HEAD, tag: v2.0.0)", - "commit a b (HEAD, tag: v2.0.0, tag: v1.4)" + "commit a b (HEAD, tag: v2.0.0, tag: v1.4)", ]; const expectedBranches = [ - ['HEAD'], - ['HEAD', 'main', 'origin/main', 'origin/HEAD'], - ['HEAD'], - ['HEAD', 'main', 'origin/main', 'origin/HEAD'], - ['HEAD'] + ["HEAD"], + ["HEAD", "main", "origin/main", "origin/HEAD"], + ["HEAD"], + ["HEAD", "main", "origin/main", "origin/HEAD"], + ["HEAD"], ]; - const expectedTags = [ - [], - [], - ['v1.0.0'], - ['v2.0.0'], - ['v2.0.0', 'v1.4'] - ]; + const expectedTags = [[], [], ["v1.0.0"], ["v2.0.0"], ["v2.0.0", "v1.4"]]; const testCommitFileChanges = [ "10\t0\ta.ts\n1\t0\tREADME.md", "3\t3\ta.ts", "4\t0\ta.ts", - "0\t6\ta.ts\n2\t0\tb.ts\n3\t3\tc.ts" + "0\t6\ta.ts\n2\t0\tb.ts\n3\t3\tc.ts", ]; - const expectedFileChanged:DifferenceStatistic[] = [ + const expectedFileChanged: DifferenceStatistic[] = [ { totalInsertionCount: 11, totalDeletionCount: 0, fileDictionary: { - 'a.ts': { insertionCount: 10, deletionCount: 0 }, - 'README.md': { insertionCount: 1, deletionCount: 0 }, - } + "a.ts": { insertionCount: 10, deletionCount: 0 }, + "README.md": { insertionCount: 1, deletionCount: 0 }, + }, }, { totalInsertionCount: 3, totalDeletionCount: 3, - fileDictionary: { 'a.ts': { insertionCount: 3, deletionCount: 3 } } + fileDictionary: { "a.ts": { insertionCount: 3, deletionCount: 3 } }, }, { totalInsertionCount: 4, totalDeletionCount: 0, - fileDictionary: { 'a.ts': { insertionCount: 4, deletionCount: 0 } } + fileDictionary: { "a.ts": { insertionCount: 4, deletionCount: 0 } }, }, { totalInsertionCount: 5, totalDeletionCount: 9, fileDictionary: { - 'a.ts': { insertionCount: 0, deletionCount: 6 }, - 'b.ts': { insertionCount: 2, deletionCount: 0 }, - 'c.ts': { insertionCount: 3, deletionCount: 3 }, - } - } + "a.ts": { insertionCount: 0, deletionCount: 6 }, + "b.ts": { insertionCount: 2, deletionCount: 0 }, + "c.ts": { insertionCount: 3, deletionCount: 3 }, + }, + }, ]; - const commonExpectatedResult: CommitRaw={ + const commonExpectatedResult: CommitRaw = { sequence: 0, - id: 'a', - parents: ['b'], - branches: ['HEAD'], + id: "a", + parents: ["b"], + branches: ["HEAD"], tags: [], - author: { name: 'John Park', email: 'mail@gmail.com' }, - authorDate: new Date('Sun Sep 4 20:17:59 2022 +0900'), - committer: { name: 'John Park', email: 'mail@gmail.com' }, - committerDate: new Date('Sun Sep 4 20:17:59 2022 +0900'), - message: 'commit message', + author: { name: "John Park", email: "mail@gmail.com" }, + authorDate: new Date("Sun Sep 4 20:17:59 2022 +0900"), + committer: { name: "John Park", email: "mail@gmail.com" }, + committerDate: new Date("Sun Sep 4 20:17:59 2022 +0900"), + message: "commit message", differenceStatistic: { totalInsertionCount: 0, totalDeletionCount: 0, fileDictionary: {}, }, - commitMessageType: "" + commitMessageType: "", }; testCommitLines.forEach((mockLog, index) => { @@ -125,8 +119,12 @@ CommitDate: Sun Sep 4 20:17:59 2022 +0900 \n\tcommit message `; const result = getCommitRaws(mock); - const expectedResult = { ...commonExpectatedResult, branches: expectedBranches[index], tags: expectedTags[index] }; - + const expectedResult = { + ...commonExpectatedResult, + branches: expectedBranches[index], + tags: expectedTags[index], + }; + expect(result).toEqual([expectedResult]); }); }); diff --git a/packages/analysis-engine/src/pluginOctokit.ts b/packages/analysis-engine/src/pluginOctokit.ts index 5017a143..8920a916 100644 --- a/packages/analysis-engine/src/pluginOctokit.ts +++ b/packages/analysis-engine/src/pluginOctokit.ts @@ -82,6 +82,7 @@ export class PluginOctokit extends Octokit.plugin(throttling) { const pullNumbers = data.map((item) => item.number); + // eslint-disable-next-line no-underscore-dangle const pullRequests = await Promise.all(pullNumbers.map((pullNumber) => this._getPullRequest(pullNumber))); return pullRequests; diff --git a/packages/analysis-engine/src/stem.ts b/packages/analysis-engine/src/stem.ts index 9eb53722..b82d7959 100644 --- a/packages/analysis-engine/src/stem.ts +++ b/packages/analysis-engine/src/stem.ts @@ -90,11 +90,13 @@ export function buildStemDict(commitDict: CommitDict, baseBranchName: string): S while (!q.isEmpty()) { const tail = q.pop(); + // eslint-disable-next-line no-continue if (!tail) continue; const stemId = getStemId(tail.commit.id, tail.commit.branches, baseBranchName, mainNode, headNode); const nodes = getStemNodes(tail.commit.id, commitDict, q, stemId); + // eslint-disable-next-line no-continue if (nodes.length === 0) continue; const stem: Stem = { nodes }; diff --git a/packages/view/src/components/VerticalClusterList/VerticalClusterList.util.test.ts b/packages/view/src/components/VerticalClusterList/VerticalClusterList.util.test.ts index ecbc4bbf..049f6f4c 100644 --- a/packages/view/src/components/VerticalClusterList/VerticalClusterList.util.test.ts +++ b/packages/view/src/components/VerticalClusterList/VerticalClusterList.util.test.ts @@ -1,15 +1,8 @@ -import { - fakeFirstClusterNode, - fakeSecondClusterNode, - fakePrev, -} from "../../../tests/fakeAsset"; +import { fakeFirstClusterNode, fakeSecondClusterNode, fakePrev } from "../../../tests/fakeAsset"; import { selectedDataUpdater } from "./VerticalClusterList.util"; -const EmptyArrayAddSelectedDataUpdater = selectedDataUpdater( - fakeFirstClusterNode, - 0, -); +const EmptyArrayAddSelectedDataUpdater = selectedDataUpdater(fakeFirstClusterNode, 0); const PrevAddSelectedDataUpdater = selectedDataUpdater(fakeFirstClusterNode, 5); const RemoveSelectedDataUpdater = selectedDataUpdater(fakeSecondClusterNode, 1); diff --git a/packages/vscode/src/extension.ts b/packages/vscode/src/extension.ts index 2fc0c8e6..535d64e2 100644 --- a/packages/vscode/src/extension.ts +++ b/packages/vscode/src/extension.ts @@ -4,7 +4,7 @@ import * as vscode from "vscode"; import { COMMAND_LAUNCH, COMMAND_LOGIN_WITH_GITHUB, COMMAND_RESET_GITHUB_AUTH } from "./commands"; import { Credentials } from "./credentials"; import { GithubTokenUndefinedError, WorkspacePathUndefinedError } from "./errors/ExtensionError"; -import { deleteGithubToken, getGithubToken, setGithubToken, } from "./setting-repository"; +import { deleteGithubToken, getGithubToken, setGithubToken } from "./setting-repository"; import { mapClusterNodesFrom } from "./utils/csm.mapper"; import { findGit, @@ -18,7 +18,7 @@ import { import WebviewLoader from "./webview-loader"; let myStatusBarItem: vscode.StatusBarItem; -const projectName = 'githru'; +const projectName = "githru"; function normalizeFsPath(fsPath: string) { return fsPath.replace(/\\/g, "/"); @@ -27,7 +27,7 @@ function normalizeFsPath(fsPath: string) { export async function activate(context: vscode.ExtensionContext) { const { subscriptions, extensionPath, secrets } = context; const credentials = new Credentials(); - let currentPanel: vscode.WebviewPanel | undefined = undefined; + let currentPanel: vscode.WebviewPanel | undefined; await credentials.initialize(context); @@ -58,16 +58,15 @@ export async function activate(context: vscode.ExtensionContext) { const fetchBranches = async () => await getBranches(gitPath, currentWorkspacePath); const fetchCurrentBranch = async () => { - let branchName; try { - branchName = await getCurrentBranchName(gitPath, currentWorkspacePath) + branchName = await getCurrentBranchName(gitPath, currentWorkspacePath); } catch (error) { - console.error(error); + console.error(error); } if (!branchName) { - const branchList = (await fetchBranches()).branchList; + const { branchList } = await fetchBranches(); branchName = getDefaultBranchName(branchList); } return branchName; diff --git a/packages/vscode/src/setting-repository.ts b/packages/vscode/src/setting-repository.ts index a82726b4..d4f0ef5e 100644 --- a/packages/vscode/src/setting-repository.ts +++ b/packages/vscode/src/setting-repository.ts @@ -14,8 +14,8 @@ export const setGithubToken = async (secrets: vscode.SecretStorage, newGithubTok }; export const deleteGithubToken = async (secrets: vscode.SecretStorage) => { - return await secrets.delete(SETTING_PROPERTY_NAMES.GITHUB_TOKEN); -} + return await secrets.delete(SETTING_PROPERTY_NAMES.GITHUB_TOKEN); +}; export const setPrimaryColor = (color: string) => { const configuration = vscode.workspace.getConfiguration(); @@ -29,7 +29,6 @@ export const getPrimaryColor = (): string => { if (!primaryColor) { configuration.update(SETTING_PROPERTY_NAMES.PRIMARY_COLOR, "#ff8272"); return "#ff8272"; - } else { - return primaryColor; } + return primaryColor; }; diff --git a/packages/vscode/src/test/suite/extension.test.ts b/packages/vscode/src/test/suite/extension.test.ts index 344cc70e..2f671d3c 100644 --- a/packages/vscode/src/test/suite/extension.test.ts +++ b/packages/vscode/src/test/suite/extension.test.ts @@ -1,4 +1,5 @@ import * as assert from "assert"; + // You can import and use all API from the 'vscode' module // as well as import your extension to test it import * as vscode from "vscode"; diff --git a/packages/vscode/src/test/suite/index.ts b/packages/vscode/src/test/suite/index.ts index ed679e5b..0696dfbe 100644 --- a/packages/vscode/src/test/suite/index.ts +++ b/packages/vscode/src/test/suite/index.ts @@ -1,6 +1,7 @@ +import * as path from "path"; + import * as glob from "glob"; import * as Mocha from "mocha"; -import * as path from "path"; export function run(): Promise { // Create the mocha test diff --git a/packages/vscode/src/utils/git.util.ts b/packages/vscode/src/utils/git.util.ts index cd1fc5f9..be8d0bee 100644 --- a/packages/vscode/src/utils/git.util.ts +++ b/packages/vscode/src/utils/git.util.ts @@ -87,14 +87,12 @@ function findGitOnDarwin() { function findGitOnWin32() { return ( - findSystemGitWin32(process.env["ProgramW6432"]) + findSystemGitWin32(process.env.ProgramW6432) .then(undefined, () => findSystemGitWin32(process.env["ProgramFiles(x86)"])) - .then(undefined, () => findSystemGitWin32(process.env["ProgramFiles"])) + .then(undefined, () => findSystemGitWin32(process.env.ProgramFiles)) // eslint-disable-next-line @typescript-eslint/no-non-null-assertion .then(undefined, () => - findSystemGitWin32( - process.env["LocalAppData"] ? path.join(process.env["LocalAppData"]!, "Programs") : undefined - ) + findSystemGitWin32(process.env.LocalAppData ? path.join(process.env.LocalAppData!, "Programs") : undefined) ) .then(undefined, () => findGitWin32InPath()) ); @@ -103,7 +101,7 @@ function findSystemGitWin32(pathBase?: string) { return pathBase ? getGitExecutable(path.join(pathBase, "Git", "cmd", "git.exe")) : Promise.reject(); } async function findGitWin32InPath() { - const dirs = (process.env["PATH"] || "").split(";"); + const dirs = (process.env.PATH || "").split(";"); dirs.unshift(process.cwd()); for (let i = 0; i < dirs.length; i++) { @@ -169,7 +167,7 @@ export async function getGitLog(gitPath: string, currentWorkspacePath: string): resolveSpawnOutput( cp.spawn(gitPath, args, { cwd: currentWorkspacePath, - env: Object.assign({}, process.env), + env: { ...process.env }, }) ).then((values) => { const [status, stdout, stderr] = values; @@ -193,7 +191,7 @@ export async function getGitConfig( resolveSpawnOutput( cp.spawn(gitPath, args, { cwd: currentWorkspacePath, - env: Object.assign({}, process.env), + env: { ...process.env }, }) ).then((values) => { const [status, stdout, stderr] = values; @@ -235,7 +233,7 @@ export async function getBranches( const [status, stdout, stderr] = await resolveSpawnOutput( cp.spawn(path, ["branch", "-a"], { cwd: repo, - env: Object.assign({}, process.env), + env: { ...process.env }, }) ); @@ -269,7 +267,7 @@ export async function getCurrentBranchName(path: string, repo: string): Promise< const [status, stdout, stderr] = await resolveSpawnOutput( cp.spawn(path, ["branch", "--show-current"], { cwd: repo, - env: Object.assign({}, process.env), + env: { ...process.env }, }) ); diff --git a/packages/vscode/src/webview-loader.ts b/packages/vscode/src/webview-loader.ts index 3715fae3..7f282951 100644 --- a/packages/vscode/src/webview-loader.ts +++ b/packages/vscode/src/webview-loader.ts @@ -1,4 +1,5 @@ import * as path from "path"; + import * as vscode from "vscode"; import { getPrimaryColor, setPrimaryColor } from "./setting-repository"; @@ -39,8 +40,8 @@ export default class WebviewLoader implements vscode.Disposable { context.workspaceState.update(`${ANALYZE_DATA_KEY}_${baseBranchName}`, analyzedData); const resMessage = { - command, - payload: analyzedData, + command, + payload: analyzedData, }; await this.respondToMessage(resMessage);