-
Notifications
You must be signed in to change notification settings - Fork 34
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 missing tests #91
Conversation
This adds two failing tests to highlight bugs and a passing but previously missing test. The missing test added is for calling `set` which was destructured from `import Ember from 'ember'` One failing test is to handle the case where `Ember.computed` is called from an import that isn't named `Ember`, eg ``` import E from 'ember'; E.computed() ``` Another failing test illustrates that ember import bindings are clobbered if followed by any other default import, as in: ``` import Ember from 'ember'; import AnythingElse from 'anywhere'; ```
fb7be47
to
c84bd0d
Compare
cc @rwjblue |
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.
Sure would be nice if there was something like a todo
test 😉
Hehe. Confirm. Really need to get that wired up right through testem and whatnot. |
OK, just did a pass across this rule to fix the largest issues that @hjdivad pointed out above. I pushed the fix commits directly to this branch, so it should be ready for review... |
tests/lib/rules/no-side-effect-cp.js
Outdated
code: ` | ||
import Ember from 'ember'; | ||
import SomethingElse from 'something-else'; | ||
const { set } = Ember; |
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 we space in these lines in to line them up with the code below. It's a bit hard to read like this.
tests/lib/rules/no-side-effect-cp.js
Outdated
{ | ||
code: ` | ||
import Ember from 'ember'; | ||
const { set } = Ember; |
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.
Same here re: spacing.
tests/lib/rules/no-side-effect-cp.js
Outdated
}, | ||
{ | ||
code: ` | ||
import E from 'ember'; |
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.
Same here re: spacing.
lib/utils/computed-property.js
Outdated
} | ||
return false; | ||
} | ||
|
||
module.exports = function isCPGetter(node) { | ||
return isCPDesc(node, 'get') || isCPAccessor(node) || isPrototypeExtCP(node); | ||
module.exports = function isCPGetter(node, importedCPName, importedEmberName) { |
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.
For some reason it feels more natural to have importedEmberName
come before importedCPName
, like in hierarchical order.
lib/utils/computed-property.js
Outdated
return true; | ||
} | ||
if (callee.type === 'MemberExpression') { | ||
let caller = getCaller(callee); | ||
return caller === 'Ember.computed' || caller === 'Em.computed'; | ||
return caller === 'Ember.computed' || caller === 'Em.computed' || caller === importedEmberName + '.computed'; |
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.
You could template string ${importedEmberName}.computed
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.
This is looking good. It appears to do as advertised. I just dropped a few comments.
LGTM 👍 |
Fixes a number of the errors previously identified, as well as a few additional ones (tests added in this commit).
bc997b1
to
23bbb0b
Compare
@scalvert - I believe that the latest push addresses all of your comments. Let me know if you spot anything else... |
LGTM |
* Add missing tests This adds two failing tests to highlight bugs and a passing but previously missing test. The missing test added is for calling `set` which was destructured from `import Ember from 'ember'` One failing test is to handle the case where `Ember.computed` is called from an import that isn't named `Ember`, eg ``` import E from 'ember'; E.computed() ``` Another failing test illustrates that ember import bindings are clobbered if followed by any other default import, as in: ``` import Ember from 'ember'; import AnythingElse from 'anywhere'; ``` * Clean up no-side-effect-cp rule. Fixes a number of the errors previously identified, as well as a few additional ones (tests added in this commit).
This adds a couple of failing tests and a passing but previously missing test.
The missing test added is for calling
set
which was destructured fromimport Ember from 'ember'
One failing test is to handle the case where
Ember.computed
is called from an import that isn't namedEmber
, egAnother failing test illustrates that ember import bindings are clobbered if followed by any other default import, as in:
tl;dr things to fix
context
argEmber.computed