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
Add new no-get-properties
rule
#403
Conversation
'const { abc } = getProperties(this, MY_PROP);', | ||
'const { abc } = getProperties(this, [MY_PROP]);' | ||
], | ||
invalid: [ |
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.
can you add a test case for e.g. this.getProperties('while')
? this should not convert to let { while } = ...
since that would be illegal. but then again, this rule only triggers when there was already destructuring used before, right?
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.
Interesting! However, I don't think that applies here, because this rule is only suggesting removing the getProperties
call, and not changing the existing destructuring.
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.
FWIW, applying this rule across the board is not "safe".
Specifically, destructuring from any object that is an Ember.ObjectProxy
, an Ember.ArrayProxy
, or any object with an unknownProperty
method will result in an error. The documentation for the new rule should be updated to include this information.
I believe the rule should only apply to this.getProperties
and getProperties(this, ...)
by default (calling someForeignObject.getProperties
is much more problematic due to the exceptions I mentioned above).
@rwjblue thanks for the reminder about proxies! I removed the autofixer as a result. I also updated the documentation to call that out. However, I would prefer if the rule continues to catch
How does that sound? |
no-unnecessary-get-properties
ruleno-get-properties
rule
I would propose to keep the autofixer, but make the rule configurable. By default it would only work for |
There are a number of reported issues on that repo around this exact issue. The codemod absolutely should be restricted to |
@rwjblue thanks for calling that out, I updated this rule to be limited to @Turbo87 I would still lean towards leaving the autofixer out because:
However, I'd like to follow-up in a separate PR to add an |
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.
👍
No description provided.