Skip to content

Commit

Permalink
linting
Browse files Browse the repository at this point in the history
  • Loading branch information
dangowans committed Oct 29, 2024
1 parent c7ccdfe commit 7011ab1
Show file tree
Hide file tree
Showing 36 changed files with 184 additions and 153 deletions.
9 changes: 5 additions & 4 deletions bin/www.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import cluster from 'node:cluster';
import os from 'node:os';
import { dirname } from 'node:path';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
import ntfyPublish from '@cityssm/ntfy-publish';
import { secondsToMillis } from '@cityssm/to-millis';
import Debug from 'debug';
import exitHook from 'exit-hook';
import { getConfigProperty } from '../helpers/functions.config.js';
const debug = Debug(`lot-occupancy-system:www:${process.pid}`);
const directoryName = dirname(fileURLToPath(import.meta.url));
const directoryName = path.dirname(fileURLToPath(import.meta.url));
const processCount = Math.min(getConfigProperty('application.maximumProcesses'), os.cpus().length);
process.title = `${getConfigProperty('application.applicationName')} (Primary)`;
debug(`Primary pid: ${process.pid}`);
Expand Down Expand Up @@ -68,7 +69,7 @@ if (process.env.STARTUP_TEST === 'true') {
debug(`Killing processes in ${killSeconds} seconds...`);
setTimeout(() => {
debug('Killing processes');
// eslint-disable-next-line n/no-process-exit, unicorn/no-process-exit
// eslint-disable-next-line unicorn/no-process-exit
process.exit(0);
}, 10_000);
}, secondsToMillis(killSeconds));
}
9 changes: 5 additions & 4 deletions bin/www.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import cluster, { type Worker } from 'node:cluster'
import os from 'node:os'
import { dirname } from 'node:path'
import path from 'node:path'
import { fileURLToPath } from 'node:url'

import ntfyPublish, { type NtfyMessageOptions } from '@cityssm/ntfy-publish'
import { secondsToMillis } from '@cityssm/to-millis'
import Debug from 'debug'
import exitHook from 'exit-hook'

Expand All @@ -12,7 +13,7 @@ import type { WorkerMessage } from '../types/applicationTypes.js'

const debug = Debug(`lot-occupancy-system:www:${process.pid}`)

const directoryName = dirname(fileURLToPath(import.meta.url))
const directoryName = path.dirname(fileURLToPath(import.meta.url))

const processCount = Math.min(
getConfigProperty('application.maximumProcesses'),
Expand Down Expand Up @@ -98,7 +99,7 @@ if (process.env.STARTUP_TEST === 'true') {
setTimeout(() => {
debug('Killing processes')

// eslint-disable-next-line n/no-process-exit, unicorn/no-process-exit
// eslint-disable-next-line unicorn/no-process-exit
process.exit(0)
}, 10_000)
}, secondsToMillis(killSeconds))
}
3 changes: 1 addition & 2 deletions bin/wwwProcess.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// eslint-disable-next-line @eslint-community/eslint-comments/disable-enable-pair
/* eslint-disable n/no-process-exit, unicorn/no-process-exit */
/* eslint-disable unicorn/no-process-exit */
import http from 'node:http';
import Debug from 'debug';
import exitHook from 'exit-hook';
Expand All @@ -12,7 +12,6 @@ function onError(error) {
}
// handle specific listen errors with friendly messages
switch (error.code) {
// eslint-disable-next-line no-fallthrough
case 'EACCES': {
debug('Requires elevated privileges');
process.exit(1);
Expand Down
3 changes: 1 addition & 2 deletions bin/wwwProcess.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// eslint-disable-next-line @eslint-community/eslint-comments/disable-enable-pair
/* eslint-disable n/no-process-exit, unicorn/no-process-exit */
/* eslint-disable unicorn/no-process-exit */

import http from 'node:http'

Expand All @@ -23,7 +23,6 @@ function onError(error: ServerError): void {

// handle specific listen errors with friendly messages
switch (error.code) {
// eslint-disable-next-line no-fallthrough
case 'EACCES': {
debug('Requires elevated privileges')
process.exit(1)
Expand Down
1 change: 0 additions & 1 deletion cypress/support/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable node/no-unpublished-import */
import 'cypress-axe';
export const logout = () => {
cy.visit('/logout');
Expand Down
2 changes: 0 additions & 2 deletions cypress/support/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/* eslint-disable node/no-unpublished-import */

import 'cypress-axe'

export const logout = (): void => {
Expand Down
3 changes: 2 additions & 1 deletion data/config.cemetery.d.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
export declare const config: import("../types/configTypes.js").Config;
import type { Config } from '../types/configTypes.js';
export declare const config: Config;
export default config;
2 changes: 1 addition & 1 deletion data/config.cemetery.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { config as baseConfig } from './config.base.js';
export const config = Object.assign({}, baseConfig);
export const config = { ...baseConfig };
config.application = {
applicationName: 'Cemetery Management System',
backgroundURL: '/images/cemetery-background.jpg',
Expand Down
3 changes: 2 additions & 1 deletion data/config.cemetery.ssm.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export declare const config: import("../types/configTypes.js").Config;
import type { Config } from '../types/configTypes.js';
export declare const config: Config;
export declare function lotNameSortNameFunction(lotName: string): string;
export default config;
2 changes: 1 addition & 1 deletion data/config.cemetery.ssm.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import NodeCache from 'node-cache';
import { config as cemeteryConfig } from './config.cemetery.ontario.js';
export const config = Object.assign({}, cemeteryConfig);
export const config = { ...cemeteryConfig };
config.aliases.occupancyStartDate = 'Purchase Date';
config.aliases.externalReceiptNumber = 'GP Receipt Number';
config.settings.lot.lotNamePattern =
Expand Down
4 changes: 3 additions & 1 deletion data/config.cemetery.ssm.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import NodeCache from 'node-cache'

import type { Config } from '../types/configTypes.js'

import { config as cemeteryConfig } from './config.cemetery.ontario.js'

export const config = Object.assign({}, cemeteryConfig)
export const config: Config = { ...cemeteryConfig}

config.aliases.occupancyStartDate = 'Purchase Date'
config.aliases.externalReceiptNumber = 'GP Receipt Number'
Expand Down
4 changes: 3 additions & 1 deletion data/config.cemetery.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import type { Config } from '../types/configTypes.js'

import { config as baseConfig } from './config.base.js'

export const config = Object.assign({}, baseConfig)
export const config: Config = { ...baseConfig }

config.application = {
applicationName: 'Cemetery Management System',
Expand Down
5 changes: 3 additions & 2 deletions data/config.defaultValues.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { hoursToMillis } from '@cityssm/to-millis';
export const configDefaultValues = {
'activeDirectory': undefined,
activeDirectory: undefined,
'application.applicationName': 'Lot Occupancy System',
'application.backgroundURL': '/images/cemetery-background.jpg',
'application.logoURL': '/images/cemetery-logo.png',
Expand All @@ -13,7 +14,7 @@ export const configDefaultValues = {
'reverseProxy.urlPrefix': '',
'session.cookieName': 'lot-occupancy-system-user-sid',
'session.secret': 'cityssm/lot-occupancy-system',
'session.maxAgeMillis': 60 * 60 * 1000,
'session.maxAgeMillis': hoursToMillis(1),
'session.doKeepAlive': false,
'users.testing': [],
'users.canLogin': ['administrator'],
Expand Down
15 changes: 11 additions & 4 deletions data/config.defaultValues.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
import { hoursToMillis } from '@cityssm/to-millis'
import type { config as MSSQLConfig } from 'mssql'

import type { ConfigActiveDirectory, ConfigNtfyStartup, DynamicsGPLookup } from '../types/configTypes.js'
import type {
ConfigActiveDirectory,
ConfigNtfyStartup,
DynamicsGPLookup
} from '../types/configTypes.js'

export const configDefaultValues = {
'activeDirectory': undefined as unknown as ConfigActiveDirectory,
activeDirectory: undefined as unknown as ConfigActiveDirectory,

'application.applicationName': 'Lot Occupancy System',
'application.backgroundURL': '/images/cemetery-background.jpg',
Expand All @@ -21,7 +26,7 @@ export const configDefaultValues = {

'session.cookieName': 'lot-occupancy-system-user-sid',
'session.secret': 'cityssm/lot-occupancy-system',
'session.maxAgeMillis': 60 * 60 * 1000,
'session.maxAgeMillis': hoursToMillis(1),
'session.doKeepAlive': false,

'users.testing': [] as string[],
Expand Down Expand Up @@ -66,7 +71,9 @@ export const configDefaultValues = {

'settings.adminCleanup.recordDeleteAgeDays': 60,

'settings.printPdf.contentDisposition': 'attachment' as 'attachment' | 'inline',
'settings.printPdf.contentDisposition': 'attachment' as
| 'attachment'
| 'inline',

'settings.dynamicsGP.integrationIsEnabled': false,
'settings.dynamicsGP.mssqlConfig': undefined as unknown as MSSQLConfig,
Expand Down
3 changes: 2 additions & 1 deletion data/config.testing.d.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
export declare const config: import("../types/configTypes.js").Config;
import type { Config } from '../types/configTypes.js';
export declare const config: Config;
export default config;
2 changes: 1 addition & 1 deletion data/config.testing.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { config as cemeteryConfig } from './config.cemetery.ssm.js';
export const config = Object.assign({}, cemeteryConfig);
export const config = { ...cemeteryConfig };
config.application.useTestDatabases = true;
config.session.doKeepAlive = true;
config.users = {
Expand Down
4 changes: 3 additions & 1 deletion data/config.testing.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import type { Config } from '../types/configTypes.js'

import { config as cemeteryConfig } from './config.cemetery.ssm.js'

export const config = Object.assign({}, cemeteryConfig)
export const config: Config = { ...cemeteryConfig }

config.application.useTestDatabases = true

Expand Down
2 changes: 1 addition & 1 deletion database/getFeeCategories.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { type PoolConnection } from 'better-sqlite-pool';
import type { PoolConnection } from 'better-sqlite-pool';
import type { FeeCategory } from '../types/recordTypes.js';
interface GetFeeCategoriesFilters {
occupancyTypeId?: number | string;
Expand Down
2 changes: 1 addition & 1 deletion database/getFeeCategories.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { type PoolConnection } from 'better-sqlite-pool'
import type { PoolConnection } from 'better-sqlite-pool'

import type { FeeCategory } from '../types/recordTypes.js'

Expand Down
2 changes: 1 addition & 1 deletion database/getLotOccupancyComments.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export default async function getLotOccupancyComments(lotOccupancyId, connectedD
and lotOccupancyId = ?
order by lotOccupancyCommentDate desc, lotOccupancyCommentTime desc, lotOccupancyCommentId desc`)
.all(lotOccupancyId);
if (connectedDatabase === null) {
if (connectedDatabase === undefined) {
database.release();
}
return lotComments;
Expand Down
2 changes: 1 addition & 1 deletion database/getLotOccupancyComments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export default async function getLotOccupancyComments(
)
.all(lotOccupancyId) as LotOccupancyComment[]

if (connectedDatabase === null) {
if (connectedDatabase === undefined) {
database.release()
}

Expand Down
8 changes: 5 additions & 3 deletions database/getNextMapId.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@ export default async function getNextMapId(
order by mapName
limit 1`
)
.get(mapId) as {
mapId: number
}
.get(mapId) as
| {
mapId: number
}
| undefined

database.release()

Expand Down
6 changes: 2 additions & 4 deletions database/getNextWorkOrderNumber.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@ export default async function getNextWorkOrderNumber(connectedDatabase) {
const regex = new RegExp(`^${currentYearString}-\\d+$`);
database.function(
// eslint-disable-next-line no-secrets/no-secrets
'userFn_matchesWorkOrderNumberSyntax', (workOrderNumber) => {
return regex.test(workOrderNumber) ? 1 : 0;
});
'userFn_matchesWorkOrderNumberSyntax', (workOrderNumber) => (regex.test(workOrderNumber) ? 1 : 0));
const workOrderNumberRecord = database
.prepare(
// eslint-disable-next-line no-secrets/no-secrets
Expand All @@ -21,7 +19,7 @@ export default async function getNextWorkOrderNumber(connectedDatabase) {
database.release();
}
let workOrderNumberIndex = 0;
if (workOrderNumberRecord) {
if (workOrderNumberRecord !== undefined) {
workOrderNumberIndex = Number.parseInt(workOrderNumberRecord.workOrderNumber.split('-')[1], 10);
}
workOrderNumberIndex += 1;
Expand Down
14 changes: 7 additions & 7 deletions database/getNextWorkOrderNumber.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@ export default async function getNextWorkOrderNumber(
database.function(
// eslint-disable-next-line no-secrets/no-secrets
'userFn_matchesWorkOrderNumberSyntax',
(workOrderNumber: string) => {
return regex.test(workOrderNumber) ? 1 : 0
}
(workOrderNumber: string) => (regex.test(workOrderNumber) ? 1 : 0)
)

const workOrderNumberRecord = database
Expand All @@ -31,17 +29,19 @@ export default async function getNextWorkOrderNumber(
where userFn_matchesWorkOrderNumberSyntax(workOrderNumber) = 1
order by cast(substr(workOrderNumber, instr(workOrderNumber, '-') + 1) as integer) desc`
)
.get() as {
workOrderNumber: string
}
.get() as
| {
workOrderNumber: string
}
| undefined

if (connectedDatabase === undefined) {
database.release()
}

let workOrderNumberIndex = 0

if (workOrderNumberRecord) {
if (workOrderNumberRecord !== undefined) {
workOrderNumberIndex = Number.parseInt(
workOrderNumberRecord.workOrderNumber.split('-')[1],
10
Expand Down
27 changes: 13 additions & 14 deletions database/getPastLotOccupancyOccupants.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,11 @@ export default async function getPastLotOccupancyOccupants(filters, options) {
if (searchFilterPiece === '') {
continue;
}
sqlWhereClause +=
" and (o.occupantName like '%' || ? || '%'" +
" or o.occupantFamilyName like '%' || ? || '%'" +
" or o.occupantAddress1 like '%' || ? || '%'" +
" or o.occupantAddress2 like '%' || ? || '%'" +
" or o.occupantCity like '%' || ? || '%')";
sqlWhereClause += ` and (o.occupantName like '%' || ? || '%'
or o.occupantFamilyName like '%' || ? || '%'
or o.occupantAddress1 like '%' || ? || '%'
or o.occupantAddress2 like '%' || ? || '%'
or o.occupantCity like '%' || ? || '%')`;
sqlParameters.push(searchFilterPiece, searchFilterPiece, searchFilterPiece, searchFilterPiece, searchFilterPiece);
}
}
Expand All @@ -24,14 +23,14 @@ export default async function getPastLotOccupancyOccupants(filters, options) {
o.occupantPhoneNumber, o.occupantEmailAddress,
count(*) as lotOccupancyIdCount,
max(o.recordUpdate_timeMillis) as recordUpdate_timeMillisMax
from LotOccupancyOccupants o
left join LotOccupancies l on o.lotOccupancyId = l.lotOccupancyId
${sqlWhereClause}
group by occupantName, occupantAddress1, occupantAddress2,
occupantCity, occupantProvince, occupantPostalCode,
occupantPhoneNumber, occupantEmailAddress
order by lotOccupancyIdCount desc, recordUpdate_timeMillisMax desc
limit ${options.limit}`;
from LotOccupancyOccupants o
left join LotOccupancies l on o.lotOccupancyId = l.lotOccupancyId
${sqlWhereClause}
group by occupantName, occupantAddress1, occupantAddress2,
occupantCity, occupantProvince, occupantPostalCode,
occupantPhoneNumber, occupantEmailAddress
order by lotOccupancyIdCount desc, recordUpdate_timeMillisMax desc
limit ${options.limit}`;
const lotOccupancyOccupants = database
.prepare(sql)
.all(sqlParameters);
Expand Down
Loading

0 comments on commit 7011ab1

Please sign in to comment.