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

flatMap not detected as part of a lodash chain #49

Closed
lukeapage opened this issue Mar 28, 2016 · 6 comments
Closed

flatMap not detected as part of a lodash chain #49

lukeapage opened this issue Mar 28, 2016 · 6 comments
Labels

Comments

@lukeapage
Copy link
Contributor

this

_.chain(a).flatMap('b').map('c').value()

is hitting prefer-lodash-method because flatMap isn't marked chainable.

But am also confused by the lodash documentation - I raised this..
lodash/lodash#2166
because it looks like everything is chainable.. so am not sure whether everything should be chainable or just to add flatMap to the chainable list..

@ganimomer
Copy link
Contributor

The lodash docs are a bit fuzzy on the matter (there's separate docs for _.prototype.flatMap), but it looks like you're right, this is a bug in the plugin.
I tried running _(arr).flatMap() and it returned a wrapper, so it's chainable.

@lukeapage
Copy link
Contributor Author

Even things the docs say arent possible e.g. join return a wrapper. We will see what jdalton says in a bit anyway..

@ganimomer
Copy link
Contributor

I answered you by myself in the issue. The docs are unclear about _.flatMap, and what you reported here looks like an actual bug, so both issues you opened are valid.

@lukeapage
Copy link
Contributor Author

So now I understand - it looks to me like there is another bug - the lodash utils exits early if the method is not chainable, without checking to see if its implicit or explicit...

@lukeapage
Copy link
Contributor Author

@ganimomer ganimomer added the bug label Mar 28, 2016
@ganimomer
Copy link
Contributor

Right again! I'll open a separate issue.

lukeapage added a commit to lukeapage/eslint-plugin-lodash that referenced this issue Mar 29, 2016
ganimomer added a commit that referenced this issue Mar 29, 2016
Sync chainable in v4 with lodash master. Fixes #49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants