From 4313c4e45bf55f4550bbd8dd164c6515185f7261 Mon Sep 17 00:00:00 2001 From: Armano Date: Mon, 4 Sep 2017 22:12:33 +0200 Subject: [PATCH] Ensure that executeOnVueComponent is called after object instead of before. fixes #173 --- lib/utils/index.js | 2 +- .../lib/rules/return-in-computed-property.js | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/lib/utils/index.js b/lib/utils/index.js index 8a35c14b0..957a9d6c8 100644 --- a/lib/utils/index.js +++ b/lib/utils/index.js @@ -457,7 +457,7 @@ module.exports = { } return { - ObjectExpression (node) { + 'ObjectExpression:exit' (node) { if (!componentComments.some(el => el.loc.end.line === node.loc.start.line - 1) || isDuplicateNode(node)) return cb(node) }, diff --git a/tests/lib/rules/return-in-computed-property.js b/tests/lib/rules/return-in-computed-property.js index e1d290fba..0a32faf75 100644 --- a/tests/lib/rules/return-in-computed-property.js +++ b/tests/lib/rules/return-in-computed-property.js @@ -237,6 +237,25 @@ ruleTester.run('return-in-computed-property', rule, { message: 'Expected to return a value in "foo" computed property.', line: 4 }] + }, + { + filename: 'test.js', + code: ` + // @vue/component + export default { + computed: { + my_FALSE_test() { + let aa = 2; + this.my_id = aa; + } + } + } + `, + parserOptions, + errors: [{ + message: 'Expected to return a value in "my_FALSE_test" computed property.', + line: 5 + }] } ] })