Skip to content

Commit

Permalink
refactor: formatLicense to return undefined instead of null
Browse files Browse the repository at this point in the history
  • Loading branch information
griffithtp committed Jul 7, 2019
1 parent cf1f47e commit 13c7aa6
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions src/utils/package.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ describe('formatLicense', (): void => {
});

test('should check license field for other value', (): void => {
expect(formatLicense(null)).toBeNull();
expect(formatLicense({})).toBeNull();
expect(formatLicense([])).toBeNull();
expect(formatLicense(null)).toBeUndefined();
expect(formatLicense({})).toBeUndefined();
expect(formatLicense([])).toBeUndefined();
});
});

Expand Down
4 changes: 2 additions & 2 deletions src/utils/package.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export const TIMEFORMAT = 'DD.MM.YYYY, HH:mm:ss';
*/
// License should use type License defined above, but conflicts with the unit test that provide array or empty object
/* eslint-disable @typescript-eslint/no-explicit-any */
export function formatLicense(license: any): string | null {
export function formatLicense(license: any): string | undefined {
if (isString(license)) {
return license;
}
Expand All @@ -21,7 +21,7 @@ export function formatLicense(license: any): string | null {
return license.type;
}

return null;
return;
}

export interface Repository {
Expand Down
2 changes: 1 addition & 1 deletion types/packageMeta.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export interface PackageMetaInterface {
fileCount: number;
unpackedSize: number;
};
license?: Partial<LicenseInterface> | string | null;
license?: Partial<LicenseInterface> | string;
};
_uplinks: {};
}
Expand Down

0 comments on commit 13c7aa6

Please sign in to comment.