chore(server,cli,web): housekeeping and stricter code style (#6751)

* add unicorn to eslint

* fix lint errors for cli

* fix merge

* fix album name extraction

* Update cli/src/commands/upload.command.ts

Co-authored-by: Ben McCann <322311+benmccann@users.noreply.github.com>

* es2k23

* use lowercase os

* return undefined album name

* fix bug in asset response dto

* auto fix issues

* fix server code style

* es2022 and formatting

* fix compilation error

* fix test

* fix config load

* fix last lint errors

* set string type

* bump ts

* start work on web

* web formatting

* Fix UUIDParamDto as UUIDParamDto

* fix library service lint

* fix web errors

* fix errors

* formatting

* wip

* lints fixed

* web can now start

* alphabetical package json

* rename error

* chore: clean up

---------

Co-authored-by: Ben McCann <322311+benmccann@users.noreply.github.com>
Co-authored-by: Jason Rasmussen <jrasm91@gmail.com>
This commit is contained in:
Jonathan Jogenfors
2024-02-02 04:18:00 +01:00
committed by GitHub
parent e4d0560d49
commit f44fa45aa0
218 changed files with 2471 additions and 1244 deletions

View File

@@ -7,7 +7,7 @@ describe('parsing latitude from string input', () => {
expect(parseLatitude('Infinity')).toBeNull();
expect(parseLatitude('-Infinity')).toBeNull();
expect(parseLatitude('90.001')).toBeNull();
expect(parseLatitude(-90.000001)).toBeNull();
expect(parseLatitude(-90.000_001)).toBeNull();
expect(parseLatitude('1000')).toBeNull();
expect(parseLatitude(-1000)).toBeNull();
});
@@ -15,10 +15,10 @@ describe('parsing latitude from string input', () => {
it('returns the numeric coordinate for valid inputs', () => {
expect(parseLatitude('90')).toBeCloseTo(90);
expect(parseLatitude('-90')).toBeCloseTo(-90);
expect(parseLatitude(89.999999)).toBeCloseTo(89.999999);
expect(parseLatitude(89.999_999)).toBeCloseTo(89.999_999);
expect(parseLatitude('-89.9')).toBeCloseTo(-89.9);
expect(parseLatitude(0)).toBeCloseTo(0);
expect(parseLatitude('-0.0')).toBeCloseTo(-0.0);
expect(parseLatitude('-0.0')).toBeCloseTo(-0);
});
});
@@ -32,7 +32,7 @@ describe('parsing longitude from string input', () => {
it('returns null for invalid inputs', () => {
expect(parseLongitude('')).toBeNull();
expect(parseLongitude('NaN')).toBeNull();
expect(parseLongitude(Infinity)).toBeNull();
expect(parseLongitude(Number.POSITIVE_INFINITY)).toBeNull();
expect(parseLongitude('-Infinity')).toBeNull();
expect(parseLongitude('180.001')).toBeNull();
expect(parseLongitude('-180.000001')).toBeNull();
@@ -43,10 +43,10 @@ describe('parsing longitude from string input', () => {
it('returns the numeric coordinate for valid inputs', () => {
expect(parseLongitude(180)).toBeCloseTo(180);
expect(parseLongitude('-180')).toBeCloseTo(-180);
expect(parseLongitude('179.999999')).toBeCloseTo(179.999999);
expect(parseLongitude('179.999999')).toBeCloseTo(179.999_999);
expect(parseLongitude(-179.9)).toBeCloseTo(-179.9);
expect(parseLongitude('0')).toBeCloseTo(0);
expect(parseLongitude('-0.0')).toBeCloseTo(-0.0);
expect(parseLongitude('-0.0')).toBeCloseTo(-0);
});
});

View File

@@ -2,15 +2,15 @@ import { isDecimalNumber, isNumberInRange, toNumberOrNull } from './numbers';
describe('checks if a number is a decimal number', () => {
it('returns false for non-decimal numbers', () => {
expect(isDecimalNumber(NaN)).toBe(false);
expect(isDecimalNumber(Infinity)).toBe(false);
expect(isDecimalNumber(-Infinity)).toBe(false);
expect(isDecimalNumber(Number.NaN)).toBe(false);
expect(isDecimalNumber(Number.POSITIVE_INFINITY)).toBe(false);
expect(isDecimalNumber(Number.NEGATIVE_INFINITY)).toBe(false);
});
it('returns true for decimal numbers', () => {
expect(isDecimalNumber(0)).toBe(true);
expect(isDecimalNumber(-0)).toBe(true);
expect(isDecimalNumber(10.12345)).toBe(true);
expect(isDecimalNumber(10.123_45)).toBe(true);
expect(isDecimalNumber(Number.MAX_VALUE)).toBe(true);
expect(isDecimalNumber(Number.MIN_VALUE)).toBe(true);
});
@@ -26,16 +26,17 @@ describe('checks if a number is within a range', () => {
it('returns true for numbers inside the range', () => {
expect(isNumberInRange(0, 0, 50)).toBe(true);
expect(isNumberInRange(50, 0, 50)).toBe(true);
expect(isNumberInRange(-50.12345, -50.12345, 0)).toBe(true);
expect(isNumberInRange(-50.123_45, -50.123_45, 0)).toBe(true);
});
});
describe('converts input to a number or null', () => {
it('returns null for invalid inputs', () => {
expect(toNumberOrNull(null)).toBeNull();
// eslint-disable-next-line unicorn/no-useless-undefined
expect(toNumberOrNull(undefined)).toBeNull();
expect(toNumberOrNull('')).toBeNull();
expect(toNumberOrNull(NaN)).toBeNull();
expect(toNumberOrNull(Number.NaN)).toBeNull();
});
it('returns a number for valid inputs', () => {

View File

@@ -1,12 +1,12 @@
export function isDecimalNumber(num: number): boolean {
return !Number.isNaN(num) && Number.isFinite(num);
export function isDecimalNumber(number_: number): boolean {
return !Number.isNaN(number_) && Number.isFinite(number_);
}
/**
* Check if `num` is a valid number and is between `start` and `end` (inclusive)
*/
export function isNumberInRange(num: number, start: number, end: number): boolean {
return isDecimalNumber(num) && num >= start && num <= end;
export function isNumberInRange(number_: number, start: number, end: number): boolean {
return isDecimalNumber(number_) && number_ >= start && number_ <= end;
}
export function toNumberOrNull(input: number | string | null | undefined): number | null {
@@ -14,6 +14,6 @@ export function toNumberOrNull(input: number | string | null | undefined): numbe
return null;
}
const num = typeof input === 'string' ? Number.parseFloat(input) : input;
return isDecimalNumber(num) ? num : null;
const number_ = typeof input === 'string' ? Number.parseFloat(input) : input;
return isDecimalNumber(number_) ? number_ : null;
}