Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

Fix eslint errors: coalescing operator, unused var

Alexander Brandon Coles2fbd1071e426
diff --git a/frontend/src/app/shared/helpers/chronic_duration.ts b/frontend/src/app/shared/helpers/chronic_duration.ts
index b71934de252..2a5f75c53e3 100644
--- a/frontend/src/app/shared/helpers/chronic_duration.ts
+++ b/frontend/src/app/shared/helpers/chronic_duration.ts
@@ -120,8 +120,8 @@ function durationUnitsSecondsMultiplier(unit:string, opts:ChronicDurationOptions
return 0;
}
- const hoursPerDay = opts.hoursPerDay || HOURS_PER_DAY;
- const daysPerMonth = opts.daysPerMonth || DAYS_PER_MONTH;
+ const hoursPerDay = opts.hoursPerDay ?? HOURS_PER_DAY;
+ const daysPerMonth = opts.daysPerMonth ?? DAYS_PER_MONTH;
const daysPerWeek = Math.trunc(daysPerMonth / FULL_WEEKS_PER_MONTH);
switch (unit) {
@@ -174,7 +174,7 @@ function calculateFromWords(string:string, opts:ChronicDurationOptions):number {
lastExplicitUnit = unit;
} else {
// No explicit unit and no previous unit, fall back to default
- unit = opts.defaultUnit || 'seconds';
+ unit = opts.defaultUnit ?? 'seconds';
}
val += convertToNumber(v) * durationUnitsSecondsMultiplier(unit, opts);
@@ -292,8 +292,8 @@ export function outputChronicDuration(seconds:number, opts:ChronicDurationOption
seconds,
};
- const hoursPerDay = opts.hoursPerDay || HOURS_PER_DAY;
- const daysPerMonth = opts.daysPerMonth || DAYS_PER_MONTH;
+ const hoursPerDay = opts.hoursPerDay ?? HOURS_PER_DAY;
+ const daysPerMonth = opts.daysPerMonth ?? DAYS_PER_MONTH;
const daysPerWeek = Math.trunc(daysPerMonth / FULL_WEEKS_PER_MONTH);
const decimalPlaces =
@@ -343,8 +343,8 @@ export function outputChronicDuration(seconds:number, opts:ChronicDurationOption
}
}
- let joiner = opts.joiner || ' ';
- let process:((str:string) => string)|null = null;
+ let joiner = opts.joiner ?? ' ';
+ let process:((_str:string) => string)|null = null;
let dividers:Dividers;
switch (opts.format) {
diff --git a/frontend/src/stimulus/helpers/chronic-duration-helper.ts b/frontend/src/stimulus/helpers/chronic-duration-helper.ts
index 281d671e491..00a580a96b7 100644
--- a/frontend/src/stimulus/helpers/chronic-duration-helper.ts
+++ b/frontend/src/stimulus/helpers/chronic-duration-helper.ts
@@ -40,7 +40,7 @@ export function durationStringToSeconds(value:string):number {
return parseChronicDuration(normalizedValue, {
defaultUnit: 'hours',
ignoreSecondsWhenColonSeparated: true,
- }) || 0;
+ }) ?? 0;
}
export function formattedHour(seconds:number):string {
@@ -48,5 +48,5 @@ export function formattedHour(seconds:number):string {
return '';
}
-return outputChronicDuration(seconds, { format: 'hours_only' }) ?? '';
+ return outputChronicDuration(seconds, { format: 'hours_only' }) ?? '';
}