-
Notifications
You must be signed in to change notification settings - Fork 4
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
Prefer Lodash get #4
Comments
No qualms with this at all. Sounds good to me. 👍 |
How deep is too deep or would that be determined on a per-project basis? |
default depth is 3, which sounds like a reasonable baseline to me |
I'm generally for it although to play devil's advocate:
Having said that, there's definitely valid cases for deep access (e.g. retrieving something from a dumb but deeply nested data structure) where One more thing — in our codebase I see quite a few occurrences of triple nesting such as |
Yeah, great points, @kangax. For some added context, the use case that brought this up in the first place was our Contentful entries. A common resource like a hero image url could come back nested as follows: ...and that's following normal practices for Contentful data modeling. Error handling/alerting is a different question though, and probably something better left to the application engineers to determine. |
re: that thread in quincy-2337, it would be great if this lint config also enforced importing lodash as |
Thats a slightly different conversation @GLosch -- this one is talking about preferring get for lookups in deeply nested objects. What you're talking about is importing the whole lodash module vs importing specific modules as necessary. I disagree with you on this one -- let's open up a new issue to discuss? |
Opened #5 for that discussion ^ /cc @GLosch @thinkaxelthink |
awesome, thanks |
The problem
In code reviews, a common request is to use Lodash
_.get
in place of referencing deeply nested data structures likefoo.bar.moreFoo.moreBar
to avoid potential JavaScript errors that would break the page. Implementing theprefer-get
rule here would take care of this.The text was updated successfully, but these errors were encountered: