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

New rule: no-attrs (resolves #52) #100

Merged
merged 6 commits into from
Aug 1, 2017
Merged

New rule: no-attrs (resolves #52) #100

merged 6 commits into from
Aug 1, 2017

Conversation

jbandura
Copy link
Collaborator

@jbandura jbandura commented Jul 15, 2017

This PR adds new rule regarding to #52

@michalsnik michalsnik changed the title New rule: no-attrs New rule: no-attrs (resolves #52) Jul 20, 2017
@michalsnik michalsnik self-requested a review July 20, 2017 07:13
* @param {ASTNode} node The node to check.
* @returns {boolean} Whether or not the node is a ThisExpression with name of attrs.
*/
function isThisAttrsExpression(node) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is Ember specific stuff so maybe we should put it in utils/ember.js. And actually I would argue that we don't need to add this to utils at all, it will probably be used only once so we can simply keep it in the rule's file. What do you think @jbandura ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, that's a good point actually. I moved it to the utils in order to write tests for this. On the other hand it's true that it might not be used outside of this rule. I can move it to the rule I think.


create(context) {
return {
MemberExpression(node) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Although it's only being ported I'm thinking whether we should scope this check to component files only and do not throw error if it's used in util or anywhere else. What do you think? Anyway I'm ok with postponing this update at the moment.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this is not something that we already check, then I'd suggest postponing it. If it is, I'll add the check :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have an util for checking that: https://github.com/ember-cli/eslint-plugin-ember/blob/master/lib/rules/order-in-components.js#L40

You should then add CallExpression:exit selector, store globally the found member expressions and then check if any of these exist inside that CallExpression. For the reference I wrote a similar check here: https://github.com/vuejs/eslint-plugin-vue/blob/master/lib/rules/no-side-effects-in-computed-properties.js#L39

Copy link
Member

@michalsnik michalsnik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok I think it's good to go

@michalsnik michalsnik merged commit d27e76d into master Aug 1, 2017
@michalsnik michalsnik deleted the 52-no-attrs branch August 1, 2017 07:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants