Skip to content

Commit 10cb5b1

Browse files
Thomas StrombergThomas Stromberg
authored andcommitted
lint
1 parent 77c4185 commit 10cb5b1

File tree

16 files changed

+141
-88
lines changed

16 files changed

+141
-88
lines changed

.yamllint

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
---
2+
extends: default
3+
4+
rules:
5+
braces:
6+
max-spaces-inside: 1
7+
brackets:
8+
max-spaces-inside: 1
9+
comments: disable
10+
comments-indentation: disable
11+
document-start: disable
12+
line-length:
13+
level: warning
14+
max: 160
15+
allow-non-breakable-inline-mappings: true
16+
truthy: disable

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ LINTERS += yamllint-lint
7070
yamllint-lint: $(YAMLLINT_BIN)
7171
PYTHONPATH=$(YAMLLINT_ROOT)/dist $(YAMLLINT_ROOT)/dist/bin/yamllint .
7272

73-
BIOME_VERSION ?= 1.9.4
73+
BIOME_VERSION ?= 2.2.6
7474
BIOME_BIN := $(LINT_ROOT)/out/linters/biome-$(BIOME_VERSION)-$(LINT_ARCH)
7575
BIOME_CONFIG := $(LINT_ROOT)/biome.json
7676

@@ -83,7 +83,7 @@ endif
8383
$(BIOME_BIN):
8484
mkdir -p $(LINT_ROOT)/out/linters
8585
rm -rf $(LINT_ROOT)/out/linters/biome-*
86-
curl -sSfL -o $@ https://github.com/biomejs/biome/releases/download/cli%2Fv$(BIOME_VERSION)/biome-$(LINT_OS_LOWER)-$(BIOME_ARCH) \
86+
curl -sSfL -o $@ https://github.com/biomejs/biome/releases/download/%40biomejs%2Fbiome%40$(BIOME_VERSION)/biome-$(LINT_OS_LOWER)-$(BIOME_ARCH) \
8787
|| echo "Unable to fetch biome for $(LINT_OS_LOWER)/$(BIOME_ARCH), falling back to local install"
8888
test -f $@ || printf "#!/usr/bin/env biome\n" > $@
8989
chmod u+x $@

assets/app.js

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { Robots } from "./robots.js";
55
import { Stats } from "./stats.js";
66
import { User } from "./user.js";
77
// Ready To Review - Modern ES6+ Application
8-
import { $, $$, clearChildren, el, hide, setHTML, show, showToast } from "./utils.js";
8+
import { $, clearChildren, el, hide, show, showToast } from "./utils.js";
99
import { Workspace } from "./workspace.js";
1010

1111
const App = (() => {
@@ -40,7 +40,7 @@ const App = (() => {
4040
isChangelog: true,
4141
};
4242
}
43-
const changelogMatch = path.match(/^\/changelog\/([^\/]+)$/);
43+
const changelogMatch = path.match(/^\/changelog\/([^/]+)$/);
4444
if (changelogMatch) {
4545
const [, username] = changelogMatch;
4646
return {
@@ -87,7 +87,7 @@ const App = (() => {
8787
}
8888

8989
// Check for user dashboard pattern: /u/username
90-
const userMatch = path.match(/^\/u\/([^\/]+)$/);
90+
const userMatch = path.match(/^\/u\/([^/]+)$/);
9191
if (userMatch) {
9292
const [, username] = userMatch;
9393
return {
@@ -435,7 +435,7 @@ const App = (() => {
435435
const rateLimitReset = response.headers.get("X-RateLimit-Reset");
436436

437437
if (rateLimitRemaining === "0") {
438-
const resetTime = new Date(Number.parseInt(rateLimitReset) * 1000);
438+
const resetTime = new Date(Number.parseInt(rateLimitReset, 10) * 1000);
439439
const now = new Date();
440440
const minutesUntilReset = Math.ceil((resetTime - now) / 60000);
441441

@@ -464,7 +464,7 @@ const App = (() => {
464464
errorMessage = `GitHub error: ${firstError.message}`;
465465
}
466466
}
467-
} catch (e) {
467+
} catch (_e) {
468468
// Use default message
469469
}
470470

@@ -488,14 +488,18 @@ const App = (() => {
488488

489489
// Demo Mode
490490
const initializeDemoMode = () => {
491+
// biome-ignore lint/correctness/noUndeclaredVariables: DEMO_DATA loaded as global from demo-data.js
491492
if (typeof DEMO_DATA === "undefined") {
492493
console.error("Demo data not loaded");
493494
return;
494495
}
495496

496497
state.isDemoMode = true;
498+
// biome-ignore lint/correctness/noUndeclaredVariables: DEMO_DATA loaded as global from demo-data.js
497499
state.currentUser = DEMO_DATA.user;
500+
// biome-ignore lint/correctness/noUndeclaredVariables: DEMO_DATA loaded as global from demo-data.js
498501
state.viewingUser = DEMO_DATA.user;
502+
// biome-ignore lint/correctness/noUndeclaredVariables: DEMO_DATA loaded as global from demo-data.js
499503
state.pullRequests = DEMO_DATA.pullRequests;
500504

501505
const allPRs = [...state.pullRequests.incoming, ...state.pullRequests.outgoing];
@@ -570,6 +574,7 @@ const App = (() => {
570574

571575
const urlContext = parseURL();
572576
if (!urlContext || !urlContext.username) {
577+
// biome-ignore lint/correctness/noUndeclaredVariables: DEMO_DATA loaded as global from demo-data.js
573578
window.location.href = `/u/${DEMO_DATA.user.login}?demo=true`;
574579
return;
575580
}
@@ -625,7 +630,7 @@ const App = (() => {
625630
path === "/" ||
626631
path.startsWith("/u/") ||
627632
path === "/robots" ||
628-
path.match(/^\/robots\/gh\/[^\/]+$/)
633+
path.match(/^\/robots\/gh\/[^/]+$/)
629634
) {
630635
show(searchInput);
631636
} else {
@@ -714,7 +719,7 @@ const App = (() => {
714719
}
715720
// Handle notifications page routing
716721
const path = window.location.pathname;
717-
if (path === "/notifications" || path.match(/^\/notifications\/gh\/[^\/]+$/)) {
722+
if (path === "/notifications" || path.match(/^\/notifications\/gh\/[^/]+$/)) {
718723
updateSearchInputVisibility();
719724
const token = Auth.getStoredToken();
720725
if (token) {
@@ -731,7 +736,7 @@ const App = (() => {
731736
}
732737

733738
// Handle robots page routing
734-
if (path === "/robots" || path.match(/^\/robots\/gh\/[^\/]+$/)) {
739+
if (path === "/robots" || path.match(/^\/robots\/gh\/[^/]+$/)) {
735740
updateSearchInputVisibility();
736741
const token = Auth.getStoredToken();
737742
if (!token) {
@@ -969,7 +974,7 @@ const App = (() => {
969974
Robots.copyYAML();
970975
try {
971976
showToast("Configuration copied to clipboard!", "success");
972-
} catch (error) {
977+
} catch (_error) {
973978
showToast("Failed to copy to clipboard", "error");
974979
}
975980
};

assets/auth.js

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export const Auth = (() => {
3131
}
3232

3333
function getCookie(name) {
34-
const nameEQ = name + "=";
34+
const nameEQ = `${name}=`;
3535
const ca = document.cookie.split(";");
3636
for (let i = 0; i < ca.length; i++) {
3737
let c = ca[i];
@@ -79,7 +79,7 @@ export const Auth = (() => {
7979
console.log("[Auth.initiateOAuthLogin] Current URL:", window.location.href);
8080
console.log(
8181
"[Auth.initiateOAuthLogin] Redirecting to:",
82-
window.location.origin + "/oauth/login"
82+
`${window.location.origin}/oauth/login`
8383
);
8484

8585
// Simply redirect to the backend OAuth endpoint
@@ -198,7 +198,7 @@ export const Auth = (() => {
198198
errorDiv.style.display = "block";
199199
}
200200
}
201-
} catch (error) {
201+
} catch (_error) {
202202
if (errorDiv) {
203203
errorDiv.textContent = "Error validating token. Please try again.";
204204
errorDiv.style.display = "block";
@@ -274,7 +274,7 @@ export const Auth = (() => {
274274

275275
const token = getStoredToken();
276276
if (token) {
277-
headers["Authorization"] = `token ${token}`;
277+
headers.Authorization = `token ${token}`;
278278
}
279279

280280
let lastError;
@@ -302,14 +302,14 @@ export const Auth = (() => {
302302
const responseClone = response.clone();
303303
const responseText = await responseClone.text();
304304
console.warn("Response body:", responseText);
305-
} catch (e) {
305+
} catch (_e) {
306306
console.warn("Could not read response body due to CORS restrictions");
307307
}
308308
}
309309

310310
// Retry on all 500+ server errors
311311
if (response.status >= 500 && attempt < retries) {
312-
const delay = Math.min(250 * Math.pow(2, attempt), 10000); // Exponential backoff starting at 250ms, max 10s
312+
const delay = Math.min(250 * 2 ** attempt, 10000); // Exponential backoff starting at 250ms, max 10s
313313
console.warn(
314314
`[githubAPI] Retry ${attempt + 1}/${retries} for ${CONFIG.API_BASE}${endpoint} - Status: ${response.status}, Delay: ${delay}ms`
315315
);
@@ -325,7 +325,7 @@ export const Auth = (() => {
325325

326326
// If it's a network error and we have retries left, try again
327327
if (attempt < retries) {
328-
const delay = Math.min(250 * Math.pow(2, attempt), 10000);
328+
const delay = Math.min(250 * 2 ** attempt, 10000);
329329
console.warn(
330330
`[githubAPI] Network error retry ${attempt + 1}/${retries} for ${CONFIG.API_BASE}${endpoint} - Error: ${error.message}, Delay: ${delay}ms`
331331
);
@@ -385,7 +385,7 @@ export const Auth = (() => {
385385

386386
// Retry on all 500+ server errors
387387
if (response.status >= 500 && attempt < retries) {
388-
const delay = Math.min(250 * Math.pow(2, attempt), 10000); // Exponential backoff starting at 250ms, max 10s
388+
const delay = Math.min(250 * 2 ** attempt, 10000); // Exponential backoff starting at 250ms, max 10s
389389

390390
// Log all available response information
391391
console.warn(
@@ -397,7 +397,7 @@ export const Auth = (() => {
397397
try {
398398
const responseText = await response.text();
399399
console.warn("Response body:", responseText);
400-
} catch (e) {
400+
} catch (_e) {
401401
console.warn("Could not read response body due to CORS restrictions");
402402
}
403403

@@ -410,15 +410,15 @@ export const Auth = (() => {
410410
console.error("Request details:", {
411411
query,
412412
variables,
413-
authHeader: authHeader.substring(0, 20) + "...",
413+
authHeader: `${authHeader.substring(0, 20)}...`,
414414
});
415415
throw new Error(`GraphQL request failed: ${response.status} ${response.statusText}`);
416416
}
417417

418418
const data = await response.json();
419419
if (data.errors) {
420420
console.error("GraphQL errors:", data.errors);
421-
throw new Error("GraphQL query failed: " + data.errors[0]?.message);
421+
throw new Error(`GraphQL query failed: ${data.errors[0]?.message}`);
422422
}
423423

424424
return data.data;
@@ -427,7 +427,7 @@ export const Auth = (() => {
427427

428428
// If it's a network error and we have retries left, try again
429429
if (error.name === "TypeError" && error.message.includes("fetch") && attempt < retries) {
430-
const delay = Math.min(250 * Math.pow(2, attempt), 10000);
430+
const delay = Math.min(250 * 2 ** attempt, 10000);
431431
console.warn(
432432
`[githubGraphQL] Network error retry ${attempt + 1}/${retries} for ${CONFIG.API_BASE}/graphql - Error: ${error.message}, Delay: ${delay}ms`
433433
);

assets/changelog.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ export const Changelog = (() => {
216216

217217
// Wait before retrying (exponential backoff)
218218
if (attempt < maxRetries) {
219-
const delay = Math.min(1000 * Math.pow(2, attempt - 1), 5000);
219+
const delay = Math.min(1000 * 2 ** (attempt - 1), 5000);
220220
await new Promise((resolve) => setTimeout(resolve, delay));
221221
}
222222
}

assets/demo-data.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
* Mock data representing a busy software engineer working on Go, Terraform, and React
44
*/
55

6+
// biome-ignore lint/correctness/noUnusedVariables: Used as global variable in app.js
67
const DEMO_DATA = {
78
user: {
89
login: "demo",

assets/leaderboard.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Stats } from "./stats.js";
22
// Leaderboard Module - Shows PR merge activity by contributor
3-
import { $, $$, escapeHtml, hide, show, showToast } from "./utils.js";
3+
import { $, $$, hide, show, showToast } from "./utils.js";
44

55
export const Leaderboard = (() => {
66
const TEN_DAYS_IN_MS = 10 * 24 * 60 * 60 * 1000;
@@ -56,7 +56,9 @@ export const Leaderboard = (() => {
5656
loadUserOrganizations
5757
) => {
5858
// Hide other content
59-
$$('[id$="Content"], #prSections').forEach((el) => el?.setAttribute("hidden", ""));
59+
$$('[id$="Content"], #prSections').forEach((el) => {
60+
el?.setAttribute("hidden", "");
61+
});
6062

6163
// Check for authentication first
6264
if (!state.accessToken) {
@@ -87,7 +89,7 @@ export const Leaderboard = (() => {
8789
}
8890
}
8991

90-
updateUserDisplay(state, () => {});
92+
updateUserDisplay(state, () => undefined);
9193
setupHamburgerMenu();
9294

9395
// Update search input placeholder
@@ -150,7 +152,7 @@ export const Leaderboard = (() => {
150152
mergedPRs = cached.data;
151153
console.log("Cached leaderboard data:", {
152154
totalPRs: mergedPRs.length,
153-
cacheAge: Math.round(cached.age / 60000) + " minutes",
155+
cacheAge: `${Math.round(cached.age / 60000)} minutes`,
154156
dateRange: {
155157
from: new Date(Date.now() - TEN_DAYS_IN_MS).toISOString().split("T")[0],
156158
to: new Date().toISOString().split("T")[0],
@@ -280,7 +282,7 @@ export const Leaderboard = (() => {
280282
<div class="chart-content">
281283
${topContributors
282284
.slice(0, 5)
283-
.map((author, index) => {
285+
.map((author, _index) => {
284286
const percentage = (author.count / maxContributorCount) * 100;
285287
return `
286288
<div class="chart-item">
@@ -305,7 +307,7 @@ export const Leaderboard = (() => {
305307
<div class="chart-content">
306308
${topRepos
307309
.slice(0, 5)
308-
.map((repo, index) => {
310+
.map((repo, _index) => {
309311
const percentage = (repo.count / maxRepoCount) * 100;
310312
const shortName = repo.name.split("/")[1] || repo.name;
311313
return `

0 commit comments

Comments
 (0)