Skip to content
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

Merged
merged 4 commits into from
Jul 16, 2017

Conversation

jbandura
Copy link
Collaborator

@jbandura jbandura commented Jul 14, 2017

Resolves #83

Problem:

Linter doesn't recognize following code as a computed property:

foo: computed(function() {}).volatile()

Solution:

The computed property is determined based on whether the node is a CallExpression with Identifier of type computed as callee. However in the above case, we have a MemberExpression. The solution involves checking for MemberExpression with computed CallExpression.

@@ -321,6 +321,15 @@ eslintTester.run('order-in-components', rule, {
});`,
parserOptions: { ecmaVersion: 6, sourceType: 'module' },
},
{
code: `export default Component.extend({
foo: computed(function() {
Copy link
Member

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

@@ -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);
Copy link
Member

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?

@jbandura jbandura force-pushed the 83-support-member-functions branch from 1e374eb to a953da0 Compare July 15, 2017 12:23
@michalsnik
Copy link
Member

Good job @jbandura ! 👍

@michalsnik michalsnik merged commit e4532f0 into master Jul 16, 2017
@Turbo87 Turbo87 deleted the 83-support-member-functions branch July 17, 2017 06:32
@Turbo87 Turbo87 added the bug label Nov 15, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants