From 4d3c3f039af08b954fbbba1e9a50979ffc98592b Mon Sep 17 00:00:00 2001 From: Ruben Bridgewater Date: Tue, 13 Feb 2018 03:01:46 +0100 Subject: [PATCH] tools: enable no-unsafe-finally This enables the `no-unsafe-finally` eslint rule to make sure we have a proper control flow in try / catch. PR-URL: https://github.com/nodejs/node/pull/18745 Reviewed-By: Ben Noordhuis Reviewed-By: Colin Ihrig Reviewed-By: Luigi Pinca Reviewed-By: James M Snell --- .eslintrc.yaml | 1 + test/common/index.js | 14 +++----------- 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/.eslintrc.yaml b/.eslintrc.yaml index 0839e352cd399d..e73e97dede44af 100644 --- a/.eslintrc.yaml +++ b/.eslintrc.yaml @@ -152,6 +152,7 @@ rules: }] no-tabs: error no-trailing-spaces: error + no-unsafe-finally: error object-curly-spacing: [error, always] one-var-declaration-per-line: error operator-linebreak: [error, after] diff --git a/test/common/index.js b/test/common/index.js index e8546db3a2f4ea..8ffeda42dfd52c 100644 --- a/test/common/index.js +++ b/test/common/index.js @@ -504,21 +504,13 @@ exports.canCreateSymLink = function() { const whoamiPath = path.join(process.env['SystemRoot'], 'System32', 'whoami.exe'); - let err = false; - let output = ''; - try { - output = execSync(`${whoamiPath} /priv`, { timout: 1000 }); + const output = execSync(`${whoamiPath} /priv`, { timout: 1000 }); + return output.includes('SeCreateSymbolicLinkPrivilege'); } catch (e) { - err = true; - } finally { - if (err || !output.includes('SeCreateSymbolicLinkPrivilege')) { - return false; - } + return false; } } - - return true; }; exports.getCallSite = function getCallSite(top) {