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 ?? '') !== '' && if ((filters.workOrderTypeIds ?? '') !== '' &&
commaSeparatedNumbersRegex.test(filters.workOrderTypeIds)) { commaSeparatedNumbersRegex.test(filters.workOrderTypeIds)) {
sqlWhereClause += 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)) { commaSeparatedNumbersRegex.test(filters.workOrderMilestoneTypeIds)) {
sqlWhereClause += sqlWhereClause += ` and m.workOrderMilestoneTypeId in (${filters.workOrderMilestoneTypeIds})`;
' and m.workOrderMilestoneTypeId in (' +
filters.workOrderMilestoneTypeIds +
')';
} }
return { return {
sqlWhereClause, sqlWhereClause,

View File

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

View File

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

View File

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

View File

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

View File

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