diff --git a/helpers/functions.authentication.js b/helpers/functions.authentication.js index 90a6a8a4..3ee7557a 100644 --- a/helpers/functions.authentication.js +++ b/helpers/functions.authentication.js @@ -43,8 +43,8 @@ const safeRedirects = new Set([ '/workorders/outlook', '/reports' ]); -const recordUrl = /^(\/(maps|lots|lotoccupancies|workorders)\/)\d+(\/edit)?$/; -const printUrl = /^\/print\/(pdf|screen)\/[\d/=?A-Za-z-]+$/; +const recordUrl = /^\/(?:maps|lots|lotoccupancies|workorders)\/\d+(?:\/edit)?$/; +const printUrl = /^\/print\/(?:pdf|screen)\/[\d/=?A-Za-z-]+$/; export function getSafeRedirectURL(possibleRedirectURL = '') { const urlPrefix = configFunctions.getProperty('reverseProxy.urlPrefix'); if (typeof possibleRedirectURL === 'string') { @@ -58,5 +58,5 @@ export function getSafeRedirectURL(possibleRedirectURL = '') { return urlPrefix + urlToCheck; } } - return urlPrefix + '/dashboard/'; + return `${urlPrefix}/dashboard/`; } diff --git a/helpers/functions.authentication.ts b/helpers/functions.authentication.ts index 60d0e448..1bf1da11 100644 --- a/helpers/functions.authentication.ts +++ b/helpers/functions.authentication.ts @@ -59,11 +59,9 @@ const safeRedirects = new Set([ '/reports' ]) -// eslint-disable-next-line regexp/no-unused-capturing-group -const recordUrl = /^(\/(maps|lots|lotoccupancies|workorders)\/)\d+(\/edit)?$/ +const recordUrl = /^\/(?:maps|lots|lotoccupancies|workorders)\/\d+(?:\/edit)?$/ -// eslint-disable-next-line regexp/no-unused-capturing-group -const printUrl = /^\/print\/(pdf|screen)\/[\d/=?A-Za-z-]+$/ +const printUrl = /^\/print\/(?:pdf|screen)\/[\d/=?A-Za-z-]+$/ export function getSafeRedirectURL(possibleRedirectURL = ''): string { const urlPrefix = configFunctions.getProperty('reverseProxy.urlPrefix') @@ -84,5 +82,5 @@ export function getSafeRedirectURL(possibleRedirectURL = ''): string { } } - return urlPrefix + '/dashboard/' + return `${urlPrefix}/dashboard/` } diff --git a/helpers/functions.cache.js b/helpers/functions.cache.js index 98ec3127..aea14e28 100644 --- a/helpers/functions.cache.js +++ b/helpers/functions.cache.js @@ -109,14 +109,14 @@ export async function getOccupancyTypeByOccupancyType(occupancyTypeString) { } export async function getOccupancyTypePrintsById(occupancyTypeId) { const occupancyType = await getOccupancyTypeById(occupancyTypeId); - if (occupancyType === undefined || - (occupancyType.occupancyTypePrints ?? []).length === 0) { + if (occupancyType?.occupancyTypePrints === undefined || + occupancyType.occupancyTypePrints.length === 0) { return []; } if (occupancyType.occupancyTypePrints.includes('*')) { return configFunctions.getProperty('settings.lotOccupancy.prints'); } - return occupancyType.occupancyTypePrints; + return occupancyType.occupancyTypePrints ?? []; } function clearOccupancyTypesCache() { occupancyTypes = undefined; diff --git a/helpers/functions.cache.ts b/helpers/functions.cache.ts index bae4c6c8..ae18941c 100644 --- a/helpers/functions.cache.ts +++ b/helpers/functions.cache.ts @@ -198,17 +198,17 @@ export async function getOccupancyTypePrintsById( const occupancyType = await getOccupancyTypeById(occupancyTypeId) if ( - occupancyType === undefined || - (occupancyType.occupancyTypePrints ?? []).length === 0 + occupancyType?.occupancyTypePrints === undefined || + occupancyType.occupancyTypePrints.length === 0 ) { return [] } - if (occupancyType.occupancyTypePrints!.includes('*')) { + if (occupancyType.occupancyTypePrints.includes('*')) { return configFunctions.getProperty('settings.lotOccupancy.prints') } - return occupancyType.occupancyTypePrints! + return occupancyType.occupancyTypePrints ?? [] } function clearOccupancyTypesCache(): void { diff --git a/helpers/functions.config.ts b/helpers/functions.config.ts index 9429378c..2370df9b 100644 --- a/helpers/functions.config.ts +++ b/helpers/functions.config.ts @@ -62,6 +62,7 @@ configFallbackValues.set( ) configFallbackValues.set( + // eslint-disable-next-line no-secrets/no-secrets 'settings.lotOccupancy.occupancyEndDateIsRequired', true ) diff --git a/helpers/functions.database.js b/helpers/functions.database.js index c4f2491e..abd29f67 100644 --- a/helpers/functions.database.js +++ b/helpers/functions.database.js @@ -1,12 +1,8 @@ import fs from 'node:fs/promises'; -import { lotOccupancyDB as databasePath, backupFolder } from '../data/databasePaths.js'; +import { backupFolder, lotOccupancyDB as databasePath } from '../data/databasePaths.js'; export const backupDatabase = async () => { const databasePathSplit = databasePath.split(/[/\\]/g); - const backupDatabasePath = backupFolder + - '/' + - databasePathSplit[databasePathSplit.length - 1] + - '.' + - Date.now().toString(); + const backupDatabasePath = `${backupFolder}/${databasePathSplit.at(-1)}.${Date.now().toString()}`; try { await fs.copyFile(databasePath, backupDatabasePath); return backupDatabasePath; diff --git a/helpers/functions.database.ts b/helpers/functions.database.ts index ac1fdb4d..0375e4f1 100644 --- a/helpers/functions.database.ts +++ b/helpers/functions.database.ts @@ -1,18 +1,14 @@ import fs from 'node:fs/promises' + import { - lotOccupancyDB as databasePath, - backupFolder + backupFolder, + lotOccupancyDB as databasePath } from '../data/databasePaths.js' export const backupDatabase = async (): Promise => { const databasePathSplit = databasePath.split(/[/\\]/g) - const backupDatabasePath = - backupFolder + - '/' + - databasePathSplit[databasePathSplit.length - 1] + - '.' + - Date.now().toString() + const backupDatabasePath = `${backupFolder}/${databasePathSplit.at(-1)}.${Date.now().toString()}` try { await fs.copyFile(databasePath, backupDatabasePath) diff --git a/helpers/functions.dynamicsGP.ts b/helpers/functions.dynamicsGP.ts index 01b7bf0a..fc39dd5d 100644 --- a/helpers/functions.dynamicsGP.ts +++ b/helpers/functions.dynamicsGP.ts @@ -1,9 +1,9 @@ /* eslint-disable unicorn/filename-case, @eslint-community/eslint-comments/disable-enable-pair */ import { - DynamicsGP, type DiamondCashReceipt, type DiamondExtendedGPInvoice, + DynamicsGP, type GPInvoice } from '@cityssm/dynamics-gp'