diff --git a/database/addLot.js b/database/addLot.js index 365a9d47..571c6a50 100644 --- a/database/addLot.js +++ b/database/addLot.js @@ -20,7 +20,7 @@ export default async function addLot(lotForm, user) { await addOrUpdateLotField({ lotId, lotTypeFieldId, - lotFieldValue + lotFieldValue: lotFieldValue ?? '' }, user, database); } } diff --git a/database/addLot.ts b/database/addLot.ts index b99b8858..3230a03f 100644 --- a/database/addLot.ts +++ b/database/addLot.ts @@ -53,14 +53,14 @@ export default async function addLot( const lotTypeFieldIds = (lotForm.lotTypeFieldIds ?? '').split(',') for (const lotTypeFieldId of lotTypeFieldIds) { - const lotFieldValue = lotForm[`lotFieldValue_${lotTypeFieldId}`] as string + const lotFieldValue = lotForm[`lotFieldValue_${lotTypeFieldId}`] as string | undefined if ((lotFieldValue ?? '') !== '') { await addOrUpdateLotField( { lotId, lotTypeFieldId, - lotFieldValue + lotFieldValue: lotFieldValue ?? '' }, user, database diff --git a/database/addLotOccupancy.js b/database/addLotOccupancy.js index 53eb071f..03f8afc1 100644 --- a/database/addLotOccupancy.js +++ b/database/addLotOccupancy.js @@ -27,24 +27,24 @@ export default async function addLotOccupancy(lotOccupancyForm, user, connectedD await addOrUpdateLotOccupancyField({ lotOccupancyId, occupancyTypeFieldId, - lotOccupancyFieldValue + lotOccupancyFieldValue: lotOccupancyFieldValue ?? '' }, user, database); } } if ((lotOccupancyForm.lotOccupantTypeId ?? '') !== '') { await addLotOccupancyOccupant({ lotOccupancyId, - lotOccupantTypeId: lotOccupancyForm.lotOccupantTypeId, - occupantName: lotOccupancyForm.occupantName, - occupantFamilyName: lotOccupancyForm.occupantFamilyName, - occupantAddress1: lotOccupancyForm.occupantAddress1, - occupantAddress2: lotOccupancyForm.occupantAddress2, - occupantCity: lotOccupancyForm.occupantCity, - occupantProvince: lotOccupancyForm.occupantProvince, - occupantPostalCode: lotOccupancyForm.occupantPostalCode, - occupantPhoneNumber: lotOccupancyForm.occupantPhoneNumber, - occupantEmailAddress: lotOccupancyForm.occupantEmailAddress, - occupantComment: lotOccupancyForm.occupantComment + lotOccupantTypeId: lotOccupancyForm.lotOccupantTypeId ?? '', + occupantName: lotOccupancyForm.occupantName ?? '', + occupantFamilyName: lotOccupancyForm.occupantFamilyName ?? '', + occupantAddress1: lotOccupancyForm.occupantAddress1 ?? '', + occupantAddress2: lotOccupancyForm.occupantAddress2 ?? '', + occupantCity: lotOccupancyForm.occupantCity ?? '', + occupantProvince: lotOccupancyForm.occupantProvince ?? '', + occupantPostalCode: lotOccupancyForm.occupantPostalCode ?? '', + occupantPhoneNumber: lotOccupancyForm.occupantPhoneNumber ?? '', + occupantEmailAddress: lotOccupancyForm.occupantEmailAddress ?? '', + occupantComment: lotOccupancyForm.occupantComment ?? '' }, user, database); } if (connectedDatabase === undefined) { diff --git a/database/addLotOccupancy.ts b/database/addLotOccupancy.ts index 21330d16..8e031045 100644 --- a/database/addLotOccupancy.ts +++ b/database/addLotOccupancy.ts @@ -78,14 +78,14 @@ export default async function addLotOccupancy( for (const occupancyTypeFieldId of occupancyTypeFieldIds) { const lotOccupancyFieldValue = lotOccupancyForm[ `lotOccupancyFieldValue_${occupancyTypeFieldId}` - ] as string + ] as string | undefined if ((lotOccupancyFieldValue ?? '') !== '') { await addOrUpdateLotOccupancyField( { lotOccupancyId, occupancyTypeFieldId, - lotOccupancyFieldValue + lotOccupancyFieldValue: lotOccupancyFieldValue ?? '' }, user, database @@ -97,17 +97,17 @@ export default async function addLotOccupancy( await addLotOccupancyOccupant( { lotOccupancyId, - lotOccupantTypeId: lotOccupancyForm.lotOccupantTypeId!, - occupantName: lotOccupancyForm.occupantName!, - occupantFamilyName: lotOccupancyForm.occupantFamilyName!, - occupantAddress1: lotOccupancyForm.occupantAddress1!, - occupantAddress2: lotOccupancyForm.occupantAddress2!, - occupantCity: lotOccupancyForm.occupantCity!, - occupantProvince: lotOccupancyForm.occupantProvince!, - occupantPostalCode: lotOccupancyForm.occupantPostalCode!, - occupantPhoneNumber: lotOccupancyForm.occupantPhoneNumber!, - occupantEmailAddress: lotOccupancyForm.occupantEmailAddress!, - occupantComment: lotOccupancyForm.occupantComment! + lotOccupantTypeId: lotOccupancyForm.lotOccupantTypeId ?? '', + occupantName: lotOccupancyForm.occupantName ?? '', + occupantFamilyName: lotOccupancyForm.occupantFamilyName ?? '', + occupantAddress1: lotOccupancyForm.occupantAddress1 ?? '', + occupantAddress2: lotOccupancyForm.occupantAddress2 ?? '', + occupantCity: lotOccupancyForm.occupantCity ?? '', + occupantProvince: lotOccupancyForm.occupantProvince ?? '', + occupantPostalCode: lotOccupancyForm.occupantPostalCode ?? '', + occupantPhoneNumber: lotOccupancyForm.occupantPhoneNumber ?? '', + occupantEmailAddress: lotOccupancyForm.occupantEmailAddress ?? '', + occupantComment: lotOccupancyForm.occupantComment ?? '' }, user, database diff --git a/database/addLotOccupancyFee.d.ts b/database/addLotOccupancyFee.d.ts index 6e5de22b..11b3130d 100644 --- a/database/addLotOccupancyFee.d.ts +++ b/database/addLotOccupancyFee.d.ts @@ -1,4 +1,4 @@ -import { type PoolConnection } from 'better-sqlite-pool'; +import type { PoolConnection } from 'better-sqlite-pool'; export interface AddLotOccupancyFeeForm { lotOccupancyId: number | string; feeId: number | string; diff --git a/database/addLotOccupancyFee.js b/database/addLotOccupancyFee.js index 81e54831..a4bc9a40 100644 --- a/database/addLotOccupancyFee.js +++ b/database/addLotOccupancyFee.js @@ -32,8 +32,8 @@ export default async function addLotOccupancyFee(lotOccupancyFeeForm, user, conn where lotOccupancyId = ? and feeId = ?`) .get(lotOccupancyFeeForm.lotOccupancyId, lotOccupancyFeeForm.feeId); - if (record) { - if (record.recordDelete_timeMillis) { + if (record !== undefined) { + if (record.recordDelete_timeMillis !== null) { database .prepare(`delete from LotOccupancyFees where recordDelete_timeMillis is not null diff --git a/database/addLotOccupancyFee.ts b/database/addLotOccupancyFee.ts index 6804d226..301c1e51 100644 --- a/database/addLotOccupancyFee.ts +++ b/database/addLotOccupancyFee.ts @@ -1,4 +1,4 @@ -import { type PoolConnection } from 'better-sqlite-pool' +import type { PoolConnection } from 'better-sqlite-pool' import { calculateFeeAmount, @@ -60,14 +60,16 @@ export default async function addLotOccupancyFee( where lotOccupancyId = ? and feeId = ?` ) - .get(lotOccupancyFeeForm.lotOccupancyId, lotOccupancyFeeForm.feeId) as { - feeAmount?: number - taxAmount?: number - recordDelete_timeMillis?: number - } - - if (record) { - if (record.recordDelete_timeMillis) { + .get(lotOccupancyFeeForm.lotOccupancyId, lotOccupancyFeeForm.feeId) as + | { + feeAmount: number | null + taxAmount: number | null + recordDelete_timeMillis: number | null + } + | undefined + + if (record !== undefined) { + if (record.recordDelete_timeMillis !== null) { database .prepare( `delete from LotOccupancyFees diff --git a/package-lock.json b/package-lock.json index b44ac94a..84a69aa0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -80,7 +80,7 @@ "bulma-tooltip": "^3.0.2", "cypress": "^13.15.1", "cypress-axe": "^1.5.0", - "eslint-config-cityssm": "^14.0.1", + "eslint-config-cityssm": "^14.0.2", "gulp": "^5.0.0", "gulp-sass": "^5.1.0", "nodemon": "^3.1.7", @@ -8120,9 +8120,9 @@ } }, "node_modules/eslint-config-cityssm": { - "version": "14.0.1", - "resolved": "https://registry.npmjs.org/eslint-config-cityssm/-/eslint-config-cityssm-14.0.1.tgz", - "integrity": "sha512-pmqsNjS0cxznslzhZeihz1iGSOe/4LgJZdJzi7D8R3KE3N6dDSxiIay0T+q2u8BgmZJJwmmvrL6Qlk0924mNyA==", + "version": "14.0.2", + "resolved": "https://registry.npmjs.org/eslint-config-cityssm/-/eslint-config-cityssm-14.0.2.tgz", + "integrity": "sha512-eCQHo5VoJGXvuhSYaJ6erZ7NS/KwDP+D9pkB0GtJMdk8NNBuN0NJyvJojJJwdwYTVFzG+Jhcc9LJvd05mpoufA==", "dev": true, "license": "Unlicense", "dependencies": { diff --git a/package.json b/package.json index 920632b3..84d96219 100644 --- a/package.json +++ b/package.json @@ -104,7 +104,7 @@ "bulma-tooltip": "^3.0.2", "cypress": "^13.15.1", "cypress-axe": "^1.5.0", - "eslint-config-cityssm": "^14.0.1", + "eslint-config-cityssm": "^14.0.2", "gulp": "^5.0.0", "gulp-sass": "^5.1.0", "nodemon": "^3.1.7", diff --git a/public/javascripts/adminDatabase.js b/public/javascripts/adminDatabase.js index 53494149..29220e32 100644 --- a/public/javascripts/adminDatabase.js +++ b/public/javascripts/adminDatabase.js @@ -1,5 +1,4 @@ "use strict"; -/* @typescript-eslint/no-non-null-assertion, unicorn/prefer-module */ Object.defineProperty(exports, "__esModule", { value: true }); (() => { const los = exports.los; diff --git a/public/javascripts/adminDatabase.ts b/public/javascripts/adminDatabase.ts index ddba582a..8115f8c6 100644 --- a/public/javascripts/adminDatabase.ts +++ b/public/javascripts/adminDatabase.ts @@ -1,5 +1,3 @@ -/* @typescript-eslint/no-non-null-assertion, unicorn/prefer-module */ - import type { BulmaJS } from '@cityssm/bulma-js/types.js' import type { cityssmGlobal } from '@cityssm/bulma-webapp-js/src/types.js' @@ -24,7 +22,7 @@ declare const exports: Record } | { success: false - errorMessage: string + errorMessage?: string } if (responseJSON.success) { @@ -59,7 +57,7 @@ declare const exports: Record } | { success: false - errorMessage: string + errorMessage?: string } if (responseJSON.success) { diff --git a/public/javascripts/adminFees.js b/public/javascripts/adminFees.js index 9e0d5102..6206f7d5 100644 --- a/public/javascripts/adminFees.js +++ b/public/javascripts/adminFees.js @@ -1,6 +1,4 @@ "use strict"; -// eslint-disable-next-line @eslint-community/eslint-comments/disable-enable-pair -/* eslint-disable unicorn/prefer-module */ Object.defineProperty(exports, "__esModule", { value: true }); (() => { const los = exports.los; @@ -8,14 +6,10 @@ Object.defineProperty(exports, "__esModule", { value: true }); let feeCategories = exports.feeCategories; delete exports.feeCategories; function getFeeCategory(feeCategoryId) { - return feeCategories.find((currentFeeCategory) => { - return currentFeeCategory.feeCategoryId === feeCategoryId; - }); + return feeCategories.find((currentFeeCategory) => currentFeeCategory.feeCategoryId === feeCategoryId); } function getFee(feeCategory, feeId) { - return feeCategory.fees.find((currentFee) => { - return currentFee.feeId === feeId; - }); + return feeCategory.fees.find((currentFee) => currentFee.feeId === feeId); } function renderFeeCategories() { if (feeCategories.length === 0) { @@ -551,8 +545,8 @@ Object.defineProperty(exports, "__esModule", { value: true }); } } function toggleQuantityFields() { - const includeQuanitityValue = editModalElement.querySelector('#feeEdit--includeQuantity').value; - editModalElement.querySelector('#feeEdit--quantityUnit').disabled = includeQuanitityValue === ''; + const includeQuantityValue = editModalElement.querySelector('#feeEdit--includeQuantity').value; + editModalElement.querySelector('#feeEdit--quantityUnit').disabled = includeQuantityValue === ''; } cityssm.openHtmlModal('adminFees-editFee', { onshow(modalElement) { diff --git a/public/javascripts/adminFees.ts b/public/javascripts/adminFees.ts index 00c2160b..f75a647b 100644 --- a/public/javascripts/adminFees.ts +++ b/public/javascripts/adminFees.ts @@ -1,6 +1,3 @@ -// eslint-disable-next-line @eslint-community/eslint-comments/disable-enable-pair -/* eslint-disable unicorn/prefer-module */ - import type { BulmaJS } from '@cityssm/bulma-js/types.js' import type { cityssmGlobal } from '@cityssm/bulma-webapp-js/src/types.js' @@ -33,19 +30,19 @@ declare const exports: Record } | { success: false - errorMessage: string + errorMessage?: string } function getFeeCategory(feeCategoryId: number): FeeCategory { - return feeCategories.find((currentFeeCategory) => { - return currentFeeCategory.feeCategoryId === feeCategoryId - }) as FeeCategory + return feeCategories.find( + (currentFeeCategory) => currentFeeCategory.feeCategoryId === feeCategoryId + ) as FeeCategory } function getFee(feeCategory: FeeCategory, feeId: number): Fee { - return feeCategory.fees.find((currentFee) => { - return currentFee.feeId === feeId - }) as Fee + return feeCategory.fees.find( + (currentFee) => currentFee.feeId === feeId + ) as Fee } function renderFeeCategories(): void { @@ -861,7 +858,7 @@ declare const exports: Record } function toggleQuantityFields(): void { - const includeQuanitityValue = ( + const includeQuantityValue = ( editModalElement.querySelector( '#feeEdit--includeQuantity' ) as HTMLSelectElement @@ -871,7 +868,7 @@ declare const exports: Record editModalElement.querySelector( '#feeEdit--quantityUnit' ) as HTMLInputElement - ).disabled = includeQuanitityValue === '' + ).disabled = includeQuantityValue === '' } cityssm.openHtmlModal('adminFees-editFee', { diff --git a/public/javascripts/adminLotTypes.ts b/public/javascripts/adminLotTypes.ts index 59c0d341..a3f1f41a 100644 --- a/public/javascripts/adminLotTypes.ts +++ b/public/javascripts/adminLotTypes.ts @@ -17,7 +17,7 @@ type ResponseJSON = } | { success: false - errorMessage: string + errorMessage?: string } ;(() => { const los = exports.los as LOS diff --git a/public/javascripts/workOrderView.js b/public/javascripts/workOrderView.js index 68549502..e9929751 100644 --- a/public/javascripts/workOrderView.js +++ b/public/javascripts/workOrderView.js @@ -12,7 +12,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); }, (rawResponseJSON) => { const responseJSON = rawResponseJSON; if (responseJSON.success) { - window.location.href = los.getWorkOrderURL(workOrderId, true, true); + globalThis.location.href = los.getWorkOrderURL(workOrderId, true, true); } else { bulmaJS.alert({ diff --git a/public/javascripts/workOrderView.ts b/public/javascripts/workOrderView.ts index 889531cb..ec972b38 100644 --- a/public/javascripts/workOrderView.ts +++ b/public/javascripts/workOrderView.ts @@ -30,7 +30,7 @@ declare const exports: Record } if (responseJSON.success) { - window.location.href = los.getWorkOrderURL( + globalThis.location.href = los.getWorkOrderURL( workOrderId, true, true diff --git a/test/0_initializeDatabase.js b/test/0_initializeDatabase.js index 2d67836f..55b6f714 100644 --- a/test/0_initializeDatabase.js +++ b/test/0_initializeDatabase.js @@ -8,6 +8,7 @@ describe('Initialize Database', () => { if (!useTestDatabases) { assert.fail('Test database must be used!'); } + // eslint-disable-next-line security/detect-non-literal-fs-filename await fs.unlink(databasePath); const success = await initializeCemeteryDatabase(); assert.ok(success); diff --git a/test/0_initializeDatabase.ts b/test/0_initializeDatabase.ts index 7ebc5bc0..7478611f 100644 --- a/test/0_initializeDatabase.ts +++ b/test/0_initializeDatabase.ts @@ -15,6 +15,7 @@ describe('Initialize Database', () => { assert.fail('Test database must be used!') } + // eslint-disable-next-line security/detect-non-literal-fs-filename await fs.unlink(databasePath) const success = await initializeCemeteryDatabase()