aboutsummaryrefslogtreecommitdiff
path: root/tools/eslint/lib/ast-utils.js
diff options
context:
space:
mode:
authorAnatoli Papirovski <apapirovski@mac.com>2017-10-14 07:39:20 -0400
committerAnatoli Papirovski <apapirovski@mac.com>2017-10-19 09:00:34 -0400
commit7babce90c9c87ccfa63169e86c7c26cdef3ebc26 (patch)
tree0f25530086c1b4d6949ccf9c8f8e6241ef1ab583 /tools/eslint/lib/ast-utils.js
parent10ef56359e5b4e3eb1e0ec96767375420b7e0fe5 (diff)
downloadandroid-node-v8-7babce90c9c87ccfa63169e86c7c26cdef3ebc26.tar.gz
android-node-v8-7babce90c9c87ccfa63169e86c7c26cdef3ebc26.tar.bz2
android-node-v8-7babce90c9c87ccfa63169e86c7c26cdef3ebc26.zip
tools: update to ESLint 4.8.0
PR-URL: https://github.com/nodejs/node/pull/16199 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Yuta Hiroto <hello@about-hiroppy.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Diffstat (limited to 'tools/eslint/lib/ast-utils.js')
-rw-r--r--tools/eslint/lib/ast-utils.js37
1 files changed, 20 insertions, 17 deletions
diff --git a/tools/eslint/lib/ast-utils.js b/tools/eslint/lib/ast-utils.js
index 98775f5ef0..47cc71990f 100644
--- a/tools/eslint/lib/ast-utils.js
+++ b/tools/eslint/lib/ast-utils.js
@@ -626,6 +626,9 @@ module.exports = {
// // setup...
// return function foo() { ... };
// })();
+ // obj.foo = (() =>
+ // function foo() { ... }
+ // )();
case "ReturnStatement": {
const func = getUpperFunction(parent);
@@ -635,6 +638,12 @@ module.exports = {
node = func.parent;
break;
}
+ case "ArrowFunctionExpression":
+ if (node !== parent.body || !isCallee(parent)) {
+ return true;
+ }
+ node = parent.parent;
+ break;
// e.g.
// var obj = { foo() { ... } };
@@ -655,16 +664,15 @@ module.exports = {
// [Foo = function() { ... }] = a;
case "AssignmentExpression":
case "AssignmentPattern":
- if (parent.right === node) {
- if (parent.left.type === "MemberExpression") {
- return false;
- }
- if (isAnonymous &&
- parent.left.type === "Identifier" &&
- startsWithUpperCase(parent.left.name)
- ) {
- return false;
- }
+ if (parent.left.type === "MemberExpression") {
+ return false;
+ }
+ if (
+ isAnonymous &&
+ parent.left.type === "Identifier" &&
+ startsWithUpperCase(parent.left.name)
+ ) {
+ return false;
}
return true;
@@ -809,19 +817,14 @@ module.exports = {
return 17;
case "CallExpression":
-
- // IIFE is allowed to have parens in any position (#655)
- if (node.callee.type === "FunctionExpression") {
- return -1;
- }
return 18;
case "NewExpression":
return 19;
- // no default
+ default:
+ return 20;
}
- return 20;
},
/**