From 06eba07d6b73ba2650f581372fd613f89385993c Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Mon, 26 Jul 2021 11:35:15 -0700 Subject: [PATCH] [eslint] enable `brace-style` --- .eslintrc | 3 +++ lib/default_stream.js | 21 +++++++++++++++------ test/double_end.js | 3 +-- 3 files changed, 19 insertions(+), 8 deletions(-) diff --git a/.eslintrc b/.eslintrc index 9c181942..235361f5 100644 --- a/.eslintrc +++ b/.eslintrc @@ -8,6 +8,9 @@ "Promise": false, }, "rules": { + "brace-style": ["error", "1tbs", { + "allowSingleLine": true, + }], "comma-dangle": ["error", "never"], "comma-spacing": [2, { "before": false, diff --git a/lib/default_stream.js b/lib/default_stream.js index b750eab8..4647d93b 100644 --- a/lib/default_stream.js +++ b/lib/default_stream.js @@ -13,18 +13,27 @@ module.exports = function () { var c = typeof buf === 'string' ? buf.charAt(i) : String.fromCharCode(buf[i]); - if (c === '\n') { flush(); } - else { line += c; } + if (c === '\n') { + flush(); + } else { + line += c; + } } } function flush() { if (fs.writeSync && (/^win/).test(process.platform)) { - try { fs.writeSync(1, line + '\n'); } - catch (e) { stream.emit('error', e); } + try { + fs.writeSync(1, line + '\n'); + } catch (e) { + stream.emit('error', e); + } } else { - try { console.log(line); } - catch (e) { stream.emit('error', e); } + try { + console.log(line); + } catch (e) { + stream.emit('error', e); + } } line = ''; } diff --git a/test/double_end.js b/test/double_end.js index af630cae..a3445ab6 100644 --- a/test/double_end.js +++ b/test/double_end.js @@ -29,8 +29,7 @@ test(function (tt) { var atExpected; try { to._onTimeout(); - } - catch (e) { + } catch (e) { stackExpected = stripFullStack(e.stack)[1]; stackExpected = stackExpected.replace('double_end.js', 'double_end/double.js'); stackExpected = stackExpected.trim();