-
Notifications
You must be signed in to change notification settings - Fork 135
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
Remove underscore from expensify-common and reduce usage of lodash and jQuery #704
Remove underscore from expensify-common and reduce usage of lodash and jQuery #704
Conversation
CLA Assistant Lite bot All contributors have signed the CLA ✍️ ✅ |
I have read the CLA Document and I hereby sign the CLA |
6d15818
to
4407b0b
Compare
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.
When migrating code from lodash to native JS you have to watch out for all possible null
/undefined
values, or places where a variable can be an object
/array
interchangeably. Left some comments
I can review this one as C+ @puneetlath |
@puneetlath I'm happy to do so - either instead or in addition - but let me know if you want to be the official reviewer here since it looks like you have the context! |
Ah yeah, here's the slack convo: |
@dangrous yeah I can take this one since I'm assigned to the issue. Though you're welcome to review as well if you like! |
Linting is failing @Skalakid |
@hungvu193 You can continue reviewing it's connected to this (@Skalakid needs to restore the rule and it'll be fine) |
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.
Looks good to me, @hungvu193 please double check that every lodash/underscore method is replaced correctly + watch out for empty values like null/undefined as these could break the logic.
@Skalakid Should we uninstall underscore
nad lodash
perhaps?
Looks good to me as well! |
@hungvu193 @blazejkustra All lint errors should be fixed now and I uninstalled |
@puneetlath @dangrous What are the next steps here? |
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.
Couple of broader questions here, feel free to ignore me if I don't have the right context. Mainly - it looks like we're not removing lodash or jquery fully, but from the PR title seems like we should be. Let me know!
|
||
// Use this deferred lib so we don't have a dependency on jQuery (so we can use this module in mobile) | ||
import {Deferred} from 'simply-deferred'; | ||
import {has} from 'lodash'; |
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.
maybe I'm misinterpreting the issue goal but shouldn't we be removing anything from lodash?
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.
Oh sorry, I forgot to update the title of the PR and its description. We decided to remove all these libraries only inside files that we will be using in react-native-live-markdown
and execute on the UI thread (ExpensiMark
, Src
etc). Also, we decided to move more complex underscore
functions to lodash
, like during migration to TS in E/App, because it doesn't make sense to rewrite them on our own in the utils file
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 updated the PR description
'arrow-body-style': 'off', | ||
'es/no-nullish-coalescing-operators': 'off', | ||
'rulesdir/prefer-underscore-method': 'off', | ||
'es/no-optional-chaining': 'off', |
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.
NAB - why are we turning off these rules?
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.
We turned off some ESlint rules because in some cases we had to use some JS features that were blocked by them, to make functions work the same
@@ -1,6 +1,5 @@ | |||
import $ from 'jquery'; |
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.
should we be removing/replacing this too?
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.
We decided to not migrate it because we don't have access to repos that are actually using this Network
file, and we couldn't test it. Replacing jQuery can introduce many critical regressions and require bigger logic changes
import has from 'lodash/has'; | ||
import {once} from 'lodash'; |
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.
same here - aren't we removing lodash?
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.
The same answer from above applies to it
I am closing this PR since I created a rebased version of it, that has all commits signed. Please continue reviewing/discussions in the new PR |
The original goal of this PR was to remove
underscore
,jQuery
, andlodash
from files that are connected toExpensiMark
so we can workletize these functions and enable thereact-native-live-markdown
to run parser on UI thread. We wanted to block usage of these libraries in the whole repo, however without knowing the use cases and without being able to test it inside the private Expensify reposthat uses some of these files, we decided to:underscore
from repo, since it's quite easy to do without testingunderscore
fucntions withlodash
versions because it doesn;t make. sene to re-write themExpensiMark
,Logger
,Src
so we can workletize functions from these files and run them on UI thread inreact-native-live-markdown
Fixed Issues
Expensify/App#42494
Tests
QA