diff options
author | cjihrig <cjihrig@gmail.com> | 2019-11-22 14:17:22 -0500 |
---|---|---|
committer | cjihrig <cjihrig@gmail.com> | 2019-11-25 11:55:40 -0500 |
commit | 90fb308de42575adeed82d864da57148049185b3 (patch) | |
tree | 79d362bf7f18f1088da78b8b3073252b059b7c3f /tools/node_modules/eslint/lib/rules/no-constructor-return.js | |
parent | 02d4c742369975fd7499bb242be61bbb1f8fc1ab (diff) | |
download | android-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/no-constructor-return.js')
-rw-r--r-- | tools/node_modules/eslint/lib/rules/no-constructor-return.js | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/tools/node_modules/eslint/lib/rules/no-constructor-return.js b/tools/node_modules/eslint/lib/rules/no-constructor-return.js new file mode 100644 index 0000000000..4757770b7c --- /dev/null +++ b/tools/node_modules/eslint/lib/rules/no-constructor-return.js @@ -0,0 +1,62 @@ +/** + * @fileoverview Rule to disallow returning value from constructor. + * @author Pig Fang <https://github.com/g-plane> + */ + +"use strict"; + +//------------------------------------------------------------------------------ +// Rule Definition +//------------------------------------------------------------------------------ + +module.exports = { + meta: { + type: "problem", + + docs: { + description: "disallow returning value from constructor", + category: "Best Practices", + recommended: false, + url: "https://eslint.org/docs/rules/no-constructor-return" + }, + + schema: {}, + + fixable: null, + + messages: { + unexpected: "Unexpected return statement in constructor." + } + }, + + create(context) { + const stack = []; + + return { + onCodePathStart(_, node) { + stack.push(node); + }, + onCodePathEnd() { + stack.pop(); + }, + ReturnStatement(node) { + const last = stack[stack.length - 1]; + + if (!last.parent) { + return; + } + + if ( + last.parent.type === "MethodDefinition" && + last.parent.kind === "constructor" && + (node.parent.parent === last || node.argument) + ) { + context.report({ + node, + messageId: "unexpected" + }); + } + } + }; + } +}; |