-
-
Notifications
You must be signed in to change notification settings - Fork 204
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Detecting computed properties with MemberExpressions #98
Conversation
@@ -321,6 +321,15 @@ eslintTester.run('order-in-components', rule, { | |||
});`, | |||
parserOptions: { ecmaVersion: 6, sourceType: 'module' }, | |||
}, | |||
{ | |||
code: `export default Component.extend({ | |||
foo: computed(function() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's add one more test - failing one with computed().volatile
in wrong order
lib/utils/ember.js
Outdated
@@ -129,6 +129,9 @@ function isObserverProp(node) { | |||
} | |||
|
|||
function isComputedProp(node) { | |||
if (utils.isMemberExpression(node.callee) && utils.isCallExpression(node.callee.object)) { | |||
return isModule(node.callee.object, 'computed') && utils.isIdentifier(node.callee.property); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We were speaking about white listing four methods that are supported on CPs (meta
, property
, readOnly
and volatile
regarding https://www.emberjs.com/api/ember/2.14.0/classes/Ember.ComputedProperty). Are you going to add them?
1e374eb
to
a953da0
Compare
Good job @jbandura ! 👍 |
Resolves #83
Problem:
Linter doesn't recognize following code as a computed property:
Solution:
The computed property is determined based on whether the node is a
CallExpression
withIdentifier
of typecomputed
as callee. However in the above case, we have aMemberExpression
. The solution involves checking forMemberExpression
with computedCallExpression
.