Skip to content

Commit

Permalink
Update duolingo pre-commit hook to 1.7.0 (#38)
Browse files Browse the repository at this point in the history
  • Loading branch information
artnc authored Nov 21, 2023
1 parent 7b3bfbc commit e4c5c0b
Show file tree
Hide file tree
Showing 11 changed files with 31 additions and 23 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion src/engines/drive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
12 changes: 7 additions & 5 deletions src/engines/github.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
} } }`,
Expand Down Expand Up @@ -147,9 +147,11 @@ const engine: Engine = {
snippet: item.body
? `<blockquote>${marked(item.body)}</blockquote>`
: 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 {
Expand Down
6 changes: 3 additions & 3 deletions src/engines/groups.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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]}`,
}));
},
};
Expand Down
2 changes: 1 addition & 1 deletion src/engines/jenkins.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { fuzzyIncludes, rateLimit } from "../util";

const JOB_FIELDS = ["description", "name", "url"] as const;

type Job = Record<typeof JOB_FIELDS[number], string>;
type Job = Record<(typeof JOB_FIELDS)[number], string>;

let getJobs: (() => Promise<Set<Job>>) | undefined;

Expand Down
4 changes: 2 additions & 2 deletions src/engines/lingo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -206,8 +206,8 @@ const engine: Engine = {
snippet: item.asset.colors?.length
? hsb2rgb(item.asset.colors[0])
: item.asset.thumbnails
? `<a href="${url}"><img src="${item.asset.thumbnails["292"]}"></a>`
: undefined,
? `<a href="${url}"><img src="${item.asset.thumbnails["292"]}"></a>`
: undefined,
title: `${kitName} > ${s.section.name} > ${item.asset.name}`,
url,
};
Expand Down
7 changes: 4 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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`);
}
Expand Down
2 changes: 1 addition & 1 deletion src/ui/index.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!DOCTYPE html>
<!doctype html>
<html>
<head>
<title>Metasearch</title>
Expand Down
4 changes: 3 additions & 1 deletion src/ui/styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions src/ui/ui.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,8 @@ const Sidebar = ({
numResults === undefined
? "Searching..."
: numResults
? "Jump to results"
: "No results found"
? "Jump to results"
: "No results found"
}
>
<div className="engine-wrap">
Expand Down
9 changes: 6 additions & 3 deletions src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,9 +154,12 @@ export const rateLimit = <R, F extends () => Promise<R>>(

// 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;
Expand Down

0 comments on commit e4c5c0b

Please sign in to comment.