Skip to content

Commit 57b6982

Browse files
committed
chore: improve jsdocs
Signed-off-by: Adam Setch <adam.setch@outlook.com>
1 parent c68eff9 commit 57b6982

6 files changed

Lines changed: 72 additions & 6 deletions

File tree

src/renderer/types.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -421,13 +421,12 @@ export type GitifyCheckSuiteStatus =
421421
| 'WAITING';
422422

423423
/**
424-
*
425424
* Gitify Type Enhancements
426425
*
427426
* These types represent the clean, UI-focused notification structure
428-
* used throughout the application. Raw GitHub API responses are
429-
* transformed into these types at the API boundary.
427+
* used throughout the application.
430428
*
429+
* Raw GitHub API responses are transformed into these types at the API boundary.
431430
**/
432431

433432
// Stronger typings for string literal attributes

src/shared/events.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@ import { APPLICATION } from './constants';
22

33
const P = APPLICATION.EVENT_PREFIX;
44

5+
/**
6+
* IPC event name constants for all Electron main ↔ renderer communication channels.
7+
* Each value is prefixed with `APPLICATION.EVENT_PREFIX` to prevent collisions.
8+
*/
59
export const EVENTS = {
610
AUTH_CALLBACK: `${P}auth-callback`,
711
QUIT: `${P}quit`,
@@ -23,23 +27,28 @@ export const EVENTS = {
2327
TWEMOJI_DIRECTORY: `${P}twemoji-directory`,
2428
} as const;
2529

30+
/** Union type of all valid IPC event name strings. */
2631
export type EventType = (typeof EVENTS)[keyof typeof EVENTS];
2732

33+
/** Payload for the `UPDATE_AUTO_LAUNCH` event. */
2834
export interface IAutoLaunch {
2935
openAtLogin: boolean;
3036
openAsHidden: boolean;
3137
}
3238

39+
/** Payload for the `UPDATE_KEYBOARD_SHORTCUT` event. */
3340
export interface IKeyboardShortcut {
3441
enabled: boolean;
3542
keyboardShortcut: string;
3643
}
3744

45+
/** Payload for the `OPEN_EXTERNAL` event. */
3846
export interface IOpenExternal {
3947
url: string;
4048
activate: boolean;
4149
}
4250

51+
/** Union of all possible IPC event payload types. */
4352
export type EventData =
4453
| string
4554
| number

src/shared/logger.test.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,21 @@ describe('shared/logger.ts', () => {
1212
describe('logInfo', () => {
1313
it('logs info without contexts', () => {
1414
logInfo('foo', 'bar');
15+
1516
expect(logInfoSpy).toHaveBeenCalledTimes(1);
1617
expect(logInfoSpy).toHaveBeenCalledWith('[foo]', 'bar');
1718
});
1819

1920
it('logs info with single context', () => {
2021
logInfo('foo', 'bar', ['ctx']);
22+
2123
expect(logInfoSpy).toHaveBeenCalledTimes(1);
2224
expect(logInfoSpy).toHaveBeenCalledWith('[foo]', 'bar', '[ctx]');
2325
});
2426

2527
it('logs info with multiple contexts', () => {
2628
logInfo('foo', 'bar', ['ctx1', 'ctx2']);
29+
2730
expect(logInfoSpy).toHaveBeenCalledTimes(1);
2831
expect(logInfoSpy).toHaveBeenCalledWith('[foo]', 'bar', '[ctx1 >> ctx2]');
2932
});
@@ -32,18 +35,21 @@ describe('shared/logger.ts', () => {
3235
describe('logWarn', () => {
3336
it('logs warn without contexts', () => {
3437
logWarn('foo', 'bar');
38+
3539
expect(logWarnSpy).toHaveBeenCalledTimes(1);
3640
expect(logWarnSpy).toHaveBeenCalledWith('[foo]', 'bar');
3741
});
3842

3943
it('logs warn with single context', () => {
4044
logWarn('foo', 'bar', ['ctx']);
45+
4146
expect(logWarnSpy).toHaveBeenCalledTimes(1);
4247
expect(logWarnSpy).toHaveBeenCalledWith('[foo]', 'bar', '[ctx]');
4348
});
4449

4550
it('logs warn with multiple contexts', () => {
4651
logWarn('foo', 'bar', ['ctx1', 'ctx2']);
52+
4753
expect(logWarnSpy).toHaveBeenCalledTimes(1);
4854
expect(logWarnSpy).toHaveBeenCalledWith('[foo]', 'bar', '[ctx1 >> ctx2]');
4955
});
@@ -52,12 +58,14 @@ describe('shared/logger.ts', () => {
5258
describe('logError', () => {
5359
it('logs error without contexts', () => {
5460
logError('foo', 'bar', mockError);
61+
5562
expect(logErrorSpy).toHaveBeenCalledTimes(1);
5663
expect(logErrorSpy).toHaveBeenCalledWith('[foo]', 'bar', mockError);
5764
});
5865

5966
it('logs error with single context', () => {
6067
logError('foo', 'bar', mockError, ['ctx']);
68+
6169
expect(logErrorSpy).toHaveBeenCalledTimes(1);
6270
expect(logErrorSpy).toHaveBeenCalledWith(
6371
'[foo]',
@@ -69,6 +77,7 @@ describe('shared/logger.ts', () => {
6977

7078
it('logs error with multiple contexts', () => {
7179
logError('foo', 'bar', mockError, ['ctx1', 'ctx2']);
80+
7281
expect(logErrorSpy).toHaveBeenCalledTimes(1);
7382
expect(logErrorSpy).toHaveBeenCalledWith(
7483
'[foo]',

src/shared/logger.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@ import log from 'electron-log';
22

33
type AllowedLogFunction = typeof log.info | typeof log.warn | typeof log.error;
44

5+
/**
6+
* Logs an informational message via electron-log.
7+
*
8+
* @param type - A short label identifying the caller or module (e.g. `'getAllNotifications'`).
9+
* @param message - The log message.
10+
* @param contexts - Optional array of context strings appended to the log entry.
11+
*/
512
export function logInfo(
613
type: string,
714
message: string,
@@ -10,6 +17,13 @@ export function logInfo(
1017
logMessage(log.info, type, message, undefined, contexts);
1118
}
1219

20+
/**
21+
* Logs a warning message via electron-log.
22+
*
23+
* @param type - A short label identifying the caller or module.
24+
* @param message - The warning message.
25+
* @param contexts - Optional array of context strings appended to the log entry.
26+
*/
1327
export function logWarn(
1428
type: string,
1529
message: string,
@@ -18,6 +32,14 @@ export function logWarn(
1832
logMessage(log.warn, type, message, undefined, contexts);
1933
}
2034

35+
/**
36+
* Logs an error message via electron-log.
37+
*
38+
* @param type - A short label identifying the caller or module.
39+
* @param message - A description of the error context.
40+
* @param err - The error object that was caught.
41+
* @param contexts - Optional array of context strings appended to the log entry.
42+
*/
2143
export function logError(
2244
type: string,
2345
message: string,

src/shared/platform.test.ts

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,28 +9,40 @@ describe('shared/platform.ts', () => {
99
});
1010
}
1111

12-
afterEach(() => {
12+
afterAll(() => {
1313
mockPlatform(originalPlatform as NodeJS.Platform);
1414
});
1515

1616
it('isLinux returns true only for linux', () => {
1717
mockPlatform('linux');
1818
expect(isLinux()).toBe(true);
19+
1920
mockPlatform('darwin');
2021
expect(isLinux()).toBe(false);
22+
23+
mockPlatform('win32');
24+
expect(isLinux()).toBe(false);
2125
});
2226

2327
it('isMacOS returns true only for darwin', () => {
28+
mockPlatform('linux');
29+
expect(isMacOS()).toBe(false);
30+
2431
mockPlatform('darwin');
2532
expect(isMacOS()).toBe(true);
33+
2634
mockPlatform('win32');
2735
expect(isMacOS()).toBe(false);
2836
});
2937

3038
it('isWindows returns true only for win32', () => {
31-
mockPlatform('win32');
32-
expect(isWindows()).toBe(true);
3339
mockPlatform('linux');
3440
expect(isWindows()).toBe(false);
41+
42+
mockPlatform('darwin');
43+
expect(isWindows()).toBe(false);
44+
45+
mockPlatform('win32');
46+
expect(isWindows()).toBe(true);
3547
});
3648
});

src/shared/platform.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,26 @@
1+
/**
2+
* Returns `true` if the current operating system is Linux.
3+
*
4+
* @returns `true` on Linux, `false` otherwise.
5+
*/
16
export function isLinux(): boolean {
27
return process.platform === 'linux';
38
}
49

10+
/**
11+
* Returns `true` if the current operating system is macOS.
12+
*
13+
* @returns `true` on macOS, `false` otherwise.
14+
*/
515
export function isMacOS(): boolean {
616
return process.platform === 'darwin';
717
}
818

19+
/**
20+
* Returns `true` if the current operating system is Windows.
21+
*
22+
* @returns `true` on Windows, `false` otherwise.
23+
*/
924
export function isWindows(): boolean {
1025
return process.platform === 'win32';
1126
}

0 commit comments

Comments
 (0)