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

"require-dependent-keys" false negative with computed decorator #97

Open
allthesignals opened this issue Apr 7, 2018 · 4 comments
Open

Comments

@allthesignals
Copy link

allthesignals commented Apr 7, 2018

The following code

import Model from 'ember-data/model';
import { attr, belongsTo } from 'ember-decorators/data';
import { computed } from 'ember-decorators/object';

export default class LayerModel extends Model {
  @belongsTo('layer-group') layerGroup
  @attr() style

  @computed('layerGroup.visible')
  get visible() {
    return true;
  }
}

Throws:

Do not use Computed Properties without dependent keys...

But a dependent key is provided.

image

package.json:

"ember-source": "~3.0.0",
//...
"eslint-plugin-ember-best-practices": "1.1.1",
"eslint-plugin-ember": "^5.0.0",
@allthesignals
Copy link
Author

Maybe it's just trying to get me to use an alias there instead ;)

@runspired
Copy link
Collaborator

Thanks for the report! definitely seems like something we should fix :)

@allthesignals
Copy link
Author

Added a failing test but not quite sure how to get the decorator modules imported and parsing correctly with class syntax...

@allthesignals
Copy link
Author

Another issue I have with this is that it asks us to use init or the constructor instead (when a computed has no dep keys), but it doesn't appear that query params are applied at the moment in which they are referenced:

constructor(...args) {
  super(...args);

    // these end up being the default values, in spite of query params
   // eg '?lat=-73.94513902424359&lng=40.75213197841276&zoom=15.08183388491034'
    const mapOptions = this.getProperties('center', 'zoom', 'pitch', 'bearing');
    this.set('initMapOptions', {
      ...mapOptions,
     // other things
    });
  }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants