type linting

deepsource-autofix-76c6eb20
Dan Gowans 2024-06-24 10:30:09 -04:00
parent 5a9074eb20
commit 66f4e7d3bf
6 changed files with 17 additions and 18 deletions

View File

@ -49,14 +49,12 @@ function buildWhereClause(filters) {
if ((filters.workOrderTypeIds ?? '') !== '' &&
commaSeparatedNumbersRegex.test(filters.workOrderTypeIds)) {
sqlWhereClause +=
' and w.workOrderTypeId in (' + filters.workOrderTypeIds + ')';
` and w.workOrderTypeId in (${filters.workOrderTypeIds})`;
}
if ((filters.workOrderMilestoneTypeIds ?? '') !== '' &&
if (filters.workOrderMilestoneTypeIds !== undefined &&
filters.workOrderMilestoneTypeIds !== '' &&
commaSeparatedNumbersRegex.test(filters.workOrderMilestoneTypeIds)) {
sqlWhereClause +=
' and m.workOrderMilestoneTypeId in (' +
filters.workOrderMilestoneTypeIds +
')';
sqlWhereClause += ` and m.workOrderMilestoneTypeId in (${filters.workOrderMilestoneTypeIds})`;
}
return {
sqlWhereClause,

View File

@ -1,4 +1,5 @@
import {
type DateString,
dateIntegerToString,
dateStringToInteger,
dateToInteger,
@ -100,7 +101,7 @@ function buildWhereClause(filters: WorkOrderMilestoneFilters): {
if ((filters.workOrderMilestoneDateString ?? '') !== '') {
sqlWhereClause += ' and m.workOrderMilestoneDate = ?'
sqlParameters.push(
dateStringToInteger(filters.workOrderMilestoneDateString!)
dateStringToInteger(filters.workOrderMilestoneDateString as DateString)
)
}
@ -109,17 +110,15 @@ function buildWhereClause(filters: WorkOrderMilestoneFilters): {
commaSeparatedNumbersRegex.test(filters.workOrderTypeIds!)
) {
sqlWhereClause +=
' and w.workOrderTypeId in (' + filters.workOrderTypeIds! + ')'
` and w.workOrderTypeId in (${filters.workOrderTypeIds})`
}
if (
(filters.workOrderMilestoneTypeIds ?? '') !== '' &&
filters.workOrderMilestoneTypeIds !== undefined &&
filters.workOrderMilestoneTypeIds !== '' &&
commaSeparatedNumbersRegex.test(filters.workOrderMilestoneTypeIds!)
) {
sqlWhereClause +=
' and m.workOrderMilestoneTypeId in (' +
filters.workOrderMilestoneTypeIds! +
')'
sqlWhereClause += ` and m.workOrderMilestoneTypeId in (${filters.workOrderMilestoneTypeIds})`
}
return {

View File

@ -11,7 +11,7 @@ let apiKeys: Record<string, string>
async function loadApiKeys(): Promise<void> {
try {
const fileData = await fs.readFile(apiKeyPath, 'utf8')
apiKeys = JSON.parse(fileData)
apiKeys = JSON.parse(fileData) as Record<string, string>
} catch (error) {
debug(error)
apiKeys = {}

View File

@ -6,7 +6,7 @@ async function authenticateViaActiveDirectory(userName, password) {
return await new Promise((resolve) => {
try {
const ad = new ActiveDirectory(activeDirectoryConfig);
ad.authenticate(userDomain + '\\' + userName, password, (error, auth) => {
ad.authenticate(`${userDomain}\\${userName}`, password, (error, auth) => {
let authenticated = false;
if ((error ?? '') === '') {
authenticated = auth;

View File

@ -4,7 +4,8 @@ import * as configFunctions from './functions.config.js'
const userDomain = configFunctions.getConfigProperty('application.userDomain')
const activeDirectoryConfig = configFunctions.getConfigProperty('activeDirectory')
const activeDirectoryConfig =
configFunctions.getConfigProperty('activeDirectory')
async function authenticateViaActiveDirectory(
userName: string,
@ -14,7 +15,7 @@ async function authenticateViaActiveDirectory(
try {
const ad = new ActiveDirectory(activeDirectoryConfig)
ad.authenticate(userDomain + '\\' + userName, password, (error, auth) => {
ad.authenticate(`${userDomain}\\${userName}`, password, (error, auth) => {
let authenticated = false
if ((error ?? '') === '') {

View File

@ -19,6 +19,7 @@ describe('config.cemetery.ssm', () => {
describe('functions.cache', () => {
const badId = -3
// eslint-disable-next-line no-secrets/no-secrets
const badName = 'qwertyuiopasdfghjklzxcvbnm'
before(() => {
@ -477,7 +478,7 @@ describe('functions.user', () => {
it('authenticates with a valid API key', async () => {
const apiKeysJSON: Record<string, string> = JSON.parse(
fs.readFileSync('data/apiKeys.json', 'utf8')
)
) as Record<string, string>
const apiKey = Object.values(apiKeysJSON)[0]