From 742860d3aa432a9841aa3843c418de9b06153746 Mon Sep 17 00:00:00 2001 From: tyankatsu Date: Sun, 8 Aug 2021 00:02:16 +0900 Subject: [PATCH] fix: check pattern that CallExpression's arguments include CallExpression --- .../no-use-computed-property-like-method.js | 3 + .../no-use-computed-property-like-method.js | 64 +++++++++++++++++++ 2 files changed, 67 insertions(+) diff --git a/lib/rules/no-use-computed-property-like-method.js b/lib/rules/no-use-computed-property-like-method.js index 1add2c343..c1c8ca765 100644 --- a/lib/rules/no-use-computed-property-like-method.js +++ b/lib/rules/no-use-computed-property-like-method.js @@ -228,6 +228,9 @@ module.exports = { if (node.parent.type !== 'MemberExpression') return if (node.parent.property.type !== 'Identifier') return + if (node.parent.parent.type !== 'CallExpression') return + if (node.parent.parent.callee.type !== 'MemberExpression') return + if (!Object.is(node.parent.parent.callee, node.parent)) return const thisMember = node.parent.property.name diff --git a/tests/lib/rules/no-use-computed-property-like-method.js b/tests/lib/rules/no-use-computed-property-like-method.js index b6e5e6958..902f29b19 100644 --- a/tests/lib/rules/no-use-computed-property-like-method.js +++ b/tests/lib/rules/no-use-computed-property-like-method.js @@ -418,6 +418,26 @@ tester.run('no-use-computed-property-like-method', rule, { } ` + }, + { + filename: 'test.vue', + code: ` + + ` } ], invalid: [ @@ -698,6 +718,50 @@ tester.run('no-use-computed-property-like-method', rule, { errors: [ 'Use this.computedReturnNothing instead of this.computedReturnNothing().' ] + }, + { + filename: 'test.vue', + code: ` + + `, + errors: [ + 'Use this.computedReturnString instead of this.computedReturnString().' + ] + }, + { + filename: 'test.vue', + code: ` + + `, + errors: [ + 'Use this.computedReturnArray instead of this.computedReturnArray().', + 'Use this.computedReturnArray2 instead of this.computedReturnArray2().' + ] } ] })