diff --git a/package.json b/package.json index 0faea99..3b351f4 100644 --- a/package.json +++ b/package.json @@ -47,6 +47,7 @@ "@seald-io/nedb": "^4.0.2", "body-parser": "^1.20.2", "compression": "^1.7.4", + "eslint-plugin-prettier": "^5.1.3", "express": "^4.18.2", "express-validator": "^7.0.1", "node-fetch": "^2", diff --git a/src/agents/sofie-core/sofieCoreAgent.ts b/src/agents/sofie-core/sofieCoreAgent.ts index 2cc1b6d..2dbb756 100644 --- a/src/agents/sofie-core/sofieCoreAgent.ts +++ b/src/agents/sofie-core/sofieCoreAgent.ts @@ -58,7 +58,7 @@ async function createMessage(message: ServiceMessage, instance: SofieInstance): 'Content-Type': 'application/json', Accept: 'application/json', }), - }) + }), ) await checkResponse(response, [200, 201]) @@ -99,7 +99,7 @@ async function recallMessage(message: ServiceMessage, instance: SofieInstance): targetUrl.pathname = `${REMOTE_SERVICEMESSAGE_API_PATH}/${id}` const response = await fetch( targetUrl.href, - Object.assign({}, defaultOptions, { method: 'delete', headers: defaultHeaders }) + Object.assign({}, defaultOptions, { method: 'delete', headers: defaultHeaders }), ) await checkResponse(response, [200, 404]) @@ -146,7 +146,7 @@ async function getMessage(id: string, instance: SofieInstance): Promise): Promis if (allowed.indexOf(response.status) < 0) { const message = await response.text() const err: SofieCoreAgentError = new Error( - `Unexpected response HTTP ${response.status} ${message}, wanted one of ${allowed.join(',')}!` + `Unexpected response HTTP ${response.status} ${message}, wanted one of ${allowed.join(',')}!`, ) err.responseStatus = response.status diff --git a/src/api/coreControl/peripheralDevices.ts b/src/api/coreControl/peripheralDevices.ts index e88c56d..c5bf6ce 100644 --- a/src/api/coreControl/peripheralDevices.ts +++ b/src/api/coreControl/peripheralDevices.ts @@ -61,7 +61,7 @@ async function setPeripheralSubDeviceState( href: string, peripheralDeviceId: string, subDeviceId: string, - desiredState: SofieSubDeviceState + desiredState: SofieSubDeviceState, ) { const actionPath = `/disablePeripheralSubDevice/restApi/${peripheralDeviceId}/${subDeviceId}/${desiredState.enabled}` diff --git a/src/api/serviceMessages/api.ts b/src/api/serviceMessages/api.ts index add95c8..adbab86 100644 --- a/src/api/serviceMessages/api.ts +++ b/src/api/serviceMessages/api.ts @@ -32,7 +32,7 @@ function registerServiceMessageApiHandlers(app: Application, rootPath: string): endpoints.read = { path, method: 'GET', useId: true } app.post(`${path}/refreshPublishStates/:id`, (req, res) => - callAsyncAsCallback(refreshPublishStatesHandler, undefined, req, res) + callAsyncAsCallback(refreshPublishStatesHandler, undefined, req, res), ) endpoints.refreshPublishStates = { diff --git a/src/controllers/coreControl.ts b/src/controllers/coreControl.ts index bef234d..a8d8dfc 100644 --- a/src/controllers/coreControl.ts +++ b/src/controllers/coreControl.ts @@ -23,19 +23,19 @@ if (process.env.CONTROL_SUB_DEVICES_CONFIG_PATH) { rk5rk6SubDevicesToEnableDisable.rk5.disablePayloads = createPeripheralSubDevicePayloads( rk5rk6SubDevicesToEnableDisable.rk5, - false + false, ) rk5rk6SubDevicesToEnableDisable.rk5.enablePayloads = createPeripheralSubDevicePayloads( rk5rk6SubDevicesToEnableDisable.rk5, - true + true, ) rk5rk6SubDevicesToEnableDisable.rk6.disablePayloads = createPeripheralSubDevicePayloads( rk5rk6SubDevicesToEnableDisable.rk6, - false + false, ) rk5rk6SubDevicesToEnableDisable.rk6.enablePayloads = createPeripheralSubDevicePayloads( rk5rk6SubDevicesToEnableDisable.rk6, - true + true, ) } catch (e) { logger.error(`Failed to load list of sub-devices to control: ${e}`) diff --git a/src/controllers/sofieInstances.ts b/src/controllers/sofieInstances.ts index df12803..a760088 100644 --- a/src/controllers/sofieInstances.ts +++ b/src/controllers/sofieInstances.ts @@ -17,7 +17,7 @@ function registerSofieInstancesHandler(app: Application): void { (req, res, next) => { callAsyncAsCallback(addInstancesFromQuerystringParam, undefined, req as RequestWithInstances, res, next) }, - (req, res) => callAsyncAsCallback(getHandler, undefined, req, res) + (req, res) => callAsyncAsCallback(getHandler, undefined, req, res), ) logger.debug('registered sofieInstances route') } diff --git a/src/data/serviceMessages/api.ts b/src/data/serviceMessages/api.ts index 10e2a8b..06d9a8d 100644 --- a/src/data/serviceMessages/api.ts +++ b/src/data/serviceMessages/api.ts @@ -21,7 +21,7 @@ export { createServiceMessage, getAllMessages, getMessage, removeServiceMessage, async function createServiceMessage( criticality: Criticality, message: string, - targetHosts: Array + targetHosts: Array, ): Promise { const instances = await getInstancesFromTargetHosts(targetHosts) logger.debug(`Got ${instances.length} instances from ${targetHosts.length} target hosts`, { diff --git a/src/data/serviceMessages/dataStore.ts b/src/data/serviceMessages/dataStore.ts index 65bfb1e..b04a466 100644 --- a/src/data/serviceMessages/dataStore.ts +++ b/src/data/serviceMessages/dataStore.ts @@ -89,7 +89,7 @@ async function update(message: ServiceMessage): Promise { } catch (e: any) { reject(`Unknown data error in stored document: ${e.message}`) } - } + }, ) }) } diff --git a/src/data/sofieInstances/dataStore.ts b/src/data/sofieInstances/dataStore.ts index 702f0e9..20a344f 100644 --- a/src/data/sofieInstances/dataStore.ts +++ b/src/data/sofieInstances/dataStore.ts @@ -109,7 +109,7 @@ async function update(instance: SofieInstance): Promise { } catch (e: any) { reject(`Unknown data error in stored document: ${e.message}`) } - } + }, ) }) } diff --git a/src/distribution/api.ts b/src/distribution/api.ts index de95506..d9aeed5 100644 --- a/src/distribution/api.ts +++ b/src/distribution/api.ts @@ -42,7 +42,7 @@ function distribute(message: ServiceMessage, isUpdate = false): void { if (!targetInstanceId || !messageId) { logger.warn( `Unable to add job for message, missing ${targetInstanceId ? 'message id' : targetInstanceId}`, - { command, serviceMessage: message, instance: distribution.instance } + { command, serviceMessage: message, instance: distribution.instance }, ) continue } @@ -86,7 +86,7 @@ function recall(message: ServiceMessage): void { if (!targetInstanceId || !messageId) { logger.warn( `Unable to add job for message, missing ${targetInstanceId ? 'message id' : targetInstanceId}`, - { command: Command.DELETE, serviceMessage: message, instance: distribution.instance } + { command: Command.DELETE, serviceMessage: message, instance: distribution.instance }, ) continue } @@ -144,7 +144,7 @@ async function retryingExecution(job: Job): Promise { } else { setTimeout( () => callAsyncAsCallback(retryingExecution, undefined, job), - job.waitingTimeBeforeRetry ?? DEFAULT_JOB_WAITING_PERIOD_BEFORE_RETRY + job.waitingTimeBeforeRetry ?? DEFAULT_JOB_WAITING_PERIOD_BEFORE_RETRY, ) } } diff --git a/src/distribution/processors.ts b/src/distribution/processors.ts index 55073ec..b981408 100644 --- a/src/distribution/processors.ts +++ b/src/distribution/processors.ts @@ -81,7 +81,7 @@ processors[Command.DELETE] = { const message = await messageStore.read(messageId) if (!message) { logger.debug( - `Aborted recall of message ${messageId} from ${targetInstanceId}, message is not in datastore` + `Aborted recall of message ${messageId} from ${targetInstanceId}, message is not in datastore`, ) return } diff --git a/src/lib/lib.ts b/src/lib/lib.ts index 3140adc..c2de182 100644 --- a/src/lib/lib.ts +++ b/src/lib/lib.ts @@ -44,7 +44,7 @@ export async function getExternalVersions(serverHost: string): Promise): Promise { try { const hosts = [] diff --git a/src/util/logger.ts b/src/util/logger.ts index d48ed75..624c965 100644 --- a/src/util/logger.ts +++ b/src/util/logger.ts @@ -7,7 +7,7 @@ if (process.env.NODE_ENV === 'production') { new transports.Console({ level: 'error', format: format.json(), - }) + }), ) } else { const logLevel = process.env.DEBUG === 'true' ? 'debug' : 'warn' @@ -15,7 +15,7 @@ if (process.env.NODE_ENV === 'production') { new transports.Console({ level: logLevel, format: format.combine(format.colorize(), format.simple()), - }) + }), ) logger.debug('Logging initialized at debug level') } diff --git a/yarn.lock b/yarn.lock index 4365805..2947663 100644 --- a/yarn.lock +++ b/yarn.lock @@ -701,6 +701,11 @@ mkdirp "^1.0.4" rimraf "^3.0.2" +"@pkgr/core@^0.1.0": + version "0.1.1" + resolved "https://registry.yarnpkg.com/@pkgr/core/-/core-0.1.1.tgz#1ec17e2edbec25c8306d424ecfbf13c7de1aaa31" + integrity sha512-cq8o4cWH0ibXh9VGi5P20Tu9XF/0fFXl9EUinr9QfTM7a7p0oTA4iJRCQWppXR1Pg8dSM0UCItCkPwsk9qWWYA== + "@seald-io/binary-search-tree@^1.0.3": version "1.0.3" resolved "https://registry.yarnpkg.com/@seald-io/binary-search-tree/-/binary-search-tree-1.0.3.tgz#165a9a456eaa30d15885b25db83861bcce2c6a74" @@ -2318,6 +2323,14 @@ eslint-plugin-prettier@^4.2.1: dependencies: prettier-linter-helpers "^1.0.0" +eslint-plugin-prettier@^5.1.3: + version "5.1.3" + resolved "https://registry.yarnpkg.com/eslint-plugin-prettier/-/eslint-plugin-prettier-5.1.3.tgz#17cfade9e732cef32b5f5be53bd4e07afd8e67e1" + integrity sha512-C9GCVAs4Eq7ZC/XFQHITLiHJxQngdtraXaM+LoUFoFp/lHNl2Zn8f3WQbe9HvTBBQ9YnKFB0/2Ajdqwo5D1EAw== + dependencies: + prettier-linter-helpers "^1.0.0" + synckit "^0.8.6" + eslint-scope@^5.1.1: version "5.1.1" resolved "https://registry.yarnpkg.com/eslint-scope/-/eslint-scope-5.1.1.tgz#e786e59a66cb92b3f6c1fb0d508aab174848f48c" @@ -5730,6 +5743,14 @@ symbol-tree@^3.2.4: resolved "https://registry.yarnpkg.com/symbol-tree/-/symbol-tree-3.2.4.tgz#430637d248ba77e078883951fb9aa0eed7c63fa2" integrity sha512-9QNk5KwDF+Bvz+PyObkmSYjI5ksVUYtjW7AU22r2NKcfLJcXp96hkDWU3+XndOsUb+AQ9QhfzfCT2O+CNWT5Tw== +synckit@^0.8.6: + version "0.8.8" + resolved "https://registry.yarnpkg.com/synckit/-/synckit-0.8.8.tgz#fe7fe446518e3d3d49f5e429f443cf08b6edfcd7" + integrity sha512-HwOKAP7Wc5aRGYdKH+dw0PRRpbO841v2DENBtjnR5HFWoiNByAl7vrx3p0G/rCyYXQsrxqtX48TImFtPcIHSpQ== + dependencies: + "@pkgr/core" "^0.1.0" + tslib "^2.6.2" + tar@^6.0.2, tar@^6.1.11, tar@^6.1.2: version "6.1.13" resolved "https://registry.yarnpkg.com/tar/-/tar-6.1.13.tgz#46e22529000f612180601a6fe0680e7da508847b"