From 5f0a6a73acf7cbe3dc8cd70e6dbc569dc452e2e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iiro=20J=C3=A4ppinen?= Date: Mon, 30 May 2022 15:34:27 +0300 Subject: [PATCH] refactor: use optional chaining `?.` --- lib/index.js | 2 +- lib/printTaskOutput.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/index.js b/lib/index.js index 2e250fecf..85420f546 100644 --- a/lib/index.js +++ b/lib/index.js @@ -109,7 +109,7 @@ const lintStaged = async ( printTaskOutput(ctx, logger) return true } catch (runAllError) { - if (runAllError && runAllError.ctx && runAllError.ctx.errors) { + if (runAllError?.ctx?.errors) { const { ctx } = runAllError if (ctx.errors.has(ConfigNotFoundError)) { diff --git a/lib/printTaskOutput.js b/lib/printTaskOutput.js index 831f8fd07..e3a4845d6 100644 --- a/lib/printTaskOutput.js +++ b/lib/printTaskOutput.js @@ -5,7 +5,7 @@ */ export const printTaskOutput = (ctx = {}, logger) => { if (!Array.isArray(ctx.output)) return - const log = ctx.errors && ctx.errors.size > 0 ? logger.error : logger.log + const log = ctx.errors?.size > 0 ? logger.error : logger.log for (const line of ctx.output) { log(line) }