Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Better to check that
nodeInitializedTo.type === 'CallExpression'
.Also need a test of course.
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.
Lack of a test case is the reason I left this PR as a draft. I'm not sure how to reproduce this in a test.
Would I import from the same path like
import { SOMETHING } from '@ember/array'
and make sure it doesn't have a callee?What would that even look like?
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.
I think maybe this could reproduce the error?
I think in this case,
node.InitializedTo.type
is no longer aCallExpression
but rather aMemberExpression
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.
@lin-ll when I add your test case,
without the fix above, I get the following error:
with the fix above, I get a legitimate linting error:
The linting error is a false positive. This rule probably should allow your test case but it currently doesn't.
So either way, it's not a valid test case for this fix.
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.
Hmm really? When I run that example (
yarn test tests/lib/rules/no-array-prototype-extensions.js
), I get the correct undefined error:Agreed that with your fix, it doesn't fix the false positive -- but it does seem like a valid way of reproducing this error