Skip to content

Commit 4451419

Browse files
committed
fix: sonarlint issues
Signed-off-by: Adam Setch <[email protected]>
1 parent 5943dab commit 4451419

File tree

10 files changed

+19
-19
lines changed

10 files changed

+19
-19
lines changed

src/renderer/components/filters/TokenSearchInput.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ interface TokenSearchInputProps {
1919
onRemove: (token: SearchToken) => void;
2020
}
2121

22-
const INPUT_KEY_EVENTS = ['Enter', 'Tab', ' ', ','];
22+
const INPUT_KEY_EVENTS: Set<string> = new Set(['Enter', 'Tab', ' ', ',']);
2323

2424
export const TokenSearchInput: FC<TokenSearchInputProps> = ({
2525
label,
@@ -51,7 +51,7 @@ export const TokenSearchInput: FC<TokenSearchInputProps> = ({
5151
}
5252

5353
function onKeyDown(e: React.KeyboardEvent<HTMLInputElement>) {
54-
if (INPUT_KEY_EVENTS.includes(e.key)) {
54+
if (INPUT_KEY_EVENTS.has(e.key)) {
5555
tryAddToken(e);
5656
setShowSuggestions(false);
5757
} else if (e.key === 'ArrowDown') {

src/renderer/components/metrics/MetricPill.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,15 @@ import { Label, Stack, Text } from '@primer/react';
66
import { type IconColor, Size } from '../../types';
77

88
export interface IMetricPill {
9-
key?: string;
109
title: string;
1110
metric?: number;
1211
icon: Icon;
1312
color: IconColor;
1413
}
1514

1615
export const MetricPill: FC<IMetricPill> = (props: IMetricPill) => {
16+
const Icon = props.icon;
17+
1718
return (
1819
<Label
1920
className="hover:bg-gitify-notification-pill-hover"
@@ -22,7 +23,7 @@ export const MetricPill: FC<IMetricPill> = (props: IMetricPill) => {
2223
variant="secondary"
2324
>
2425
<Stack align="center" direction="horizontal" gap="none">
25-
<props.icon className={props.color} size={Size.XSMALL} />
26+
<Icon className={props.color} size={Size.XSMALL} />
2627
{props.metric ? (
2728
<Text className="text-xxs px-1">{props.metric}</Text>
2829
) : null}

src/renderer/components/settings/AppearanceSettings.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ export const AppearanceSettings: FC = () => {
5959
<FieldLabel label="Theme:" name="theme" />
6060
<Select
6161
data-testid="settings-theme"
62-
id="theme"
6362
onChange={(evt) =>
6463
updateSetting('theme', evt.target.value as Theme)
6564
}

src/renderer/routes/__snapshots__/Settings.test.tsx.snap

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/renderer/utils/helpers.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ export function actionsURL(repositoryURL: string, filters: string[]): Link {
7777
}
7878

7979
// Note: the GitHub Actions UI cannot handle encoded '+' characters.
80-
return url.toString().replace(/%2B/g, '+') as Link;
80+
return url.toString().replaceAll('%2B', '+') as Link;
8181
}
8282

8383
async function getDiscussionUrl(notification: Notification): Promise<Link> {

src/renderer/utils/notifications/handlers/pullRequest.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,13 +139,13 @@ export async function getLatestReviewForReviewers(
139139
(review) => review.state === prReview.state,
140140
);
141141

142-
if (!reviewerFound) {
142+
if (reviewerFound) {
143+
reviewerFound.users.push(prReview.user.login);
144+
} else {
143145
reviewers.push({
144146
state: prReview.state,
145147
users: [prReview.user.login],
146148
});
147-
} else {
148-
reviewerFound.users.push(prReview.user.login);
149149
}
150150
}
151151

src/renderer/utils/notifications/native.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,13 @@ export const triggerNativeNotifications = (
2222
return accountNotifications.notifications;
2323
}
2424

25-
const accountPreviousNotificationsIds =
26-
accountPreviousNotifications.notifications.map((item) => item.id);
25+
const accountPreviousNotificationsIds = new Set<string>(
26+
accountPreviousNotifications.notifications.map((item) => item.id),
27+
);
2728

2829
const accountNewNotifications = accountNotifications.notifications.filter(
2930
(item) => {
30-
return !accountPreviousNotificationsIds.includes(`${item.id}`);
31+
return !accountPreviousNotificationsIds.has(`${item.id}`);
3132
},
3233
);
3334

src/renderer/utils/notifications/notifications.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ function getNotifications(state: GitifyState) {
4242
export async function getAllNotifications(
4343
state: GitifyState,
4444
): Promise<AccountNotifications[]> {
45-
const responses = await Promise.all([...getNotifications(state)]);
45+
const responses = await Promise.all(getNotifications(state));
4646

4747
const notifications: AccountNotifications[] = await Promise.all(
4848
responses

src/renderer/utils/notifications/remove.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ export function removeNotifications(
1616
}
1717

1818
const removeNotificationAccount = notificationsToRemove[0].account;
19-
const removeNotificationIDs = notificationsToRemove.map(
20-
(notification) => notification.id,
19+
const removeNotificationIDs = new Set<string>(
20+
notificationsToRemove.map((notification) => notification.id),
2121
);
2222

2323
const accountIndex = allNotifications.findIndex(
@@ -31,7 +31,7 @@ export function removeNotifications(
3131
updatedNotifications[accountIndex] = {
3232
...updatedNotifications[accountIndex],
3333
notifications: updatedNotifications[accountIndex].notifications.filter(
34-
(notification) => !removeNotificationIDs.includes(notification.id),
34+
(notification) => !removeNotificationIDs.has(notification.id),
3535
),
3636
};
3737
return updatedNotifications;

src/renderer/utils/zoom.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const MULTIPLIER = 2;
77
* @returns zoomLevel -2 to 0.5
88
*/
99
export const zoomPercentageToLevel = (percentage: number): number => {
10-
if (typeof percentage === 'undefined') {
10+
if (percentage === undefined) {
1111
return 0;
1212
}
1313

@@ -20,7 +20,7 @@ export const zoomPercentageToLevel = (percentage: number): number => {
2020
* @returns percentage 0-150
2121
*/
2222
export const zoomLevelToPercentage = (zoom: number): number => {
23-
if (typeof zoom === 'undefined') {
23+
if (zoom === undefined) {
2424
return 100;
2525
}
2626

0 commit comments

Comments
 (0)