Skip to content

Commit

Permalink
Apply lint fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Brad-Turner committed Oct 20, 2023
1 parent d0c3af4 commit 4f8e81b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 15 deletions.
23 changes: 10 additions & 13 deletions lib/logging.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import getEntityName from './get-entity-name'

export const logEmitter = new EventEmitter()

function extractErrorInformation(error) {
function extractErrorInformation (error) {
const source = error.originalError || error
try {
const data = JSON.parse(source.message)
Expand All @@ -21,7 +21,7 @@ function extractErrorInformation(error) {
}
}

export function formatLogMessageOneLine(logMessage) {
export function formatLogMessageOneLine (logMessage) {
const { level } = logMessage
if (!level) {
return logMessage.toString().replace(/\s+/g, ' ')
Expand Down Expand Up @@ -62,7 +62,7 @@ export function formatLogMessageOneLine(logMessage) {
}
}

export function formatLogMessagelogFileWriteStream(logMessage) {
export function formatLogMessagelogFileWriteStream (logMessage) {
const { level } = logMessage
if (level === 'info' || level === 'warning') {
return logMessage
Expand Down Expand Up @@ -96,14 +96,11 @@ export function formatLogMessagelogFileWriteStream(logMessage) {
}

// Display all errors
export function displayErrorLog(errorLog) {
export function displayErrorLog (errorLog) {
if (errorLog.length) {
const count = errorLog.reduce(
(count, curr) => {
if (Object.prototype.hasOwnProperty.call(curr, 'warning'))
count.warnings++
else if (Object.prototype.hasOwnProperty.call(curr, 'error'))
count.errors++
if (Object.prototype.hasOwnProperty.call(curr, 'warning')) { count.warnings++ } else if (Object.prototype.hasOwnProperty.call(curr, 'error')) { count.errors++ }
return count
},
{ warnings: 0, errors: 0 }
Expand Down Expand Up @@ -134,7 +131,7 @@ export function displayErrorLog(errorLog) {
* @param {Record<string, unknown>[]} errorLog
* @returns {Promise<void>}
*/
export async function writeErrorLogFile(destination, errorLog) {
export async function writeErrorLogFile (destination, errorLog) {
const formatLogTransformer = new Transform({
objectMode: true,
transform: (chunk, encoding, callback) => {
Expand Down Expand Up @@ -165,8 +162,8 @@ export async function writeErrorLogFile(destination, errorLog) {
* @param {Record<string,unknown>[]} log
* @returns {Promise<void>}
*/
export function setupLogging(log) {
function errorLogger(level, error) {
export function setupLogging (log) {
function errorLogger (level, error) {
const logMessage = {
ts: new Date().toJSON(),
level,
Expand All @@ -188,8 +185,8 @@ export function setupLogging(log) {
* @template {Ctx}
* @param {import('listr').ListrTaskWrapper<Ctx>} task
*/
export function logToTaskOutput(task) {
function logToTask(logMessage) {
export function logToTaskOutput (task) {
function logToTask (logMessage) {
const content = formatLogMessageOneLine(logMessage)
const symbols = {
info: figures.tick,
Expand Down
4 changes: 2 additions & 2 deletions test/logging.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
} from '../lib/logging'
import figures from 'figures'

function isValidDate(date) {
function isValidDate (date) {
return !isNaN(Date.parse(date))
}

Expand Down Expand Up @@ -207,7 +207,7 @@ test('sets up logging via event emitter', () => {
expect(logEmitterAddListenerSpy.mock.calls[1][0]).toBe('warning')
expect(logEmitterAddListenerSpy.mock.calls[2][0]).toBe('error')

function assertLogValues(logMessage) {
function assertLogValues (logMessage) {
if (logMessage.level === 'info') {
// Info messages are not logged
return
Expand Down

0 comments on commit 4f8e81b

Please sign in to comment.