Skip to content

Commit 13c7aa6

Browse files
committed
refactor: formatLicense to return undefined instead of null
1 parent cf1f47e commit 13c7aa6

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

src/utils/package.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ describe('formatLicense', (): void => {
1313
});
1414

1515
test('should check license field for other value', (): void => {
16-
expect(formatLicense(null)).toBeNull();
17-
expect(formatLicense({})).toBeNull();
18-
expect(formatLicense([])).toBeNull();
16+
expect(formatLicense(null)).toBeUndefined();
17+
expect(formatLicense({})).toBeUndefined();
18+
expect(formatLicense([])).toBeUndefined();
1919
});
2020
});
2121

src/utils/package.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export const TIMEFORMAT = 'DD.MM.YYYY, HH:mm:ss';
1212
*/
1313
// License should use type License defined above, but conflicts with the unit test that provide array or empty object
1414
/* eslint-disable @typescript-eslint/no-explicit-any */
15-
export function formatLicense(license: any): string | null {
15+
export function formatLicense(license: any): string | undefined {
1616
if (isString(license)) {
1717
return license;
1818
}
@@ -21,7 +21,7 @@ export function formatLicense(license: any): string | null {
2121
return license.type;
2222
}
2323

24-
return null;
24+
return;
2525
}
2626

2727
export interface Repository {

types/packageMeta.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export interface PackageMetaInterface {
55
fileCount: number;
66
unpackedSize: number;
77
};
8-
license?: Partial<LicenseInterface> | string | null;
8+
license?: Partial<LicenseInterface> | string;
99
};
1010
_uplinks: {};
1111
}

0 commit comments

Comments
 (0)