Repository: gitify-app/gitify
Pull request #1053 (2024-04-21 12:00:45)

refactor: use correct case for GitHub
🧼 Replace occurrences of `Github` with `GitHub`


Patch:
diff --git a/package.json b/package.json
index 5b6b2613..3ae53fb6 100644
--- a/package.json
+++ b/package.json
@@ -154,7 +154,7 @@
     "webpack-cli": "5.1.4",
     "webpack-merge": "5.10.0"
   },
-  "packageManager": "pnpm@9.0.4",
+  "packageManager": "pnpm@9.0.5",
   "lint-staged": {
     "*.{html,js,json,md,ts,tsx}": "biome format --write"
   }
diff --git a/src/__mocks__/mockedData.ts b/src/__mocks__/mockedData.ts
index 3db3691a..24428a97 100644
--- a/src/__mocks__/mockedData.ts
+++ b/src/__mocks__/mockedData.ts
@@ -10,7 +10,7 @@ import type {
   Notification,
   Repository,
   User,
-} from '../typesGithub';
+} from '../typesGitHub';
 import Constants from '../utils/constants';
 
 export const mockedEnterpriseAccounts: EnterpriseAccount[] = [
@@ -199,7 +199,7 @@ export const mockedSingleNotification: Notification = {
 
 // 2 Notifications
 // Repository : 'manosim/notifications-tests'
-export const mockedGithubNotifications = [
+export const mockedGitHubNotifications = [
   mockedSingleNotification,
   {
     id: '148827438',
@@ -366,7 +366,7 @@ export const mockedEnterpriseNotifications = [
 export const mockedAccountNotifications: AccountNotifications[] = [
   {
     hostname: 'github.com',
-    notifications: mockedGithubNotifications,
+    notifications: mockedGitHubNotifications,
   },
   {
     hostname: 'github.gitify.io',
diff --git a/src/__mocks__/partial-mocks.ts b/src/__mocks__/partial-mocks.ts
index e61e0d12..2c8b52b7 100644
--- a/src/__mocks__/partial-mocks.ts
+++ b/src/__mocks__/partial-mocks.ts
@@ -1,4 +1,4 @@
-import type { Notification, Subject, User } from '../typesGithub';
+import type { Notification, Subject, User } from '../typesGitHub';
 
 export function partialMockNotification(
   subject: Partial<Subject>,
diff --git a/src/components/AccountNotifications.tsx b/src/components/AccountNotifications.tsx
index 4c94bac0..b6a09e6b 100644
--- a/src/components/AccountNotifications.tsx
+++ b/src/components/AccountNotifications.tsx
@@ -1,6 +1,6 @@
 import { ChevronDownIcon, ChevronLeftIcon } from '@primer/octicons-react';
 
-import type { Notification } from '../typesGithub';
+import type { Notification } from '../typesGitHub';
 import { RepositoryNotifications } from './Repository';
 
 interface IProps {
diff --git a/src/components/NotificationRow.tsx b/src/components/NotificationRow.tsx
index 517b5d7f..81ce5d99 100644
--- a/src/components/NotificationRow.tsx
+++ b/src/components/NotificationRow.tsx
@@ -14,7 +14,7 @@ import {
 } from 'react';
 
 import { AppContext } from '../context/App';
-import type { Notification } from '../typesGithub';
+import type { Notification } from '../typesGitHub';
 import { openExternalLink } from '../utils/comms';
 import { formatForDisplay, openInBrowser } from '../utils/helpers';
 import {
diff --git a/src/components/Repository.tsx b/src/components/Repository.tsx
index 28bef678..0d68875f 100644
--- a/src/components/Repository.tsx
+++ b/src/components/Repository.tsx
@@ -4,7 +4,7 @@ import { type FC, useCallback, useContext } from 'react';
 import { CSSTransition, TransitionGroup } from 'react-transition-group';
 
 import { AppContext } from '../context/App';
-import type { Notification } from '../typesGithub';
+import type { Notification } from '../typesGitHub';
 import { openExternalLink } from '../utils/comms';
 import { NotificationRow } from './NotificationRow';
 
diff --git a/src/hooks/useNotifications.ts b/src/hooks/useNotifications.ts
index 112b6db1..c3a1053d 100644
--- a/src/hooks/useNotifications.ts
+++ b/src/hooks/useNotifications.ts
@@ -7,7 +7,7 @@ import type {
   GitifyError,
   SettingsState,
 } from '../types';
-import type { GithubRESTError, Notification } from '../typesGithub';
+import type { GitHubRESTError, Notification } from '../typesGitHub';
 import { apiRequestAuth } from '../utils/api-requests';
 import { determineFailureType } from '../utils/api/errors';
 import Constants from '../utils/constants';
@@ -74,7 +74,10 @@ export const useNotifications = (): NotificationsState => {
 
   const fetchNotifications = useCallback(
     async (accounts: AuthState, settings: SettingsState) => {
-      function getNotifications(hostname: string, token: string): AxiosPromise {
+      function getNotifications(
+        hostname: string,
+        token: string,
+      ): AxiosPromise<Notification[]> {
         const endpointSuffix = `notifications?participating=${settings.participating}`;
         const url = `${generateGitHubAPIUrl(hostname)}${endpointSuffix}`;
         return apiRequestAuth(url, 'GET', token);
@@ -198,7 +201,7 @@ export const useNotifications = (): NotificationsState => {
               });
           }),
         )
-        .catch((err: AxiosError<GithubRESTError>) => {
+        .catch((err: AxiosError<GitHubRESTError>) => {
           setIsFetching(false);
           setRequestFailed(true);
           setErrorDetails(determineFailureType(err));
diff --git a/src/types.ts b/src/types.ts
index fb4f00fb..fde42cc5 100644
--- a/src/types.ts
+++ b/src/types.ts
@@ -1,4 +1,4 @@
-import type { Notification } from './typesGithub';
+import type { Notification } from './typesGitHub';
 
 export interface AuthState {
   token?: string;
diff --git a/src/typesGithub.ts b/src/typesGitHub.ts
similarity index 99%
rename from src/typesGithub.ts
rename to src/typesGitHub.ts
index 0a462d6a..a48fd0f2 100644
--- a/src/typesGithub.ts
+++ b/src/typesGitHub.ts
@@ -440,7 +440,7 @@ export interface WorkflowRunAttributes {
   status: CheckSuiteStatus | null;
 }
 
-export interface GithubRESTError {
+export interface GitHubRESTError {
   message: string;
   documentation_url: string;
 }
diff --git a/src/utils/api/errors.ts b/src/utils/api/errors.ts
index 2c69b2a5..7202d567 100644
--- a/src/utils/api/errors.ts
+++ b/src/utils/api/errors.ts
@@ -1,10 +1,10 @@
 import { AxiosError } from 'axios';
 import type { GitifyError } from '../../types';
-import type { GithubRESTError } from '../../typesGithub';
+import type { GitHubRESTError } from '../../typesGitHub';
 import { Errors } from '../constants';
 
 export function determineFailureType(
-  err: AxiosError<GithubRESTError>,
+  err: AxiosError<GitHubRESTError>,
 ): GitifyError {
   const code = err.code;
 
diff --git a/src/utils/auth.ts b/src/utils/auth.ts
index 68fd9e5b..61b9b4d6 100644
--- a/src/utils/auth.ts
+++ b/src/utils/auth.ts
@@ -6,7 +6,7 @@ import type {
   AuthTokenResponse,
   GitifyUser,
 } from '../types';
-import type { UserDetails } from '../typesGithub';
+import type { UserDetails } from '../typesGitHub';
 import { apiRequest, apiRequestAuth } from '../utils/api-requests';
 import { Constants } from '../utils/constants';
 import { generateGitHubAPIUrl, isEnterpriseHost } from './helpers';
@@ -44,7 +44,7 @@ export const authGitHub = (
       } else if (error) {
         reject(
           "Oops! Something went wrong and we couldn't " +
-            'log you in using Github. Please try again.',
+            'log you in using GitHub. Please try again.',
         );
       }
     };
diff --git a/src/utils/helpers.ts b/src/utils/helpers.ts
index 814023fa..3ad166fe 100644
--- a/src/utils/helpers.ts
+++ b/src/utils/helpers.ts
@@ -7,7 +7,7 @@ import type {
   IssueComments,
   Notification,
   PullRequest,
-} from '../typesGithub';
+} from '../typesGitHub';
 import { apiRequestAuth } from '../utils/api-requests';
 import { openExternalLink } from '../utils/comms';
 import { Constants } from './constants';
diff --git a/src/utils/icons.ts b/src/utils/icons.ts
index a7cef5e0..60942145 100644
--- a/src/utils/icons.ts
+++ b/src/utils/icons.ts
@@ -25,7 +25,7 @@ import {
 } from '@primer/octicons-react';
 import type { FC } from 'react';
 import { IconColor } from '../types';
-import type { Subject } from '../typesGithub';
+import type { Subject } from '../typesGitHub';
 
 export function getNotificationTypeIcon(subject: Subject): FC<OcticonProps> {
   switch (subject.type) {
diff --git a/src/utils/notifications.ts b/src/utils/notifications.ts
index 0e1004de..589f8198 100644
--- a/src/utils/notifications.ts
+++ b/src/utils/notifications.ts
@@ -1,5 +1,5 @@
 import { ipcRenderer } from 'electron';
-import { Notification } from '../typesGithub';
+import { Notification } from '../typesGitHub';
 import { openInBrowser } from '../utils/helpers';
 import { updateTrayIcon } from './comms';
 
diff --git a/src/utils/reason.ts b/src/utils/reason.ts
index 1eab5491..f8486ec0 100644
--- a/src/utils/reason.ts
+++ b/src/utils/reason.ts
@@ -1,5 +1,5 @@
 import type { FormattedReason } from '../types';
-import type { Reason } from '../typesGithub';
+import type { Reason } from '../typesGitHub';
 
 const FORMATTED_REASONS: Record<Reason, FormattedReason> = {
   approval_requested: {
diff --git a/src/utils/subject.ts b/src/utils/subject.ts
index 2eda8469..469ea3b9 100644
--- a/src/utils/subject.ts
+++ b/src/utils/subject.ts
@@ -13,7 +13,7 @@ import type {
   SubjectUser,
   User,
   WorkflowRunAttributes,
-} from '../typesGithub';
+} from '../typesGitHub';
 import { apiRequestAuth } from './api-requests';
 import { fetchDiscussion, getLatestDiscussionComment } from './helpers';
 


Test patch:
diff --git a/src/components/AccountNotifications.test.tsx b/src/components/AccountNotifications.test.tsx
index 69f86c8b..b18ffa47 100644
--- a/src/components/AccountNotifications.test.tsx
+++ b/src/components/AccountNotifications.test.tsx
@@ -1,6 +1,6 @@
 import TestRenderer from 'react-test-renderer';
 
-import { mockedGithubNotifications } from '../__mocks__/mockedData';
+import { mockedGitHubNotifications } from '../__mocks__/mockedData';
 import { AccountNotifications } from './AccountNotifications';
 
 jest.mock('./Repository', () => ({
@@ -11,7 +11,7 @@ describe('components/AccountNotifications.tsx', () => {
   it('should render itself (github.com with notifications)', () => {
     const props = {
       hostname: 'github.com',
-      notifications: mockedGithubNotifications,
+      notifications: mockedGitHubNotifications,
       showAccountHostname: true,
     };
 
diff --git a/src/components/Repository.test.tsx b/src/components/Repository.test.tsx
index a2e5d877..e7d15412 100644
--- a/src/components/Repository.test.tsx
+++ b/src/components/Repository.test.tsx
@@ -1,6 +1,6 @@
 import { fireEvent, render, screen } from '@testing-library/react';
 import TestRenderer from 'react-test-renderer';
-import { mockedGithubNotifications } from '../__mocks__/mockedData';
+import { mockedGitHubNotifications } from '../__mocks__/mockedData';
 import { AppContext } from '../context/App';
 import { RepositoryNotifications } from './Repository';
 const { shell } = require('electron');
@@ -16,7 +16,7 @@ describe('components/Repository.tsx', () => {
   const props = {
     hostname: 'github.com',
     repoName: 'manosim/gitify',
-    repoNotifications: mockedGithubNotifications,
+    repoNotifications: mockedGitHubNotifications,
   };
 
   beforeEach(() => {
diff --git a/src/utils/api/errors.test.ts b/src/utils/api/errors.test.ts
index dd7d9a32..240eea26 100644
--- a/src/utils/api/errors.test.ts
+++ b/src/utils/api/errors.test.ts
@@ -1,16 +1,16 @@
 import { AxiosError, type AxiosResponse } from 'axios';
-import type { GithubRESTError } from '../../typesGithub';
+import type { GitHubRESTError } from '../../typesGitHub';
 import { Errors } from '../constants';
 import { determineFailureType } from './errors';
 
 describe('utils/api/errors.ts', () => {
   it('network error', async () => {
-    const mockError: Partial<AxiosError<GithubRESTError>> = {
+    const mockError: Partial<AxiosError<GitHubRESTError>> = {
       code: AxiosError.ERR_NETWORK,
     };
 
     const result = determineFailureType(
-      mockError as AxiosError<GithubRESTError>,
+      mockError as AxiosError<GitHubRESTError>,
     );
 
     expect(result).toBe(Errors.NETWORK);
@@ -18,49 +18,49 @@ describe('utils/api/errors.ts', () => {
 
   describe('bad request errors', () => {
     it('bad credentials', async () => {
-      const mockError: Partial<AxiosError<GithubRESTError>> = {
+      const mockError: Partial<AxiosError<GitHubRESTError>> = {
         code: AxiosError.ERR_BAD_REQUEST,
         status: 401,
         response: createMockResponse(401, 'Bad credentials'),
       };
 
       const result = determineFailureType(
-        mockError as AxiosError<GithubRESTError>,
+        mockError as AxiosError<GitHubRESTError>,
       );
 
       expect(result).toBe(Errors.BAD_CREDENTIALS);
     });
 
     it('missing scopes', async () => {
-      const mockError: Partial<AxiosError<GithubRESTError>> = {
+      const mockError: Partial<AxiosError<GitHubRESTError>> = {
         code: AxiosError.ERR_BAD_REQUEST,
         status: 403,
         response: createMockResponse(403, "Missing the 'notifications' scope"),
       };
 
       const result = determineFailureType(
-        mockError as AxiosError<GithubRESTError>,
+        mockError as AxiosError<GitHubRESTError>,
       );
 
       expect(result).toBe(Errors.MISSING_SCOPES);
     });
 
     it('rate limited - primary', async () => {
-      const mockError: Partial<AxiosError<GithubRESTError>> = {
+      const mockError: Partial<AxiosError<GitHubRESTError>> = {
         code: AxiosError.ERR_BAD_REQUEST,
         status: 403,
         response: createMockResponse(403, 'API rate limit exceeded'),
       };
 
       const result = determineFailureType(
-        mockError as AxiosError<GithubRESTError>,
+        mockError as AxiosError<GitHubRESTError>,
       );
 
       expect(result).toBe(Errors.RATE_LIMITED);
     });
 
     it('rate limited - secondary', async () => {
-      const mockError: Partial<AxiosError<GithubRESTError>> = {
+      const mockError: Partial<AxiosError<GitHubRESTError>> = {
         code: AxiosError.ERR_BAD_REQUEST,
         status: 403,
         response: createMockResponse(
@@ -70,21 +70,21 @@ describe('utils/api/errors.ts', () => {
       };
 
       const result = determineFailureType(
-        mockError as AxiosError<GithubRESTError>,
+        mockError as AxiosError<GitHubRESTError>,
       );
 
       expect(result).toBe(Errors.RATE_LIMITED);
     });
 
     it('unhandled bad request error', async () => {
-      const mockError: Partial<AxiosError<GithubRESTError>> = {
+      const mockError: Partial<AxiosError<GitHubRESTError>> = {
         code: AxiosError.ERR_BAD_REQUEST,
         status: 400,
         response: createMockResponse(403, 'Oops! Something went wrong.'),
       };
 
       const result = determineFailureType(
-        mockError as AxiosError<GithubRESTError>,
+        mockError as AxiosError<GitHubRESTError>,
       );
 
       expect(result).toBe(Errors.UNKNOWN);
@@ -92,12 +92,12 @@ describe('utils/api/errors.ts', () => {
   });
 
   it('unknown error', async () => {
-    const mockError: Partial<AxiosError<GithubRESTError>> = {
+    const mockError: Partial<AxiosError<GitHubRESTError>> = {
       code: 'anything',
     };
 
     const result = determineFailureType(
-      mockError as AxiosError<GithubRESTError>,
+      mockError as AxiosError<GitHubRESTError>,
     );
 
     expect(result).toBe(Errors.UNKNOWN);
@@ -107,7 +107,7 @@ describe('utils/api/errors.ts', () => {
 function createMockResponse(
   status: number,
   message: string,
-): AxiosResponse<GithubRESTError> {
+): AxiosResponse<GitHubRESTError> {
   return {
     data: {
       message,
diff --git a/src/utils/auth.test.ts b/src/utils/auth.test.ts
index 0365677f..fc80b045 100644
--- a/src/utils/auth.test.ts
+++ b/src/utils/auth.test.ts
@@ -15,7 +15,7 @@ describe('utils/auth.tsx', () => {
       loadURLMock.mockReset();
     });
 
-    it('should call authGithub - success', async () => {
+    it('should call authGitHub - success', async () => {
       // Casting to jest.Mock avoids Typescript errors, where the spy is expected to match all the original
       // function's typing. I might fix all that if the return type of this was actually used, or if I was
       // writing this test for a new feature. Since I'm just upgrading Jest, jest.Mock is a nice escape hatch
@@ -44,7 +44,7 @@ describe('utils/auth.tsx', () => {
       expect(browserWindow.destroy).toHaveBeenCalledTimes(1);
     });
 
-    it('should call authGithub - failure', async () => {
+    it('should call authGitHub - failure', async () => {
       (
         jest.spyOn(browserWindow.webContents, 'on') as jest.Mock
       ).mockImplementation((event, callback): void => {
@@ -55,7 +55,7 @@ describe('utils/auth.tsx', () => {
       });
 
       await expect(async () => await auth.authGitHub()).rejects.toEqual(
-        "Oops! Something went wrong and we couldn't log you in using Github. Please try again.",
+        "Oops! Something went wrong and we couldn't log you in using GitHub. Please try again.",
       );
       expect(loadURLMock).toHaveBeenCalledTimes(1);
     });
diff --git a/src/utils/helpers.test.ts b/src/utils/helpers.test.ts
index b4019e3f..4fa85c67 100644
--- a/src/utils/helpers.test.ts
+++ b/src/utils/helpers.test.ts
@@ -5,7 +5,7 @@ import {
   mockedSingleNotification,
   mockedUser,
 } from '../__mocks__/mockedData';
-import type { SubjectType } from '../typesGithub';
+import type { SubjectType } from '../typesGitHub';
 import * as apiRequests from './api-requests';
 import {
   addHours,
diff --git a/src/utils/icons.test.ts b/src/utils/icons.test.ts
index f80e600a..15fb3565 100644
--- a/src/utils/icons.test.ts
+++ b/src/utils/icons.test.ts
@@ -1,4 +1,4 @@
-import type { StateType, Subject, SubjectType } from '../typesGithub';
+import type { StateType, Subject, SubjectType } from '../typesGitHub';
 import { getNotificationTypeIcon, getNotificationTypeIconColor } from './icons';
 
 describe('utils/icons.ts', () => {
diff --git a/src/utils/notifications.test.ts b/src/utils/notifications.test.ts
index eba59266..d6c408db 100644
--- a/src/utils/notifications.test.ts
+++ b/src/utils/notifications.test.ts
@@ -3,7 +3,7 @@ import { ipcRenderer } from 'electron';
 import { mockAccounts } from '../__mocks__/mock-state';
 import {
   mockedAccountNotifications,
-  mockedGithubNotifications,
+  mockedGitHubNotifications,
   mockedSingleAccountNotifications,
 } from '../__mocks__/mockedData';
 import { defaultSettings } from '../context/App';
@@ -109,14 +109,14 @@ describe('utils/notifications.ts', () => {
 
     const nativeNotification: Notification =
       notificationsHelpers.raiseNativeNotification(
-        [mockedGithubNotifications[0]],
+        [mockedGitHubNotifications[0]],
         mockAccounts,
       );
     nativeNotification.onclick(null);
 
     expect(helpers.openInBrowser).toHaveBeenCalledTimes(1);
     expect(helpers.openInBrowser).toHaveBeenLastCalledWith(
-      mockedGithubNotifications[0],
+      mockedGitHubNotifications[0],
       mockAccounts,
     );
     expect(ipcRenderer.send).toHaveBeenCalledWith('hide-window');
@@ -124,7 +124,7 @@ describe('utils/notifications.ts', () => {
 
   it('should click on a native notification (with more than 1 notification)', () => {
     const nativeNotification = notificationsHelpers.raiseNativeNotification(
-      mockedGithubNotifications,
+      mockedGitHubNotifications,
       mockAccounts,
     );
     nativeNotification.onclick(null);
diff --git a/src/utils/reason.test.ts b/src/utils/reason.test.ts
index 10ed1c50..8d765a8f 100644
--- a/src/utils/reason.test.ts
+++ b/src/utils/reason.test.ts
@@ -1,4 +1,4 @@
-import type { Reason } from '../typesGithub';
+import type { Reason } from '../typesGitHub';
 import { formatReason } from './reason';
 
 describe('utils/reason.ts', () => {
diff --git a/src/utils/subject.test.ts b/src/utils/subject.test.ts
index 8a26b8b7..3270cf83 100644
--- a/src/utils/subject.test.ts
+++ b/src/utils/subject.test.ts
@@ -13,7 +13,7 @@ import type {
   Notification,
   Repository,
   ViewerSubscription,
-} from '../typesGithub';
+} from '../typesGitHub';
 import {
   getCheckSuiteAttributes,
   getGitifySubjectDetails,