Repository navigation
ESLint: Restrict removed Lodash functions - #41651
Conversation
|
This is great! One thing I'm wondering is if we should extend the rule to include all lodash methods that currently aren't being used anywhere in the codebase to prevent new additions altogether 🤔 not sure whether that would have to be be a manual list of all the methods or how that could be achieved though. |
Good point - I gave this a bit of thought and concluded that it's easy enough to compile that list, however there is a downside. We can't guarantee that there is an easy native JS or existing custom solution around some of the Lodash methods that we currently don't use. So I prefer risking this and potentially creating a little bit more additional work for us, rather than breaking developer experience and making it more difficult for folks to contribute to the project. |
|
Size Change: 0 B Total Size: 1.24 MB ℹ️ View Unchanged
|
|
That being said, I'd love to go ahead and merge this, so we can include these import restriction rules in future Lodash removal PRs when applicable. If reconsider, we can extend the list in another PR anyway. |
ntsekouras
left a comment
There was a problem hiding this comment.
Looks good, thanks @tyxla !
|
Thanks for the great feedback here, folks 🙌 |
What?
This PR restricts importing of Lodash functions that we've already migrated from. See https://github.com/WordPress/gutenberg/pulls?q=is%3Apr+is%3Aclosed+author%3Atyxla+Lodash+updated%3A%3E2022-06-01+ for a list of the recent migration PRs.
Why?
The short-term goal is to avoid reintroducing Lodash functions that we've moved away from. The long-term goal is to eventually get rid of the entirety of Lodash and restrict its imports completely.
How?
We introduce an extension to the
no-restricted-importsrule that prevents importing Lodash functions that have already been migrated.Testing Instructions
Try importing a restricted function like
reversefrom Lodash and verify you get an ESLint error.