summaryrefslogtreecommitdiff
path: root/tools/node_modules/eslint/lib/rules/curly.js
diff options
context:
space:
mode:
authorcjihrig <cjihrig@gmail.com>2019-11-22 14:17:22 -0500
committercjihrig <cjihrig@gmail.com>2019-11-25 11:55:40 -0500
commit90fb308de42575adeed82d864da57148049185b3 (patch)
tree79d362bf7f18f1088da78b8b3073252b059b7c3f /tools/node_modules/eslint/lib/rules/curly.js
parent02d4c742369975fd7499bb242be61bbb1f8fc1ab (diff)
downloadandroid-node-v8-90fb308de42575adeed82d864da57148049185b3.tar.gz
android-node-v8-90fb308de42575adeed82d864da57148049185b3.tar.bz2
android-node-v8-90fb308de42575adeed82d864da57148049185b3.zip
tools: update ESLint to 6.7.1
Update ESLint to 6.7.1 PR-URL: https://github.com/nodejs/node/pull/30598 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Michaƫl Zasso <targos@protonmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Diffstat (limited to 'tools/node_modules/eslint/lib/rules/curly.js')
-rw-r--r--tools/node_modules/eslint/lib/rules/curly.js13
1 files changed, 9 insertions, 4 deletions
diff --git a/tools/node_modules/eslint/lib/rules/curly.js b/tools/node_modules/eslint/lib/rules/curly.js
index 93c74d11fc..ee2fe4dceb 100644
--- a/tools/node_modules/eslint/lib/rules/curly.js
+++ b/tools/node_modules/eslint/lib/rules/curly.js
@@ -97,10 +97,15 @@ module.exports = {
* @private
*/
function isOneLiner(node) {
- const first = sourceCode.getFirstToken(node),
- last = sourceCode.getLastToken(node);
+ if (node.type === "EmptyStatement") {
+ return true;
+ }
+
+ const first = sourceCode.getFirstToken(node);
+ const last = sourceCode.getLastToken(node);
+ const lastExcludingSemicolon = astUtils.isSemicolonToken(last) ? sourceCode.getTokenBefore(last) : last;
- return first.loc.start.line === last.loc.end.line;
+ return first.loc.start.line === lastExcludingSemicolon.loc.end.line;
}
/**
@@ -240,7 +245,7 @@ module.exports = {
if (node.type === "IfStatement" && node.consequent === body && requiresBraceOfConsequent(node)) {
expected = true;
} else if (multiOnly) {
- if (hasBlock && body.body.length === 1) {
+ if (hasBlock && body.body.length === 1 && !isLexicalDeclaration(body.body[0])) {
expected = false;
}
} else if (multiLine) {