From c1c47cf496c9ace6c836dd4a59c0951977ef0d9f Mon Sep 17 00:00:00 2001 From: Matt Simerson Date: Tue, 12 Dec 2023 20:57:09 -0800 Subject: [PATCH] style(es6): eslint prefer-template --- index.js | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/index.js b/index.js index b0a967d..229359e 100644 --- a/index.js +++ b/index.js @@ -70,7 +70,7 @@ exports.get_logs = function (req, res) { // spawning a grep process is quite a lot faster than fs.read // (yes, I benchmarked it) exports.grepWithShell(log, uuid, function (err, matched) { - if (err) return res.send('

' + err + '

'); + if (err) return res.send(`

${err}

`); exports.asHtml(uuid, matched, function (html) { res.send(html); @@ -127,7 +127,7 @@ exports.asHtml = function (uuid, matched, done) { if (uuidMatch && uuidMatch[1]) { transId = uuidMatch[1].match(/\.([0-9]{1,2})$/); } - if (transId && transId[1]) replaceString = '[' + transId[1] + '] '; + if (transId && transId[1]) replaceString = `[${transId[1]}] `; let trimmed = line .replace(/\[[A-F0-9\-.]{12,40}\] /, replaceString) // UUID @@ -141,7 +141,7 @@ exports.asHtml = function (uuid, matched, done) { trimmed = trimmed.replace(/(?: [a-z.-]+)? haraka: /, ' '); } - rawLogs += trimmed + '
'; + rawLogs += `${trimmed}
`; if (/\[karma/.test(line) && /awards/.test(line)) { lastKarmaLine = line; } @@ -154,13 +154,13 @@ exports.asHtml = function (uuid, matched, done) { } done( - htmlHead() + + `${htmlHead() + htmlBody( `for connection ${uuid} on ${monthDay}`, getAwards(awardNums).join(''), getResolutions(awardNums).join('') ) + - rawLogs + '' + rawLogs}` ); } @@ -190,13 +190,12 @@ function getAwards (awardNums) { const listItems = []; awards.sort(sortByAward).forEach(function (a) { - const start = '
  • ' + a.award + ', '; + const start = `
  • ${a.award}, `; if (a.reason) { - listItems.push(start + a.reason + ' (' + a.value + ')
  • '); + listItems.push(`${start + a.reason} (${a.value})`); return; } - listItems.push(start + a.pi_name + ' ' + a.property + - ' ' + a.value + ''); + listItems.push(`${start + a.pi_name} ${a.property} ${a.value}`); }); return listItems; } @@ -216,7 +215,7 @@ function getResolutions (awardNums) { if (!a.resolution) return; if (resolutionSeen[a.resolution]) return; resolutionSeen[a.resolution] = true; - listItems.push('
  • ' + a.resolution + '
  • '); + listItems.push(`
  • ${a.resolution}
  • `); }); return listItems; } @@ -248,19 +247,19 @@ function htmlBody (uuid, awards, resolve) { your IT helpdesk or Systems Administrator and ask them for help.

    '; if (awards) { - str += '

    Policy Rules Matched

    \ - '; + str += `

    Policy Rules Matched

    \ + `; } if (resolve) { - str += '

    Steps to Resolve

    \ - '; + str += `

    Steps to Resolve

    \ + `; } - str += '
    \ + str += `
    \

    Raw Logs

    \ -

    ' + uuid + '

    \ +

    ${uuid}

    \
     \
    -        \n';
    +        \n`;
       return str;
     }