Skip to content

Commit

Permalink
refactor: use optional chaining ?.
Browse files Browse the repository at this point in the history
  • Loading branch information
iiroj committed Jun 1, 2022
1 parent eae9622 commit 5f0a6a7
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/index.js
Expand Up @@ -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)) {
Expand Down
2 changes: 1 addition & 1 deletion lib/printTaskOutput.js
Expand Up @@ -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)
}
Expand Down

0 comments on commit 5f0a6a7

Please sign in to comment.