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

Doesn't work for deconstruction if there is an intermediate step #32

Open
gunar opened this issue Jun 3, 2016 · 2 comments
Open

Doesn't work for deconstruction if there is an intermediate step #32

gunar opened this issue Jun 3, 2016 · 2 comments

Comments

@gunar
Copy link

gunar commented Jun 3, 2016

Works (gives error)

const { flow, get, reject} = require('lodash/fp')
flow(reject('a'), reject('b'))

Doesn't work (no error)

const _ = require('lodash/fp')
const { flow, get, reject } = _
flow(reject('a'), reject('b'))
@jfmengels
Copy link
Owner

(Man, I was sure I answered this one, sorry for the delay)

Yeah, this is kind of a hard thing to do with ESLint, as you have to "manually" track the variables, the assignations and stuff, which is possible, but just requires quite a lot more time and investment. It is also a lot more fragile if the values are re-assigneable or some new variable named like Lodash gets introduced through a variable or a parameter.

var _ = require('lodash/fp')
if (CONDITION) {
  _ = require('something-else');
}
var { flow, get, reject } = _
flow(reject('a'), reject('b'))

I have added the help wanted label so that if someone has experience with this and wants to tackle it, they can have a go at it (and I'd be very grateful!), but this is definitely not an issue for a beginner. I will probably not tackle this issue before quite a while either. Maybe one day I'll build a tool to help solve this kind of thing, as it is frustratingly recurrent.

Out of curiosity, is this something that you noticed, or something you have in your code and that you noticed didn't give you an error? I'm wandering this is really a problem, or just a warning. Thanks for reporting though ;)

@gunar
Copy link
Author

gunar commented Jun 6, 2016

Cool. Thank you so much! 🙌 It's something I noticed that didn't give me an error. I'll keep an eye on this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants