Skip to content

Commit c76325a

Browse files
authored
fix: manual biome linter errors (#978)
1 parent bda6d76 commit c76325a

27 files changed

+144
-59
lines changed

biome.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,12 @@
88
"rules": {
99
"recommended": true,
1010
"correctness": {
11-
"useExhaustiveDependencies": "warn"
11+
"useExhaustiveDependencies": {
12+
"level": "warn",
13+
"options": {
14+
"hooks": [{ "name": "useNavigate", "stableResult": true }]
15+
}
16+
}
1217
}
1318
}
1419
},

first-run.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
const { app, dialog } = require('electron');
22

3-
const fs = require('fs');
4-
const path = require('path');
3+
const fs = require('node:fs');
4+
const path = require('node:path');
55

66
async function onFirstRunMaybe() {
77
if (isFirstRun()) {
@@ -49,7 +49,7 @@ function isFirstRun() {
4949

5050
fs.writeFileSync(configPath, '');
5151
} catch (error) {
52-
console.warn(`First run: Unable to write firstRun file`, error);
52+
console.warn('First run: Unable to write firstRun file', error);
5353
}
5454

5555
return true;

main.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ const { ipcMain, app, nativeTheme } = require('electron');
22
const { menubar } = require('menubar');
33
const { autoUpdater } = require('electron-updater');
44
const { onFirstRunMaybe } = require('./first-run');
5-
const path = require('path');
5+
const path = require('node:path');
66

77
require('@electron/remote/main').initialize();
88

src/__mocks__/@electron/remote.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ class BrowserWindow {
55
if (!instance) {
66
instance = this;
77
}
8+
// biome-ignore lint/correctness/noConstructorReturn: This is a mock class
89
return instance;
910
}
1011
loadURL = jest.fn();

src/components/Logo.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const DARK_GRADIENT_END = '#555B6E';
1313
export const Logo = ({ isDark, onClick, className = '', ...props }: IProps) => (
1414
<svg
1515
className={className}
16-
onClick={() => onClick && onClick()}
16+
onClick={() => onClick?.()}
1717
xmlns="http://www.w3.org/2000/svg"
1818
xmlnsXlink="http://www.w3.org/1999/xlink"
1919
viewBox="0 0 500 500"
@@ -32,11 +32,11 @@ export const Logo = ({ isDark, onClick, className = '', ...props }: IProps) => (
3232
<stop
3333
stopColor={isDark ? DARK_GRADIENT_START : LIGHT_GRADIENT_START}
3434
offset="0%"
35-
></stop>
35+
/>
3636
<stop
3737
stopColor={isDark ? DARK_GRADIENT_END : LIGHT_GRADIENT_END}
3838
offset="100%"
39-
></stop>
39+
/>
4040
</linearGradient>
4141
</defs>
4242
<g stroke="none" strokeWidth="1" fill="none" fillRule="evenodd">
@@ -48,7 +48,7 @@ export const Logo = ({ isDark, onClick, className = '', ...props }: IProps) => (
4848
})`}
4949
fillRule="nonzero"
5050
>
51-
<path d="M330.391053,10.2526316 C361.413773,10.2526316 386.562656,35.4015165 386.562656,66.4242368 C386.562656,97.4469571 361.413773,122.595841 330.391053,122.595842 L330.365421,122.570211 L247.319105,122.570211 C180.042515,122.499128 125.399186,176.890222 125.159,244.166421 L125.133789,244.219632 L125.154247,245.84774 C126.219609,301.255958 164.473457,349.116728 218.453292,362.268048 C272.940509,375.542983 329.466993,350.045988 355.583747,300.428701 L272.258632,300.427737 C257.346614,300.427737 243.046846,294.496977 232.512078,283.942976 C221.97731,273.388975 216.072618,259.078414 216.099748,244.166421 C216.099748,213.150778 241.242989,188.007632 272.258632,188.007632 L371.119632,188.007632 C379.28704,188.480415 386.935401,192.166372 392.393842,198.260263 L474.869789,300.324632 L474.978789,300.325211 L474.952789,300.426632 L474.953158,300.427737 L474.951789,300.427632 L474.173714,303.448935 C446.939817,406.220475 353.906452,478.028529 247.319105,478.080211 C118.007789,478.080211 12.8157895,373.144526 12.8157895,244.166421 C12.8157895,115.188316 117.905263,10.2526316 247.319105,10.2526316 L330.391053,10.2526316 Z"></path>
51+
<path d="M330.391053,10.2526316 C361.413773,10.2526316 386.562656,35.4015165 386.562656,66.4242368 C386.562656,97.4469571 361.413773,122.595841 330.391053,122.595842 L330.365421,122.570211 L247.319105,122.570211 C180.042515,122.499128 125.399186,176.890222 125.159,244.166421 L125.133789,244.219632 L125.154247,245.84774 C126.219609,301.255958 164.473457,349.116728 218.453292,362.268048 C272.940509,375.542983 329.466993,350.045988 355.583747,300.428701 L272.258632,300.427737 C257.346614,300.427737 243.046846,294.496977 232.512078,283.942976 C221.97731,273.388975 216.072618,259.078414 216.099748,244.166421 C216.099748,213.150778 241.242989,188.007632 272.258632,188.007632 L371.119632,188.007632 C379.28704,188.480415 386.935401,192.166372 392.393842,198.260263 L474.869789,300.324632 L474.978789,300.325211 L474.952789,300.426632 L474.953158,300.427737 L474.951789,300.427632 L474.173714,303.448935 C446.939817,406.220475 353.906452,478.028529 247.319105,478.080211 C118.007789,478.080211 12.8157895,373.144526 12.8157895,244.166421 C12.8157895,115.188316 117.905263,10.2526316 247.319105,10.2526316 L330.391053,10.2526316 Z" />
5252
</g>
5353
</g>
5454
</svg>

src/components/NotificationRow.test.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ describe('components/NotificationRow.tsx', () => {
2222
it('should render itself & its children', async () => {
2323
jest
2424
.spyOn(global.Date, 'now')
25-
.mockImplementation(() => new Date('2014').valueOf());
25+
.mockImplementation(() => new Date('2024').valueOf());
2626

2727
const props = {
2828
notification: mockedSingleNotification,
@@ -34,7 +34,9 @@ describe('components/NotificationRow.tsx', () => {
3434
});
3535

3636
it('should render itself & its children without avatar', async () => {
37-
(global as any).Date.now = jest.fn(() => new Date('2024'));
37+
jest
38+
.spyOn(global.Date, 'now')
39+
.mockImplementation(() => new Date('2024').valueOf());
3840

3941
const mockNotification = mockedSingleNotification;
4042
mockNotification.subject.user = null;

src/components/NotificationRow.tsx

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,13 @@ import {
55
ReadIcon,
66
} from '@primer/octicons-react';
77
import { formatDistanceToNow, parseISO } from 'date-fns';
8-
import { type FC, type MouseEvent, useCallback, useContext } from 'react';
8+
import {
9+
type FC,
10+
type KeyboardEvent,
11+
type MouseEvent,
12+
useCallback,
13+
useContext,
14+
} from 'react';
915

1016
import { AppContext } from '../context/App';
1117
import type { Notification } from '../typesGithub';
@@ -55,7 +61,9 @@ export const NotificationRow: FC<IProps> = ({ notification, hostname }) => {
5561
unsubscribeNotification(notification.id, hostname);
5662
};
5763

58-
const openUserProfile = (event: MouseEvent<HTMLElement>) => {
64+
const openUserProfile = (
65+
event: MouseEvent<HTMLElement> | KeyboardEvent<HTMLElement>,
66+
) => {
5967
// Don't trigger onClick of parent element.
6068
event.stopPropagation();
6169

@@ -89,7 +97,11 @@ export const NotificationRow: FC<IProps> = ({ notification, hostname }) => {
8997
<NotificationIcon size={18} aria-label={notification.subject.type} />
9098
</div>
9199

92-
<div className="flex-1 overflow-hidden" onClick={() => pressTitle()}>
100+
<div
101+
className="flex-1 overflow-hidden"
102+
onClick={() => pressTitle()}
103+
onKeyDown={() => pressTitle()}
104+
>
93105
<div
94106
className="mb-1 text-sm whitespace-nowrap overflow-ellipsis overflow-hidden cursor-pointer"
95107
role="main"
@@ -102,11 +114,16 @@ export const NotificationRow: FC<IProps> = ({ notification, hostname }) => {
102114
<span className="flex items-center">
103115
<span title={updatedLabel} className="flex">
104116
{notification.subject.user ? (
105-
<span title="View User Profile" onClick={openUserProfile}>
117+
<span
118+
title="View User Profile"
119+
onClick={openUserProfile}
120+
onKeyDown={openUserProfile}
121+
>
106122
<img
107123
className="rounded-full w-4 h-4 cursor-pointer"
108124
src={notification.subject.user.avatar_url}
109125
title={notification.subject.user.login}
126+
alt={`${notification.subject.user.login}'s avatar`}
110127
/>
111128
</span>
112129
) : (
@@ -128,6 +145,7 @@ export const NotificationRow: FC<IProps> = ({ notification, hostname }) => {
128145

129146
<div className="flex justify-center items-center gap-2 opacity-0 group-hover:opacity-80 transition-opacity">
130147
<button
148+
type="button"
131149
className="focus:outline-none h-full hover:text-green-500"
132150
title="Mark as Done"
133151
onClick={() => markNotificationDone(notification.id, hostname)}
@@ -136,6 +154,7 @@ export const NotificationRow: FC<IProps> = ({ notification, hostname }) => {
136154
</button>
137155

138156
<button
157+
type="button"
139158
className="focus:outline-none h-full hover:text-red-500"
140159
title="Unsubscribe"
141160
onClick={unsubscribe}
@@ -144,6 +163,7 @@ export const NotificationRow: FC<IProps> = ({ notification, hostname }) => {
144163
</button>
145164

146165
<button
166+
type="button"
147167
className="focus:outline-none h-full hover:text-green-500"
148168
title="Mark as Read"
149169
onClick={() => markNotificationRead(notification.id, hostname)}

src/components/Repository.tsx

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,23 +38,33 @@ export const RepositoryNotifications: FC<IProps> = ({
3838
}, [repoNotifications, hostname]);
3939

4040
const avatarUrl = repoNotifications[0].repository.owner.avatar_url;
41+
const repoSlug = repoNotifications[0].repository.full_name;
4142

4243
return (
4344
<>
4445
<div className="flex py-2 px-3 bg-gray-100 dark:bg-gray-darker dark:text-white group">
4546
<div className="flex flex-1 space-x-3 items-center mt-0 text-sm font-medium overflow-hidden overflow-ellipsis whitespace-nowrap">
4647
{avatarUrl ? (
47-
<img className="rounded w-5 h-5" src={avatarUrl} />
48+
<img
49+
className="rounded w-5 h-5"
50+
src={avatarUrl}
51+
alt={`${repoSlug}'s avatar`}
52+
/>
4853
) : (
4954
<MarkGithubIcon size={18} />
5055
)}
51-
<span className="cursor-pointer" onClick={openBrowser}>
56+
<span
57+
className="cursor-pointer"
58+
onClick={openBrowser}
59+
onKeyDown={openBrowser}
60+
>
5261
{repoName}
5362
</span>
5463
</div>
5564

5665
<div className="flex justify-center items-center gap-2 opacity-0 group-hover:opacity-80 transition-opacity">
5766
<button
67+
type="button"
5868
className="focus:outline-none h-full hover:text-green-500"
5969
title="Mark Repository as Done"
6070
onClick={markRepoAsDone}
@@ -65,6 +75,7 @@ export const RepositoryNotifications: FC<IProps> = ({
6575
<div className="w-[14px]" />
6676

6777
<button
78+
type="button"
6879
className="focus:outline-none h-full hover:text-green-500"
6980
title="Mark Repository as Read"
7081
onClick={markRepoAsRead}

src/components/Sidebar.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export const Sidebar: FC = () => {
2828
}, []);
2929

3030
const onOpenGitHubNotifications = useCallback(() => {
31-
openExternalLink(`https://github.com/notifications`);
31+
openExternalLink('https://github.com/notifications');
3232
}, []);
3333

3434
const quitApp = useCallback(() => {
@@ -46,6 +46,7 @@ export const Sidebar: FC = () => {
4646
<div className="flex flex-col fixed left-14 w-14 -ml-14 h-full bg-gray-sidebar overflow-y-auto">
4747
<div className="flex flex-col flex-1 items-center py-4">
4848
<button
49+
type="button"
4950
className="w-5 my-3 mx-auto cursor-pointer outline-none"
5051
title="Open Gitify on GitHub"
5152
onClick={onOpenBrowser}
@@ -55,6 +56,7 @@ export const Sidebar: FC = () => {
5556
</button>
5657

5758
<button
59+
type="button"
5860
className={`flex justify-around self-stretch items-center my-1 py-1 px-2 text-xs font-extrabold cursor-pointer ${
5961
notificationsCount > 0 ? 'text-green-500' : 'text-white'
6062
}`}
@@ -73,6 +75,7 @@ export const Sidebar: FC = () => {
7375
{isLoggedIn && (
7476
<>
7577
<button
78+
type="button"
7679
className={sidebarButtonClasses}
7780
title="Refresh Notifications"
7881
onClick={() => {
@@ -89,6 +92,7 @@ export const Sidebar: FC = () => {
8992
</button>
9093

9194
<button
95+
type="button"
9296
className={sidebarButtonClasses}
9397
title="Settings"
9498
onClick={() => {
@@ -106,6 +110,7 @@ export const Sidebar: FC = () => {
106110

107111
{!isLoggedIn && (
108112
<button
113+
type="button"
109114
className={sidebarButtonClasses}
110115
title="Quit Gitify"
111116
aria-label="Quit Gitify"

src/components/__snapshots__/NotificationRow.test.tsx.snap

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ exports[`components/NotificationRow.tsx should render itself & its children 1`]
3737
<div
3838
className="flex-1 overflow-hidden"
3939
onClick={[Function]}
40+
onKeyDown={[Function]}
4041
>
4142
<div
4243
className="mb-1 text-sm whitespace-nowrap overflow-ellipsis overflow-hidden cursor-pointer"
@@ -53,13 +54,15 @@ exports[`components/NotificationRow.tsx should render itself & its children 1`]
5354
>
5455
<span
5556
className="flex"
56-
title="manosim updated in over 3 years"
57+
title="manosim updated over 6 years ago"
5758
>
5859
<span
5960
onClick={[Function]}
61+
onKeyDown={[Function]}
6062
title="View User Profile"
6163
>
6264
<img
65+
alt="manosim's avatar"
6366
className="rounded-full w-4 h-4 cursor-pointer"
6467
src="https://avatars0.githubusercontent.com/u/6333409?v=3"
6568
title="manosim"
@@ -74,7 +77,7 @@ exports[`components/NotificationRow.tsx should render itself & its children 1`]
7477
<span
7578
className="ml-1"
7679
>
77-
in over 3 years
80+
over 6 years ago
7881
</span>
7982
</span>
8083
</span>
@@ -87,6 +90,7 @@ exports[`components/NotificationRow.tsx should render itself & its children 1`]
8790
className="focus:outline-none h-full hover:text-green-500"
8891
onClick={[Function]}
8992
title="Mark as Done"
93+
type="button"
9094
>
9195
<svg
9296
aria-label="Mark as Done"
@@ -115,6 +119,7 @@ exports[`components/NotificationRow.tsx should render itself & its children 1`]
115119
className="focus:outline-none h-full hover:text-red-500"
116120
onClick={[Function]}
117121
title="Unsubscribe"
122+
type="button"
118123
>
119124
<svg
120125
aria-label="Unsubscribe"
@@ -143,6 +148,7 @@ exports[`components/NotificationRow.tsx should render itself & its children 1`]
143148
className="focus:outline-none h-full hover:text-green-500"
144149
onClick={[Function]}
145150
title="Mark as Read"
151+
type="button"
146152
>
147153
<svg
148154
aria-label="Mark as Read"
@@ -208,6 +214,7 @@ exports[`components/NotificationRow.tsx should render itself & its children with
208214
<div
209215
className="flex-1 overflow-hidden"
210216
onClick={[Function]}
217+
onKeyDown={[Function]}
211218
>
212219
<div
213220
className="mb-1 text-sm whitespace-nowrap overflow-ellipsis overflow-hidden cursor-pointer"
@@ -271,6 +278,7 @@ exports[`components/NotificationRow.tsx should render itself & its children with
271278
className="focus:outline-none h-full hover:text-green-500"
272279
onClick={[Function]}
273280
title="Mark as Done"
281+
type="button"
274282
>
275283
<svg
276284
aria-label="Mark as Done"
@@ -299,6 +307,7 @@ exports[`components/NotificationRow.tsx should render itself & its children with
299307
className="focus:outline-none h-full hover:text-red-500"
300308
onClick={[Function]}
301309
title="Unsubscribe"
310+
type="button"
302311
>
303312
<svg
304313
aria-label="Unsubscribe"
@@ -327,6 +336,7 @@ exports[`components/NotificationRow.tsx should render itself & its children with
327336
className="focus:outline-none h-full hover:text-green-500"
328337
onClick={[Function]}
329338
title="Mark as Read"
339+
type="button"
330340
>
331341
<svg
332342
aria-label="Mark as Read"

0 commit comments

Comments
 (0)