From 84f62800984f0b85fe7514ecd1e92e9f0db87962 Mon Sep 17 00:00:00 2001 From: tjomson Date: Sat, 18 Nov 2023 19:41:11 +0100 Subject: [PATCH 1/6] Housekeeping: Apply prettier and eslint (#692) * Apply prettier and eslint * Remove trailing commas --- package.json | 5 +- scripts/benchmark.mjs | 4 +- scripts/publish-experimental.js | 2 - src/analyzer/analyze.server.ts | 36 ++++----- src/analyzer/analyze.test.ts | 6 +- src/analyzer/args.server.ts | 10 +-- src/analyzer/coauthors.server.ts | 2 +- src/analyzer/git-caller.server.ts | 27 ++++--- src/analyzer/hydrate.server.ts | 89 ++++++++++++---------- src/analyzer/log.server.ts | 8 +- src/analyzer/model.ts | 2 +- src/analyzer/postprocessing.server.ts | 4 +- src/analyzer/util.server.ts | 12 +-- src/authorUnionUtil.server.ts | 4 +- src/authorUnionUtil.test.ts | 10 +-- src/cli.ts | 12 +-- src/components/Chart.tsx | 34 ++++----- src/components/CommitHistory.tsx | 3 +- src/components/DetailsCard.tsx | 21 +++-- src/components/EnumSelect.tsx | 5 +- src/components/GlobalInfo.tsx | 2 +- src/components/LoadingIndicator.tsx | 4 +- src/components/MenuTab.tsx | 73 +++++++++--------- src/components/Options.tsx | 30 ++++---- src/components/Providers.tsx | 37 ++++----- src/components/SearchCard.tsx | 4 +- src/components/Tooltip.tsx | 4 +- src/components/UnionAuthorsModal.tsx | 14 ++-- src/components/accordion/Accordion.tsx | 47 +++++------- src/components/accordion/AccordionItem.tsx | 60 ++++++++------- src/components/legend/GradiantLegend.tsx | 2 +- src/components/legend/Legend.tsx | 4 +- src/components/legend/PointLegend.tsx | 8 +- src/components/util.tsx | 8 +- src/contexts/CommitTabContext.ts | 2 +- src/contexts/OptionsContext.ts | 8 +- src/entry.server.tsx | 4 +- src/hooks.ts | 4 +- src/metrics/chartDepth.ts | 23 ++---- src/metrics/lastChanged.ts | 2 +- src/metrics/metricUtils.ts | 2 +- src/metrics/metrics.ts | 32 ++++---- src/metrics/sizeMetric.ts | 2 +- src/root.tsx | 14 ++-- src/routes/$repo.$.tsx | 30 ++++---- src/routes/_index.tsx | 7 +- src/routes/commits.tsx | 2 +- src/util.ts | 6 +- 48 files changed, 367 insertions(+), 364 deletions(-) diff --git a/package.json b/package.json index 437b13fc5..f258e8245 100644 --- a/package.json +++ b/package.json @@ -28,7 +28,7 @@ "pub-pre": "npm version prerelease && npm publish --tag next", "pub-exp": "node ./scripts/publish-experimental.js", "prepublishOnly": "npm run clean && npm run build", - "format": "eslint --cache --fix {src,scripts}/**/*.{ts,tsx,js,mjs} && prettier --loglevel warn --write {src,scripts}/**/*.{ts,tsx,js,mjs}", + "format": "eslint --cache --fix {src,scripts}/**/*.{ts,tsx,js,mjs} && prettier --log-level warn --write {src,scripts}/**/*.{ts,tsx,js,mjs}", "lint": "eslint --cache --fix {src,scripts}/**/*.{ts,tsx,js,mjs}" }, "devDependencies": { @@ -118,6 +118,7 @@ "prettier": { "semi": false, "printWidth": 120, + "trailingComma": "none", "plugins": [ "prettier-plugin-tailwindcss" ] @@ -139,4 +140,4 @@ "url": "https://github.com/git-truck/git-truck/issues" }, "homepage": "https://github.com/git-truck/git-truck#readme" -} +} \ No newline at end of file diff --git a/scripts/benchmark.mjs b/scripts/benchmark.mjs index 867925a73..ef9ffe220 100644 --- a/scripts/benchmark.mjs +++ b/scripts/benchmark.mjs @@ -42,7 +42,7 @@ for (let i = 0; i < versionsToCompare.length; i++) { const start = performance.now() // Install module with specific version const output = execSync(`npx git-truck@${version} -y -h`, { - stdio: "pipe", + stdio: "pipe" }) invariant( @@ -81,7 +81,7 @@ for (let i = 0; i < versionsToCompare.length; i++) { times.push({ version, "npx average time (in ms)": npxAverage, - "global install average time (in ms)": globalInstallAverage, + "global install average time (in ms)": globalInstallAverage }) } diff --git a/scripts/publish-experimental.js b/scripts/publish-experimental.js index fd9ec46b8..2c07c02a4 100644 --- a/scripts/publish-experimental.js +++ b/scripts/publish-experimental.js @@ -4,7 +4,6 @@ const { execSync } = require("child_process") const hasUncommittedChanges = execSync("git status --porcelain", { stdio: "pipe" })?.toString().trim().length > 0 async function main() { - if (hasUncommittedChanges) { console.error("You have uncommitted changes. Please commit or stash them before publishing.") process.exit(1) @@ -18,7 +17,6 @@ async function main() { const commitHash = execSync("git rev-parse --short HEAD", { stdio: "pipe" }).toString().trim() const versionTag = `0.0.0-${commitHash}` - console.log(`Tagging version ${versionTag}...`) execSync(`npm version ${versionTag} --no-git-tag-version`, { stdio: "pipe" }) console.log(`Tagged version ${versionTag}`) diff --git a/src/analyzer/analyze.server.ts b/src/analyzer/analyze.server.ts index 20ff86259..bc901ee61 100644 --- a/src/analyzer/analyze.server.ts +++ b/src/analyzer/analyze.server.ts @@ -6,11 +6,11 @@ import type { GitTreeObject, AnalyzerData, TruckUserConfig, - TruckConfig, + TruckConfig } from "./model" import { AnalyzerDataInterfaceVersion } from "./model" import { log, setLogLevel } from "./log.server" -import { describeAsyncJob, formatMs, writeRepoToFile, getDirName } from "./util.server" +import { describeAsyncJob, writeRepoToFile, getDirName } from "./util.server" import { GitCaller } from "./git-caller.server" import { emptyGitCommitHash } from "./constants" import { resolve, isAbsolute, sep } from "path" @@ -41,13 +41,13 @@ export async function analyzeCommitLight(hash: string): Promise (blob.blameAuthors = await GitCaller.getInstance().parseBlame(blob.path)))()) @@ -212,7 +212,7 @@ export async function analyze(args: TruckConfig): Promise { job: () => git.findBranchHead(branch), beforeMsg: "Finding branch head", afterMsg: "Found branch head", - errorMsg: "Error finding branch head", + errorMsg: "Error finding branch head" }) const repoName = getDirName(repoDir) @@ -228,13 +228,13 @@ export async function analyze(args: TruckConfig): Promise { repo: repoName, branch: branchName, branchHead: branchHead, - invalidateCache: args.invalidateCache, + invalidateCache: args.invalidateCache }) if (cachedData) { data = { ...cachedData, - hiddenFiles, + hiddenFiles } } else { log.info( @@ -258,7 +258,7 @@ export async function analyze(args: TruckConfig): Promise { job: () => analyzeCommit(repoName, branchHead), beforeMsg: "Analyzing commit tree", afterMsg: "Commit tree analyzed", - errorMsg: "Error analyzing commit tree", + errorMsg: "Error analyzing commit tree" }) if (repoTreeError) throw repoTreeError @@ -267,7 +267,7 @@ export async function analyze(args: TruckConfig): Promise { job: () => hydrateData(repoTree), beforeMsg: "Hydrating commit tree", afterMsg: "Commit tree hydrated", - errorMsg: "Error hydrating commit tree", + errorMsg: "Error hydrating commit tree" }) if (hydratedRepoTreeError) throw hydratedRepoTreeError @@ -303,11 +303,11 @@ export async function analyze(args: TruckConfig): Promise { job: () => writeRepoToFile(outPath, { ...data, - cached: true, + cached: true } as AnalyzerData), beforeMsg: "Writing data to file", afterMsg: `Wrote data to ${resolve(outPath)}`, - errorMsg: `Error writing data to file ${outPath}`, + errorMsg: `Error writing data to file ${outPath}` }) } } @@ -325,7 +325,7 @@ export async function analyze(args: TruckConfig): Promise { beforeMsg: "", afterMsg: `Ready in`, errorMsg: "", - ms: stop - start, + ms: stop - start }) return data diff --git a/src/analyzer/analyze.test.ts b/src/analyzer/analyze.test.ts index eca44f3ee..37a34d459 100644 --- a/src/analyzer/analyze.test.ts +++ b/src/analyzer/analyze.test.ts @@ -17,12 +17,12 @@ describe("getCoAuthors", () => { const expected = [ { name: "Bob Bobby", - email: "bob@example.com", + email: "bob@example.com" }, { name: "Alice Lmao", - email: "alice@example.com", - }, + email: "alice@example.com" + } ] const actual = getCoAuthors(sampleDescription) expect(actual).toStrictEqual(expected) diff --git a/src/analyzer/args.server.ts b/src/analyzer/args.server.ts index 982637681..6c7802c34 100644 --- a/src/analyzer/args.server.ts +++ b/src/analyzer/args.server.ts @@ -9,8 +9,8 @@ import { log } from "./log.server" export function parseArgs(rawArgs: string[] = process.argv.slice(2)) { return yargsParser(rawArgs, { configuration: { - "duplicate-arguments-array": false, - }, + "duplicate-arguments-array": false + } }) } @@ -21,7 +21,7 @@ export function getArgsWithDefaults(): TruckConfig { hiddenFiles: [] as string[], unionedAuthors: [] as string[][], invalidateCache: false, - ...args, + ...args } return tempArgs @@ -44,8 +44,8 @@ export async function getTruckConfigWithArgs(repo: string): Promise<[TruckConfig return [ { ...args, - ...config, + ...config }, - config, + config ] } diff --git a/src/analyzer/coauthors.server.ts b/src/analyzer/coauthors.server.ts index 6bf64fe9b..043a25360 100644 --- a/src/analyzer/coauthors.server.ts +++ b/src/analyzer/coauthors.server.ts @@ -9,7 +9,7 @@ export function getCoAuthors(description: string) { while (next.value !== undefined) { coauthors.push({ name: next.value.groups["name"].trimEnd(), - email: next.value.groups["email"], + email: next.value.groups["email"] }) next = coauthormatches.next() } diff --git a/src/analyzer/git-caller.server.ts b/src/analyzer/git-caller.server.ts index 5e13fbf6a..837871530 100644 --- a/src/analyzer/git-caller.server.ts +++ b/src/analyzer/git-caller.server.ts @@ -11,7 +11,7 @@ export enum ANALYZER_CACHE_MISS_REASONS { OTHER_REPO = "The cache was not created for this repo", NOT_CACHED = "No cache was found", BRANCH_HEAD_CHANGED = "Branch head changed", - DATA_VERSION_MISMATCH = "Outdated cache", + DATA_VERSION_MISMATCH = "Outdated cache" } export type RawGitObjectType = "blob" | "tree" | "commit" | "tag" @@ -94,8 +94,8 @@ export class GitCaller { async gitShow(commits: string[]) { if (!this.branch) throw Error("branch not set") const args = [ - "show", - "--no-patch", + "show", + "--no-patch", '--format="author <|%an|> date <|%at|> message <|%s|> body <|%b|> hash <|%H|>"', ...commits ] @@ -141,12 +141,12 @@ export class GitCaller { repo: getDirName(repoPath), branch: headName, branchHead: head, - invalidateCache, + invalidateCache }) return { headName, head, - isAnalyzed: result !== null, + isAnalyzed: result !== null } }) ) @@ -164,7 +164,7 @@ export class GitCaller { reasons: [], currentHead: await GitCaller._getRepositoryHead(repoPath), refs, - analyzedHeads, + analyzedHeads } try { @@ -175,7 +175,7 @@ export class GitCaller { repo: repoDir, branch, branchHead, - invalidateCache, + invalidateCache }) repo.data = data repo.reasons = reasons @@ -195,7 +195,7 @@ export class GitCaller { job: () => GitCaller.isGitRepo(argPath), beforeMsg: "Checking if path is a git repo...", afterMsg: "Done checking if path is a git repo", - errorMsg: "Error checking if path is a git repo", + errorMsg: "Error checking if path is a git repo" }) const baseDir = resolve(pathIsRepo ? getBaseDirFromPath(argPath) : argPath) @@ -214,7 +214,7 @@ export class GitCaller { ), beforeMsg: "Scanning for repositories...", afterMsg: "Done scanning for repositories", - errorMsg: "Error scanning for repositories", + errorMsg: "Error scanning for repositories" })) as [PromiseSettledResult[], null] const onlyRepos = ( @@ -233,7 +233,7 @@ export class GitCaller { static parseRefs(refsAsMultilineString: string): GitRefs { const gitRefs: GitRefs = { Branches: {}, - Tags: {}, + Tags: {} } const regex = /^(?.*) refs\/(?.*?)\/(?.*)$/gm @@ -278,10 +278,9 @@ export class GitCaller { this.branch, "--numstat", // "--cc", // include file changes for merge commits - '--format="author <|%an|> date <|%at|> message <|%s|> body <|%b|> hash <|%H|>"', + '--format="author <|%an|> date <|%at|> message <|%s|> body <|%b|> hash <|%H|>"' ] - const result = (await runProcess(this.repo, "git", args)) as string return result.trim() } @@ -290,7 +289,7 @@ export class GitCaller { repo, branch, branchHead, - invalidateCache = false, + invalidateCache = false }: { repo: string branch: string @@ -320,7 +319,7 @@ export class GitCaller { const cacheConditions = { branchHeadMatches, dataVersionMatches, - repoMatches, + repoMatches } // Only return cached data if every criteria is met diff --git a/src/analyzer/hydrate.server.ts b/src/analyzer/hydrate.server.ts index ff725ad60..40eee3f8f 100644 --- a/src/analyzer/hydrate.server.ts +++ b/src/analyzer/hydrate.server.ts @@ -6,7 +6,7 @@ import type { GitTreeObject, HydratedGitBlobObject, HydratedGitCommitObject, - HydratedGitTreeObject, + HydratedGitTreeObject } from "./model" import { analyzeRenamedFile } from "./util.server" import { GitCaller } from "./git-caller.server" @@ -15,10 +15,14 @@ import { log } from "./log.server" import { gitLogRegex, contribRegex } from "./constants" import { cpus } from "os" -let renamedFiles: Map +let renamedFiles: Map let authors: Set -export function gatherCommitsFromGitLog(gitLogResult: string, commits: Map, handleAuthors: boolean) { +export function gatherCommitsFromGitLog( + gitLogResult: string, + commits: Map, + handleAuthors: boolean +) { const matches = gitLogResult.matchAll(gitLogRegex) for (const match of matches) { const groups = match.groups ?? {} @@ -30,7 +34,7 @@ export function gatherCommitsFromGitLog(gitLogResult: string, commits: Map") if (fileHasMoved) { filePath = analyzeRenamedFile(filePath, renamedFiles, time) } - - const contribs = isBinary ? 1 : Number(contribMatch.groups?.insertions ?? "0") + Number(contribMatch.groups?.deletions ?? "0") - fileChanges.push({isBinary, contribs, path: filePath}) + + const contribs = isBinary + ? 1 + : Number(contribMatch.groups?.insertions ?? "0") + Number(contribMatch.groups?.deletions ?? "0") + fileChanges.push({ isBinary, contribs, path: filePath }) } } commits.set(hash, { author, time, body, message, hash, coauthors, fileChanges }) @@ -61,16 +66,16 @@ export function gatherCommitsFromGitLog(gitLogResult: string, commits: Map) { - const gitLogResult = await GitCaller.getInstance().gitLog(start, end - start) - gatherCommitsFromGitLog(gitLogResult, commits, true) + const gitLogResult = await GitCaller.getInstance().gitLog(start, end - start) + gatherCommitsFromGitLog(gitLogResult, commits, true) } async function updateCreditOnBlob(blob: HydratedGitBlobObject, commit: GitLogEntry, change: FileChange) { blob.noCommits = (blob.noCommits ?? 0) + 1 if (blob.commits) { - blob.commits.push({hash: commit.hash, time: commit.time}) + blob.commits.push({ hash: commit.hash, time: commit.time }) } else { - blob.commits = [{hash: commit.hash, time: commit.time}] + blob.commits = [{ hash: commit.hash, time: commit.time }] } if (!blob.lastChangeEpoch || blob.lastChangeEpoch < commit.time) blob.lastChangeEpoch = commit.time @@ -91,46 +96,47 @@ async function updateCreditOnBlob(blob: HydratedGitBlobObject, commit: GitLogEnt } } -export async function hydrateData( - commit: GitCommitObject -): Promise<[HydratedGitCommitObject, string[]]> { +export async function hydrateData(commit: GitCommitObject): Promise<[HydratedGitCommitObject, string[]]> { const data = commit as HydratedGitCommitObject const fileMap = convertFileTreeToMap(data.tree) initially_mut(data) const commitCount = await GitCaller.getInstance().getCommitCount() - const threadCount = cpus().length > 4 ? 4 : 2; + const threadCount = cpus().length > 4 ? 4 : 2 const commitBundleSize = 100000 - if (commitCount > 500000) log.warn("This repo has a lot of commits, so nodejs might run out of memory. Consider setting the environment variable NODE_OPTIONS to --max-old-space-size=4096 and rerun Git Truck") + if (commitCount > 500000) + log.warn( + "This repo has a lot of commits, so nodejs might run out of memory. Consider setting the environment variable NODE_OPTIONS to --max-old-space-size=4096 and rerun Git Truck" + ) // Sync threads every commitBundleSize commits to reset commits map, to reduce peak memory usage for (let index = 0; index < commitCount; index += commitBundleSize) { const runCountCommit = Math.min(commitBundleSize, commitCount - index) - const sectionSize = Math.ceil(runCountCommit / threadCount); - + const sectionSize = Math.ceil(runCountCommit / threadCount) + const commits = new Map() - + const promises = Array.from({ length: threadCount }, (_, i) => { - const sectionStart = index + i * sectionSize; - let sectionEnd = sectionStart + sectionSize; + const sectionStart = index + i * sectionSize + let sectionEnd = sectionStart + sectionSize if (sectionEnd > commitCount) sectionEnd = runCountCommit log.info("start thread " + sectionStart + "-" + sectionEnd) - return gatherCommitsInRange(sectionStart, sectionEnd, commits); - }); - + return gatherCommitsInRange(sectionStart, sectionEnd, commits) + }) + await Promise.all(promises) - + await hydrateBlobs(fileMap, commits) log.info("threads synced") } sortCommits(fileMap) - + return [data, Array.from(authors)] } function sortCommits(fileMap: Map) { - fileMap.forEach((blob,_) => { + fileMap.forEach((blob, _) => { const cast = blob as HydratedGitBlobObject cast.commits?.sort((a, b) => { return b.time - a.time @@ -139,9 +145,9 @@ function sortCommits(fileMap: Map) { } async function hydrateBlobs(files: Map, commits: Map) { - for (const [_,commit] of commits) { + for (const [, commit] of commits) { for (const change of commit.fileChanges) { - let recentChange = {path: change.path, timestamp: commit.time} + let recentChange = { path: change.path, timestamp: commit.time } // eslint-disable-next-line no-constant-condition while (true) { const rename = getRecentRename(recentChange.timestamp, recentChange.path) @@ -163,7 +169,7 @@ function convertFileTreeToMap(tree: GitTreeObject) { function aux(recTree: GitTreeObject) { for (const child of recTree.children) { if (child.type === "blob") { - map.set(child.path.substring(child.path.indexOf("/")+1), child) + map.set(child.path.substring(child.path.indexOf("/") + 1), child) } else { aux(child) } @@ -175,30 +181,29 @@ function convertFileTreeToMap(tree: GitTreeObject) { } function getRecentRename(targetTimestamp: number, path: string) { - const renames = renamedFiles.get(path); - if (!renames) return undefined; + const renames = renamedFiles.get(path) + if (!renames) return undefined - let minTimestamp = Infinity; - let resultRename = undefined; + let minTimestamp = Infinity + let resultRename = undefined for (const rename of renames) { - const currentTimestamp = rename.timestamp; + const currentTimestamp = rename.timestamp if (currentTimestamp > targetTimestamp && currentTimestamp < minTimestamp) { - minTimestamp = currentTimestamp; - resultRename = rename; + minTimestamp = currentTimestamp + resultRename = rename } } - if (minTimestamp === Infinity) return undefined; - return resultRename; + if (minTimestamp === Infinity) return undefined + return resultRename } - function initially_mut(data: HydratedGitCommitObject) { data.oldestLatestChangeEpoch = Number.MAX_VALUE data.newestLatestChangeEpoch = Number.MIN_VALUE authors = new Set() - renamedFiles = new Map() + renamedFiles = new Map() addAuthorsField_mut(data.tree) } diff --git a/src/analyzer/log.server.ts b/src/analyzer/log.server.ts index 659112479..e0af0f3e7 100644 --- a/src/analyzer/log.server.ts +++ b/src/analyzer/log.server.ts @@ -5,14 +5,14 @@ export enum LOG_LEVEL { ERROR, WARN, INFO, - DEBUG, + DEBUG } export enum LOG_LEVEL_LABEL { SILENT = "", ERROR = "ERR", WARN = "WRN", INFO = "NFO", - DEBUG = "DBG", + DEBUG = "DBG" } const stringToLevelMap: Record = { @@ -20,7 +20,7 @@ const stringToLevelMap: Record = { ERROR: LOG_LEVEL.ERROR, WARN: LOG_LEVEL.WARN, INFO: LOG_LEVEL.INFO, - DEBUG: LOG_LEVEL.DEBUG, + DEBUG: LOG_LEVEL.DEBUG } const { ERROR, WARN, INFO, DEBUG } = LOG_LEVEL_LABEL @@ -117,5 +117,5 @@ export const log = { warn, info, debug, - raw, + raw } diff --git a/src/analyzer/model.ts b/src/analyzer/model.ts index 347d4f1d9..72edf3243 100644 --- a/src/analyzer/model.ts +++ b/src/analyzer/model.ts @@ -79,7 +79,7 @@ export interface HydratedGitBlobObject extends GitBlobObject { unionedAuthors?: Record> dominantAuthor?: Record isSearchResult?: boolean - commits: {hash: string, time: number}[] + commits: { hash: string; time: number }[] } export interface GitTreeObject extends AbstractGitObject { diff --git a/src/analyzer/postprocessing.server.ts b/src/analyzer/postprocessing.server.ts index 679597b95..d780b5d4d 100644 --- a/src/analyzer/postprocessing.server.ts +++ b/src/analyzer/postprocessing.server.ts @@ -21,7 +21,7 @@ export function applyMetrics(data: AnalyzerData, currentTree: HydratedGitTreeObj data.commit.oldestLatestChangeEpoch = current.lastChangeEpoch } return current - }), + }) } } @@ -35,7 +35,7 @@ export function applyIgnore(tree: HydratedGitTreeObject, truckIgnore: Ignore): H .map((child) => { if (child.type === "tree") return applyIgnore(child, truckIgnore) return child - }), + }) } } diff --git a/src/analyzer/util.server.ts b/src/analyzer/util.server.ts index 6095098c0..c491d0f6c 100644 --- a/src/analyzer/util.server.ts +++ b/src/analyzer/util.server.ts @@ -19,7 +19,7 @@ export function runProcess(dir: string, command: string, args: string[]) { return new Promise((resolve, reject) => { try { const prcs = spawn(command, args, { - cwd: resolvePath(dir), + cwd: resolvePath(dir) }) const chunks: Uint8Array[] = [] const errorHandler = (buf: Error): void => reject(buf.toString().trim()) @@ -38,7 +38,7 @@ export function runProcess(dir: string, command: string, args: string[]) { export function analyzeRenamedFile( file: string, renamedFiles: Map, - timestamp: number, + timestamp: number ) { const movedFileRegex = /(?:.*{(?.*)\s=>\s(?.*)}.*)|(?:^(?.*) => (?.*))$/gm const replaceRegex = /{.*}/gm @@ -116,7 +116,7 @@ export function createTruckSpinner() { return getLogLevel() === null ? createSpinner("", { interval: 1000 / 20, - frames: generateTruckFrames(20), + frames: generateTruckFrames(20) }) : null } @@ -128,7 +128,7 @@ export async function describeAsyncJob({ beforeMsg = "", afterMsg = "", errorMsg = "", - ms = null, + ms = null }: { job: () => Promise beforeMsg: string @@ -147,7 +147,7 @@ export async function describeAsyncJob({ if (spinner) { spinner.update({ text, - frames: generateTruckFrames(text.length), + frames: generateTruckFrames(text.length) }) spinner.start() } else log.info(text) @@ -192,6 +192,6 @@ export async function getGitTruckInfo() { const [latestVersion] = await promiseHelper(getLatestVersion(pkg.name)) return { version: pkg.version, - latestVersion: latestVersion, + latestVersion: latestVersion } } diff --git a/src/authorUnionUtil.server.ts b/src/authorUnionUtil.server.ts index f069230e7..fb301d14d 100644 --- a/src/authorUnionUtil.server.ts +++ b/src/authorUnionUtil.server.ts @@ -21,7 +21,7 @@ export function unionAuthors(authors: Record, authorAliasMap: Re const credits = (newAuthorObject[author] ?? 0) + contributionCount return { ...newAuthorObject, - [author]: credits, + [author]: credits } } @@ -52,7 +52,7 @@ function addAuthorUnionRec(tree: HydratedGitTreeObject, authorUnions: Record HydratedGitBlobObject = () => ({ @@ -14,7 +14,7 @@ const makeHydratedGitBlobObject: () => HydratedGitBlobObject = () => ({ authors: { author1Dupe: 25, author2: 50, - author1: 25, + author1: 25 }, blameAuthors: {}, noCommits: 0, @@ -23,7 +23,7 @@ const makeHydratedGitBlobObject: () => HydratedGitBlobObject = () => ({ path: "", content: undefined, hash: "", - commits: [], + commits: [] }) function sumContributions(authors: HydratedGitBlobObject["authors"]) { @@ -52,13 +52,13 @@ describe("unionAuthors", () => { tjomson: 19, emiljapelt: 40, joglr: 40, - "Jonas Røssum": 125, + "Jonas Røssum": 125 }, blameAuthors: {}, sizeInBytes: 249, noCommits: 30, lastChangeEpoch: 1646818775, - commits: [], + commits: [] } const sumBefore = sumContributions(parseTS.authors) const authors = unionAuthors(parseTS.authors, makeDupeMap(authorUnionsTwo)) diff --git a/src/cli.ts b/src/cli.ts index 0b7747b63..f67fd543a 100644 --- a/src/cli.ts +++ b/src/cli.ts @@ -63,7 +63,7 @@ for usage instructions.`) const getPortLib = await import("get-port") const getPort = getPortLib.default const port = await getPort({ - port: [...getPortLib.portNumbers(3000, 4000)], + port: [...getPortLib.portNumbers(3000, 4000)] }) // Serve application build @@ -84,7 +84,7 @@ for usage instructions.`) }, beforeMsg: "Checking for git repo", afterMsg: "Done checking for git repo", - errorMsg: "Failed to check for git repo", + errorMsg: "Failed to check for git repo" }) if (extensionError) { @@ -100,7 +100,7 @@ for usage instructions.`) job: () => open(openURL), beforeMsg: "Opening Git Truck in your browser", afterMsg: "Opened Git Truck in your browser", - errorMsg: `Failed to open Git Truck in your browser. To continue, open this link manually:\n\n${openURL}\n`, + errorMsg: `Failed to open Git Truck in your browser. To continue, open this link manually:\n\n${openURL}\n` }) } else { console.log(`Application available at ${url}`) @@ -114,7 +114,7 @@ for usage instructions.`) "./build/index.js", process.env.NODE_ENV ?? "production", "/build", - path.join(__dirname, "public", "build"), + path.join(__dirname, "public", "build") ) const server = process.env.HOST ? app.listen(port, process.env.HOST, onListen) : app.listen(port, onListen) @@ -124,7 +124,7 @@ for usage instructions.`) }, beforeMsg: "Starting app", afterMsg: "App started", - errorMsg: "Failed to start app", + errorMsg: "Failed to start app" }) } @@ -134,7 +134,7 @@ function createApp( buildPath: string, mode = "production", publicPath = "/build/", - assetsBuildDirectory = "public/build/", + assetsBuildDirectory = "public/build/" ) { const app = express() diff --git a/src/components/Chart.tsx b/src/components/Chart.tsx index f720944dc..d08aec51d 100644 --- a/src/components/Chart.tsx +++ b/src/components/Chart.tsx @@ -6,7 +6,7 @@ import type { HydratedGitBlobObject, HydratedGitCommitObject, HydratedGitObject, - HydratedGitTreeObject, + HydratedGitTreeObject } from "~/analyzer/model" import { useClickedObject } from "~/contexts/ClickedContext" import { useComponentSize } from "~/hooks" @@ -22,7 +22,7 @@ import { treemapPaddingTop, treemapTreeTextOffsetX, circleBlobTextOffsetY, - treemapTreeTextOffsetY, + treemapTreeTextOffsetY } from "../const" import { useData } from "../contexts/DataContext" import { useMetrics } from "../contexts/MetricContext" @@ -37,7 +37,7 @@ import { useSearch } from "~/contexts/SearchContext" type CircleOrRectHiearchyNode = HierarchyCircularNode | HierarchyRectangularNode export const Chart = memo(function Chart({ - setHoveredObject, + setHoveredObject }: { setHoveredObject: (obj: HydratedGitObject | null) => void }) { @@ -79,8 +79,8 @@ export const Chart = memo(function Chart({ ...analyzerData.commit, tree: { ...analyzerData.commit.tree, - children: flatten(analyzerData.commit.tree), - }, + children: flatten(analyzerData.commit.tree) + } } }, [analyzerData.commit, hierarchyType]) @@ -104,7 +104,7 @@ export const Chart = memo(function Chart({ return setClickedObject(d.data) }, onMouseOver: () => setHoveredObject(d.data as HydratedGitObject), - onMouseOut: () => setHoveredObject(null), + onMouseOut: () => setHoveredObject(null) } : { onClick: (evt) => { @@ -117,7 +117,7 @@ export const Chart = memo(function Chart({ if (!isRoot) setHoveredObject(d.data as HydratedGitObject) else setHoveredObject(null) }, - onMouseOut: () => setHoveredObject(null), + onMouseOut: () => setHoveredObject(null) } } @@ -126,7 +126,7 @@ export const Chart = memo(function Chart({ 0 && isTree(d.data), - "animate-blink": clickedObject?.path === d.data.path, + "animate-blink": clickedObject?.path === d.data.path })} {...createGroupHandlers(d, i === 0)} > @@ -177,7 +177,7 @@ function Node({ d, isSearchMatch }: { d: CircleOrRectHiearchyNode; isSearchMatch strokeWidth: "1px", fill: isBlob(d.data) ? metricsData[authorshipType].get(metricType)?.colormap.get(d.data.path) ?? "grey" - : "transparent", + : "transparent" } if (chartType === "BUBBLE_CHART") { @@ -189,7 +189,7 @@ function Node({ d, isSearchMatch }: { d: CircleOrRectHiearchyNode; isSearchMatch width: circleDatum.r * 2, height: circleDatum.r * 2, rx: circleDatum.r, - ry: circleDatum.r, + ry: circleDatum.r } } else { const datum = d as HierarchyRectangularNode @@ -201,7 +201,7 @@ function Node({ d, isSearchMatch }: { d: CircleOrRectHiearchyNode; isSearchMatch width: datum.x1 - datum.x0, height: datum.y1 - datum.y0, rx: treemapNodeBorderRadius, - ry: treemapNodeBorderRadius, + ry: treemapNodeBorderRadius } } return props @@ -214,7 +214,7 @@ function Node({ d, isSearchMatch }: { d: CircleOrRectHiearchyNode; isSearchMatch "cursor-pointer": isBlob(d.data), "transition-all duration-1000 ease-in-out": transitionsEnabled, "animate-stroke-pulse": isSearchMatch, - "stroke-black/20": isTree(d.data), + "stroke-black/20": isTree(d.data) })} /> ) @@ -225,7 +225,7 @@ function collapseText({ isRoot, path, displayText, - chartType, + chartType }: { d: CircleOrRectHiearchyNode isRoot: boolean @@ -314,7 +314,7 @@ function NodeText({ d, children = null }: { d: CircleOrRectHiearchyNode; childre startOffset: isBubbleChart ? "50%" : undefined, dominantBaseline: isBubbleChart ? (isTree(d.data) ? "central" : "hanging") : "hanging", textAnchor: isBubbleChart ? "middle" : "start", - href: `#path-${d.data.path}`, + href: `#path-${d.data.path}` } return ( @@ -323,7 +323,7 @@ function NodeText({ d, children = null }: { d: CircleOrRectHiearchyNode; childre {isTree(d.data) ? ( @@ -335,7 +335,7 @@ function NodeText({ d, children = null }: { d: CircleOrRectHiearchyNode; childre {...textPathBaseProps} className={clsx("font-mono", { "text-sm font-bold": isTree(d.data), - "text-xs": !isTree(d.data), + "text-xs": !isTree(d.data) })} > {children} diff --git a/src/components/CommitHistory.tsx b/src/components/CommitHistory.tsx index 6487a7eb4..76f9fd1ac 100644 --- a/src/components/CommitHistory.tsx +++ b/src/components/CommitHistory.tsx @@ -1,3 +1,4 @@ +/* eslint-disable react-hooks/exhaustive-deps */ import type { GitLogEntry, HydratedGitTreeObject } from "~/analyzer/model" import { Fragment, useEffect, useMemo, useState } from "react" import { dateFormatLong } from "~/util" @@ -41,7 +42,7 @@ function CommitDistFragment(props: CommitDistFragProps) { ) })} - ), + ) }) } diff --git a/src/components/DetailsCard.tsx b/src/components/DetailsCard.tsx index ffc3ed850..e62920403 100644 --- a/src/components/DetailsCard.tsx +++ b/src/components/DetailsCard.tsx @@ -13,7 +13,6 @@ import byteSize from "byte-size" import type { AuthorshipType } from "~/metrics/metrics" import { mdiAccountMultiple, mdiOpenInNew, mdiEyeOffOutline, mdiFile, mdiFolder } from "@mdi/js" import { Icon } from "@mdi/react" -import { CommitHistory } from "./CommitHistory" import clsx from "clsx" import { useMetrics } from "~/contexts/MetricContext" import { MenuItem, MenuTab } from "./MenuTab" @@ -29,7 +28,7 @@ function OneFolderOut(path: string) { export function DetailsCard({ className = "", - showUnionAuthorsModal, + showUnionAuthorsModal }: { className?: string showUnionAuthorsModal: () => void @@ -60,7 +59,7 @@ export function DetailsCard({ return { backgroundColor: null, color: null, - lightBackground: true, + lightBackground: true } } const colormap = metricsData[authorshipType]?.get(metricType)?.colormap @@ -69,7 +68,7 @@ export function DetailsCard({ return { backgroundColor: backgroundColor, color: color, - lightBackground: color === "#000000", + lightBackground: color === "#000000" } }, [clickedObject, metricsData, metricType, authorshipType]) @@ -84,7 +83,7 @@ export function DetailsCard({ color ? { backgroundColor: backgroundColor, - color: color, + color: color } : {} } @@ -123,7 +122,7 @@ export function DetailsCard({

Analysis details

diff --git a/src/components/LoadingIndicator.tsx b/src/components/LoadingIndicator.tsx index 463a59db1..3254ebbfc 100644 --- a/src/components/LoadingIndicator.tsx +++ b/src/components/LoadingIndicator.tsx @@ -3,7 +3,7 @@ import anitruck from "~/assets/truck.gif" export function LoadingIndicator({ loadingText = "Loading", - className = "", + className = "" }: { loadingText?: string className?: string @@ -12,7 +12,7 @@ export function LoadingIndicator({
diff --git a/src/components/MenuTab.tsx b/src/components/MenuTab.tsx index 8df25db58..e816719ed 100644 --- a/src/components/MenuTab.tsx +++ b/src/components/MenuTab.tsx @@ -1,8 +1,8 @@ -import clsx from "clsx"; -import type { PropsWithChildren, ReactNode } from "react"; -import { Children, isValidElement, useState } from "react" +import clsx from "clsx" +import type { PropsWithChildren, ReactNode } from "react" +import { Children, isValidElement, useState } from "react" -const MenuItemTypeString = "MENUITEM"; +const MenuItemTypeString = "MENUITEM" type InternalMenuItem = { title: string @@ -25,47 +25,50 @@ export const MenuItem = (props: PropsWithChildren) => { } MenuItem.defaultProps = { - "__TYPE": MenuItemTypeString + __TYPE: MenuItemTypeString } export const MenuTab = (props: PropsWithChildren) => { - const [ currentIdx, setCurrentIdx ] = useState(0) + const [currentIdx, setCurrentIdx] = useState(0) const selectedIdx = props.selectedItemIndex ? props.selectedItemIndex : currentIdx - const items = Children.toArray(props.children).map(item => { - if(!isValidElement(item)) return false + const items = Children.toArray(props.children).map((item) => { + if (!isValidElement(item)) return false if (item.props.__TYPE && item.props.__TYPE == MenuItemTypeString) { return { title: item.props.title, children: item.props.children } } - }) as InternalMenuItem[]; + return false + }) as InternalMenuItem[] return ( <> -
- { items.map((item, idx) => ( - { - event.preventDefault(); - if (props.onChange) { - props.onChange(idx) - } - setCurrentIdx((currentValue) => (currentValue !== idx ? idx : currentValue)) - } } - > - { item.title } - - )) } +
+ {items.map((item, idx) => ( + + ))}
- { items.map((item, idx) => ( - idx == selectedIdx ?
{ item.children }
: null - )) } + {items.map((item, idx) => + idx == selectedIdx ? ( +
+ {item.children} +
+ ) : null + )} ) } diff --git a/src/components/Options.tsx b/src/components/Options.tsx index 75051a1eb..0b095591d 100644 --- a/src/components/Options.tsx +++ b/src/components/Options.tsx @@ -26,21 +26,21 @@ import { mdiViewModule, mdiCog, mdiFileTree, - mdiFamilyTree, + mdiFamilyTree } from "@mdi/js" import type { SizeMetricType } from "~/metrics/sizeMetric" import { SizeMetric } from "~/metrics/sizeMetric" import { useLocalStorage } from "react-use" import { Depth, type DepthType, depthTypeIcons } from "~/metrics/chartDepth" -function isMetricWithHistoricalOption(metric: MetricType) { - switch (metric) { - case "SINGLE_AUTHOR": - case "TOP_CONTRIBUTOR": - return true - } - return false -} +// function isMetricWithHistoricalOption(metric: MetricType) { +// switch (metric) { +// case "SINGLE_AUTHOR": +// case "TOP_CONTRIBUTOR": +// return true +// } +// return false +// } export const Options = memo(function Options() { const { @@ -57,7 +57,7 @@ export const Options = memo(function Options() { setChartType, setDepthType, setHierarchyType, - setSizeMetricType, + setSizeMetricType } = useOptions() const [linkMetricAndSizeMetric, setLinkMetricAndSizeMetric] = useLocalStorage( @@ -71,7 +71,7 @@ export const Options = memo(function Options() { MOST_COMMITS: mdiSourceCommit, SINGLE_AUTHOR: mdiAccountAlertOutline, TOP_CONTRIBUTOR: mdiPodiumGold, - TRUCK_FACTOR: mdiTruckFastOutline, + TRUCK_FACTOR: mdiTruckFastOutline } const sizeMetricIcons: Record = { @@ -79,17 +79,17 @@ export const Options = memo(function Options() { EQUAL_SIZE: mdiScaleBalance, MOST_COMMITS: mdiSourceCommit, TRUCK_FACTOR: mdiTruckFastOutline, - LAST_CHANGED: mdiUpdate, + LAST_CHANGED: mdiUpdate } const chartTypeIcons: Record = { BUBBLE_CHART: mdiChartBubble, - TREE_MAP: mdiChartTree, + TREE_MAP: mdiChartTree } const hiearchyIcons: Record = { NESTED: mdiFileTree, - FLAT: mdiChartTree, + FLAT: mdiChartTree } const relatedSizeMetric: Record = { @@ -98,7 +98,7 @@ export const Options = memo(function Options() { TOP_CONTRIBUTOR: "TRUCK_FACTOR", MOST_COMMITS: "MOST_COMMITS", SINGLE_AUTHOR: "TRUCK_FACTOR", - LAST_CHANGED: "LAST_CHANGED", + LAST_CHANGED: "LAST_CHANGED" } return ( diff --git a/src/components/Providers.tsx b/src/components/Providers.tsx index 4aa645c91..78b6a9e57 100644 --- a/src/components/Providers.tsx +++ b/src/components/Providers.tsx @@ -13,7 +13,7 @@ import { createMetricData as createMetricsData } from "../metrics/metrics" import { OPTIONS_LOCAL_STORAGE_KEY } from "~/analyzer/constants" import type { SizeMetricType } from "~/metrics/sizeMetric" import type { DepthType } from "~/metrics/chartDepth" -import type { CommitTab } from "~/contexts/CommitTabContext"; +import type { CommitTab } from "~/contexts/CommitTabContext" import { CommitTabContext, getDefaultCommitTab } from "~/contexts/CommitTabContext" interface ProvidersProps { @@ -28,7 +28,10 @@ export function Providers({ children, data }: ProvidersProps) { const [path, setPath] = useState(data.repo.name) const [clickedObject, setClickedObject] = useState(null) - const metricsData: MetricsData = useMemo(() => createMetricsData(data.analyzerData, data.truckConfig.colorSeed), [data]) + const metricsData: MetricsData = useMemo( + () => createMetricsData(data.analyzerData, data.truckConfig.colorSeed), + [data] + ) const commitTabValue = useMemo( () => ({ @@ -37,15 +40,15 @@ export function Providers({ children, data }: ProvidersProps) { setStartDate: (newDate: number | null) => { setCommitTab((prevValue) => ({ ...(prevValue ?? getDefaultCommitTab()), - startDate: newDate, + startDate: newDate })) }, setEndDate: (newDate: number | null) => { setCommitTab((prevValue) => ({ ...(prevValue ?? getDefaultCommitTab()), - endDate: newDate, + endDate: newDate })) - }, + } }), [commitTab] ) @@ -57,50 +60,50 @@ export function Providers({ children, data }: ProvidersProps) { setMetricType: (metricType: MetricType) => setOptions((prevOptions) => ({ ...(prevOptions ?? getDefaultOptionsContextValue()), - metricType, + metricType })), setChartType: (chartType: ChartType) => setOptions((prevOptions) => ({ ...(prevOptions ?? getDefaultOptionsContextValue()), - chartType, + chartType })), setDepthType: (depthType: DepthType) => setOptions((prevOptions) => ({ ...(prevOptions ?? getDefaultOptionsContextValue()), - depthType, + depthType })), setHierarchyType: (hierarchyType: HierarchyType) => setOptions((prevOptions) => ({ ...(prevOptions ?? getDefaultOptionsContextValue()), - hierarchyType, + hierarchyType })), setAuthorshipType: (authorshipType: AuthorshipType) => setOptions((prevOptions) => ({ ...(prevOptions ?? getDefaultOptionsContextValue()), - authorshipType, + authorshipType })), setSizeMetricType: (sizeMetric: SizeMetricType) => setOptions((prevOptions) => ({ ...(prevOptions ?? getDefaultOptionsContextValue()), sizeMetric })), setHoveredBlob: (blob: HydratedGitBlobObject | null) => setOptions((prevOptions) => ({ ...(prevOptions ?? getDefaultOptionsContextValue()), - hoveredBlob: blob, + hoveredBlob: blob })), setClickedObject: (object: HydratedGitObject | null) => setOptions((prevOptions) => ({ ...(prevOptions ?? getDefaultOptionsContextValue()), - clickedObject: object, + clickedObject: object })), setTransitionsEnabled: (enabled: boolean) => setOptions((prevOptions) => ({ ...(prevOptions ?? getDefaultOptionsContextValue()), - transitionsEnabled: enabled, + transitionsEnabled: enabled })), setLabelsVisible: (visible: boolean) => setOptions((prevOptions) => ({ ...(prevOptions ?? getDefaultOptionsContextValue()), - labelsVisible: visible, - })), + labelsVisible: visible + })) }), [options] ) @@ -124,7 +127,7 @@ export function Providers({ children, data }: ProvidersProps) { if (savedOptions) { setOptions({ ...getDefaultOptionsContextValue(JSON.parse(savedOptions)), - hasLoadedSavedOptions: true, + hasLoadedSavedOptions: true }) } }, []) @@ -136,7 +139,7 @@ export function Providers({ children, data }: ProvidersProps) { diff --git a/src/components/SearchCard.tsx b/src/components/SearchCard.tsx index 215bde06f..d3b9ecabe 100644 --- a/src/components/SearchCard.tsx +++ b/src/components/SearchCard.tsx @@ -1,7 +1,7 @@ -import { memo, useEffect, useMemo, useRef, useState, useTransition } from "react" +import { memo, useEffect, useMemo, useRef, useState, useTransition, useId } from "react" import type { SearchResults } from "~/contexts/SearchContext" import { useSearch } from "~/contexts/SearchContext" -import { useId } from "react" + import type { HydratedGitObject, HydratedGitTreeObject } from "~/analyzer/model" import { useData } from "~/contexts/DataContext" import { usePath } from "~/contexts/PathContext" diff --git a/src/components/Tooltip.tsx b/src/components/Tooltip.tsx index 76c976cc3..b44186508 100644 --- a/src/components/Tooltip.tsx +++ b/src/components/Tooltip.tsx @@ -41,7 +41,7 @@ export const Tooltip = memo(function Tooltip({ hoveredObject, x, y }: TooltipPro }`} ref={tooltipRef} style={{ - transform: visible ? `translate(${xTransform}, ${yTransform})` : "none", + transform: visible ? `translate(${xTransform}, ${yTransform})` : "none" }} > {hoveredObject?.type === "blob" ? ( @@ -65,7 +65,7 @@ export const Tooltip = memo(function Tooltip({ hoveredObject, x, y }: TooltipPro ? ColorMetricDependentInfo({ metric: metricType, hoveredBlob: hoveredObject as HydratedGitBlobObject, - authorshipType: authorshipType, + authorshipType: authorshipType }) : null}
diff --git a/src/components/UnionAuthorsModal.tsx b/src/components/UnionAuthorsModal.tsx index 048c1ab18..74ebedaca 100644 --- a/src/components/UnionAuthorsModal.tsx +++ b/src/components/UnionAuthorsModal.tsx @@ -1,6 +1,6 @@ -import { useTransition } from "react" +import { useTransition, useState } from "react" import type { MouseEvent } from "react" -import { useState } from "react" + import { useNavigation, useSubmit } from "@remix-run/react" import { useData } from "~/contexts/DataContext" import { getPathFromRepoAndHead } from "~/util" @@ -34,7 +34,7 @@ export function UnionAuthorsModal({ visible, onClose }: { visible: boolean; onCl submit(form, { action: `/${getPathFromRepoAndHead(repo.name, repo.currentHead)}`, - method: "post", + method: "post" }) } @@ -44,7 +44,7 @@ export function UnionAuthorsModal({ visible, onClose }: { visible: boolean; onCl submit(form, { action: `/${getPathFromRepoAndHead(repo.name, repo.currentHead)}`, - method: "post", + method: "post" }) } @@ -55,7 +55,7 @@ export function UnionAuthorsModal({ visible, onClose }: { visible: boolean; onCl submit(form, { action: `/${getPathFromRepoAndHead(repo.name, repo.currentHead)}`, - method: "post", + method: "post" }) setSelectedAuthors([]) } @@ -72,7 +72,7 @@ export function UnionAuthorsModal({ visible, onClose }: { visible: boolean; onCl submit(form, { action: `/${getPathFromRepoAndHead(repo.name, repo.currentHead)}`, - method: "post", + method: "post" }) } @@ -229,7 +229,7 @@ export function UnionAuthorsModal({ visible, onClose }: { visible: boolean; onCl function AliasEntry({ alias, onClick, - disabled, + disabled }: { alias: string disabled?: boolean diff --git a/src/components/accordion/Accordion.tsx b/src/components/accordion/Accordion.tsx index 963704527..95d41aa3d 100644 --- a/src/components/accordion/Accordion.tsx +++ b/src/components/accordion/Accordion.tsx @@ -1,4 +1,4 @@ -import type { ReactNode} from "react"; +import type { ReactNode } from "react" import { useState } from "react" import AccordionItem from "./AccordionItem" @@ -7,19 +7,13 @@ export type AccordionData = { content: ReactNode } -export type ShowMoreLabelProps = { - toggle: () => void - items: Array - show: boolean -} - function Accordion({ items, multipleOpen, openByDefault, titleLabels, currentState, - actionClickLabels, + actionClickLabels }: { items: Array multipleOpen: boolean @@ -37,31 +31,30 @@ function Accordion({ : setCurrentIdx((currentValue) => (currentValue.includes(idx) ? [] : [idx])) } if (openByDefault && !multipleOpen) { - setCurrentIdx([0]); + setCurrentIdx([0]) } return ( -
    +
      {items.map((item, idx) => ( - { - btnOnClick(idx) - if (actionClickLabels) actionClickLabels(idx); - }} - /> + { + btnOnClick(idx) + if (actionClickLabels) actionClickLabels(idx) + }} + /> ))}
    ) } - export default Accordion diff --git a/src/components/accordion/AccordionItem.tsx b/src/components/accordion/AccordionItem.tsx index d1e58801e..f60a38226 100644 --- a/src/components/accordion/AccordionItem.tsx +++ b/src/components/accordion/AccordionItem.tsx @@ -2,34 +2,42 @@ import type { AccordionData } from "./Accordion" import clsx from "clsx" function AccordionItem({ - data, - isOpen, - btnOnClick, - titleLabels + data, + isOpen, + btnOnClick, + titleLabels }: { - data: AccordionData - isOpen: boolean - btnOnClick: () => void - titleLabels?: boolean + data: AccordionData + isOpen: boolean + btnOnClick: () => void + titleLabels?: boolean }) { - const afterStyle = "after:content-[''] after:shrink-0 after:w-[14px] after:h-[14px] after:ml-auto after:transition-[transform] after:duration-[200ms] after:ease-out after:bg-[length:14px_14px] after:bg-no-repeat after:bg-arrow"; - return ( -
  • -

    -
    - { data.title } -
    -

    -
      - { isOpen &&
      { data.content }
      } -
    -
  • - ) + const afterStyle = + "after:content-[''] after:shrink-0 after:w-[14px] after:h-[14px] after:ml-auto after:transition-[transform] after:duration-[200ms] after:ease-out after:bg-[length:14px_14px] after:bg-no-repeat after:bg-arrow" + return ( +
  • +

    +
    + {data.title} +
    +

    +
      + {isOpen &&
      {data.content}
      } +
    +
  • + ) } export default AccordionItem diff --git a/src/components/legend/GradiantLegend.tsx b/src/components/legend/GradiantLegend.tsx index e40812891..128deed52 100644 --- a/src/components/legend/GradiantLegend.tsx +++ b/src/components/legend/GradiantLegend.tsx @@ -46,7 +46,7 @@ export function GradientLegend({ hoveredObject, metricCache }: MetricLegendProps
    diff --git a/src/components/legend/Legend.tsx b/src/components/legend/Legend.tsx index 0f610eaf1..ab7fe3392 100644 --- a/src/components/legend/Legend.tsx +++ b/src/components/legend/Legend.tsx @@ -18,7 +18,7 @@ export type LegendType = "POINT" | "GRADIENT" | "SEGMENTS" export function Legend({ hoveredObject, showUnionAuthorsModal, - className = "", + className = "" }: { hoveredObject: HydratedGitObject | null showUnionAuthorsModal: () => void @@ -54,7 +54,7 @@ export function Legend({ submit(form, { action: `/${getPathFromRepoAndHead(repo.name, repo.currentHead)}`, - method: "post", + method: "post" }) } diff --git a/src/components/legend/PointLegend.tsx b/src/components/legend/PointLegend.tsx index 21464f826..17ae7c229 100644 --- a/src/components/legend/PointLegend.tsx +++ b/src/components/legend/PointLegend.tsx @@ -6,7 +6,11 @@ import { ChevronButton } from "../ChevronButton" const legendCutoff = 3 export class PointInfo { - constructor(public readonly color: `#${string}`, public weight: number) {} + // eslint-disable-next-line no-useless-constructor + constructor( + public readonly color: `#${string}`, + public weight: number + ) {} add(value: number) { this.weight += value @@ -82,7 +86,7 @@ function PointLegendOther(props: LegendOtherProps) { key={`dot${label}`} dotColor={info.color} style={{ - marginLeft: margin, + marginLeft: margin }} /> ) diff --git a/src/components/util.tsx b/src/components/util.tsx index 1b43d9297..694e26adc 100644 --- a/src/components/util.tsx +++ b/src/components/util.tsx @@ -10,7 +10,7 @@ export const CloseButton = ({ }: HTMLAttributes & { absolute?: boolean }) => (