From e4c5c0bd935d3e0c8ca969a7a6aefd34d8aa741b Mon Sep 17 00:00:00 2001 From: Art Chaidarun Date: Tue, 21 Nov 2023 13:56:18 -0500 Subject: [PATCH] Update `duolingo` pre-commit hook to 1.7.0 (#38) --- .pre-commit-config.yaml | 2 +- src/engines/drive.ts | 2 +- src/engines/github.ts | 12 +++++++----- src/engines/groups.ts | 6 +++--- src/engines/jenkins.ts | 2 +- src/engines/lingo.ts | 4 ++-- src/index.ts | 7 ++++--- src/ui/index.html | 2 +- src/ui/styles.scss | 4 +++- src/ui/ui.tsx | 4 ++-- src/util.ts | 9 ++++++--- 11 files changed, 31 insertions(+), 23 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index a0fa1c8..3910b05 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -7,7 +7,7 @@ repos: language: system files: ^src/* - repo: https://github.com/duolingo/pre-commit-hooks.git - rev: 1.6.0 + rev: 1.7.0 hooks: - id: duolingo exclude: config.yaml diff --git a/src/engines/drive.ts b/src/engines/drive.ts index 3d92dbf..5b9cbb0 100644 --- a/src/engines/drive.ts +++ b/src/engines/drive.ts @@ -28,7 +28,7 @@ const getMimeInfo = ( name: "Spreadsheet", urlFragment: "spreadsheets", }, - }[mimeType ?? ""] ?? { name: "File", urlFragment: "file" }); + })[mimeType ?? ""] ?? { name: "File", urlFragment: "file" }; const engine: Engine = { id: "drive", diff --git a/src/engines/github.ts b/src/engines/github.ts index bae0248..033d99c 100644 --- a/src/engines/github.ts +++ b/src/engines/github.ts @@ -53,8 +53,8 @@ const engine: Engine = { JSON.stringify({ query: `query { organization(login: "${organization}") { repositories(first: 100${ - cursor ? `, after: "${cursor}"` : "" - }) { + cursor ? `, after: "${cursor}"` : "" + }) { edges { node { description isArchived isFork name } } pageInfo { endCursor hasNextPage } } } }`, @@ -147,9 +147,11 @@ const engine: Engine = { snippet: item.body ? `
${marked(item.body)}
` : undefined, - title: `${item.pull_request ? "PR" : "Issue"} in ${ - item.html_url.match(/github\.com\/([^\/]+\/[^\/]+)\//)?.[1] - }: ${item.title}`, + title: `${ + item.pull_request ? "PR" : "Issue" + } in ${item.html_url.match( + /github\.com\/([^\/]+\/[^\/]+)\//, + )?.[1]}: ${item.title}`, url: item.html_url, })); } catch { diff --git a/src/engines/groups.ts b/src/engines/groups.ts index 7f48c88..05a3516 100644 --- a/src/engines/groups.ts +++ b/src/engines/groups.ts @@ -50,9 +50,9 @@ const engine: Engine = { .map(g => ({ snippet: g.description ?? undefined, title: `${g.name}: ${g.email}`, - url: `https://groups.google.com/a/${domain}/forum/#!members/${ - g.email?.split("@")[0] - }`, + url: `https://groups.google.com/a/${domain}/forum/#!members/${g.email?.split( + "@", + )[0]}`, })); }, }; diff --git a/src/engines/jenkins.ts b/src/engines/jenkins.ts index c7ed994..9e7f832 100644 --- a/src/engines/jenkins.ts +++ b/src/engines/jenkins.ts @@ -4,7 +4,7 @@ import { fuzzyIncludes, rateLimit } from "../util"; const JOB_FIELDS = ["description", "name", "url"] as const; -type Job = Record; +type Job = Record<(typeof JOB_FIELDS)[number], string>; let getJobs: (() => Promise>) | undefined; diff --git a/src/engines/lingo.ts b/src/engines/lingo.ts index 9f2cb7a..887d5a7 100644 --- a/src/engines/lingo.ts +++ b/src/engines/lingo.ts @@ -206,8 +206,8 @@ const engine: Engine = { snippet: item.asset.colors?.length ? hsb2rgb(item.asset.colors[0]) : item.asset.thumbnails - ? `` - : undefined, + ? `` + : undefined, title: `${kitName} > ${s.section.name} > ${item.asset.name}`, url, }; diff --git a/src/index.ts b/src/index.ts index c589ca2..32244c5 100644 --- a/src/index.ts +++ b/src/index.ts @@ -40,9 +40,10 @@ ${JSON.stringify(data)}`); // Locate user-provided config file const dockerizedConfig = `${DOCKER_MOUNT}/${CONFIG_FILENAME}`; - const configFile = fs.existsSync("/.dockerenv") || fs.existsSync("/run/.containerenv") - ? dockerizedConfig - : CONFIG_FILENAME; + const configFile = + fs.existsSync("/.dockerenv") || fs.existsSync("/run/.containerenv") + ? dockerizedConfig + : CONFIG_FILENAME; if (!fs.existsSync(configFile)) { throw Error(`Metasearch config file '${configFile}' not found`); } diff --git a/src/ui/index.html b/src/ui/index.html index d0a0f93..75e1cd6 100644 --- a/src/ui/index.html +++ b/src/ui/index.html @@ -1,4 +1,4 @@ - + Metasearch diff --git a/src/ui/styles.scss b/src/ui/styles.scss index f24cdde..6466758 100644 --- a/src/ui/styles.scss +++ b/src/ui/styles.scss @@ -80,7 +80,9 @@ // using web-safe Arial. font-family: Metasearch, Arial, sans-serif; outline: none; - transition: background-color 0.4s, color 0.4s; + transition: + background-color 0.4s, + color 0.4s; } ::placeholder { diff --git a/src/ui/ui.tsx b/src/ui/ui.tsx index e238819..420224b 100644 --- a/src/ui/ui.tsx +++ b/src/ui/ui.tsx @@ -136,8 +136,8 @@ const Sidebar = ({ numResults === undefined ? "Searching..." : numResults - ? "Jump to results" - : "No results found" + ? "Jump to results" + : "No results found" } >
diff --git a/src/util.ts b/src/util.ts index c7de667..752e726 100644 --- a/src/util.ts +++ b/src/util.ts @@ -154,9 +154,12 @@ export const rateLimit = Promise>( // Call provided function both immediately and on an interval let lastPromise = resultCachingFn(); - setInterval(() => { - lastPromise = resultCachingFn(); - }, (intervalHours * 60 - 5 * Math.random()) * 60 * 1000); // 5 minute jitter + setInterval( + () => { + lastPromise = resultCachingFn(); + }, + (intervalHours * 60 - 5 * Math.random()) * 60 * 1000, + ); // 5 minute jitter // Prefer returning the last resolved promise, falling back to a pending one return (() => (lastResult ? Promise.resolve(lastResult) : lastPromise)) as F;