-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
changing lodash #74539
changing lodash #74539
Conversation
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.
LGTM from a security perspective 👍
There seem to be a few places missing though, e.g:
import { get, mapValues, map } from 'lodash'; |
Have those been left out on purpose?
Just realized it's not just the mapValues :) I'll go find the other lodash ones and update and then move out of draft. |
@watson i realized i only did mapvalues and not all the other lodash ones. I've since updated and ran code mod to do them all! |
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 from a security perspective 👍
I think it would be nice if we could add a linting rule in .eslintrc.js
that forbids us to import directly from lodash
within a public
directory. I can easily see these types of imports sneaking in again, in which case all your good work is for nothing, so it would be good to guard against it.
Of the top of my head I think it would be something like this:
{
files: ['**/public/**/*.{js,mjs,ts,tsx}'],
rules: {
'no-restricted-imports': [
2,
{
paths: [
{
name: 'lodash',
message: 'Please import specific method as a file instead, e.g. "lodash/get"',
},
],
},
],
},
},
Pinging @elastic/apm-ui (Team:apm) |
Per this discussion on Slack, we're going to do this for the whole repo. I'll also work on adding the eslint rule above. Will be working on this this week! |
I agree with @tylersmalley on this one. Although I'm not sure what will be the penalty impact of transform this at compile time, our lodash usage is really wide and I would prefer to have the code explicitly behave as expected. Another thing to consider is that in a future lodash major upgrade it would be easier to find the places with lodash usages we need to convert because we can just search for |
Nathan and I are doing this... In summary, what we need to watch out for:
to do:
|
Please keep _.chain in mind 😀 I would prefer for it to be a separate PR.
As we cannot automate it I feel we need to give it a little more attention
than the other automated steps.
Op ma 24 aug. 2020 18:09 schreef Brittany Joiner <[email protected]>:
… Nathan and I are doing this...
In summary, what we need to watch out for:
- Make sure no extra new lines are added
- Only edit in /public,/common, and /packages
to do:
- Revert to master
- do find import _, (\{ [a-zA-Z\s,]+ \}) from 'lodash' and replace
with import $1 from 'lodash'
- write and run ESlint rule
<#74539 (review)>
to get list of files
- run codemod on tht list of files
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#74539 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AACWDXHTIAZJCVZMS5RSE33SCKGCZANCNFSM4PWVSFNA>
.
|
Also, disabling the prettier rule when running eslint should give you a
nice speed boost of 75%. There are some other rules that could save you
some time too, I posted the list in the Kibana ops channel.
Op ma 24 aug. 2020 19:11 schreef Dario Gieselaar <[email protected]
…:
Please keep _.chain in mind 😀 I would prefer for it to be a separate PR.
As we cannot automate it I feel we need to give it a little more attention
than the other automated steps.
Op ma 24 aug. 2020 18:09 schreef Brittany Joiner ***@***.***
>:
> Nathan and I are doing this...
>
> In summary, what we need to watch out for:
>
> - Make sure no extra new lines are added
> - Only edit in /public,/common, and /packages
>
> to do:
>
> - Revert to master
> - do find import _, (\{ [a-zA-Z\s,]+ \}) from 'lodash' and replace
> with import $1 from 'lodash'
> - write and run ESlint rule
> <#74539 (review)>
> to get list of files
> - run codemod on tht list of files
>
> —
> You are receiving this because you were mentioned.
> Reply to this email directly, view it on GitHub
> <#74539 (comment)>,
> or unsubscribe
> <https://github.com/notifications/unsubscribe-auth/AACWDXHTIAZJCVZMS5RSE33SCKGCZANCNFSM4PWVSFNA>
> .
>
|
e620a16
to
6c6b1cf
Compare
@elasticmachine merge upstream |
merge conflict between base and head |
We're close! Just need to fetch the most recent and do this again to avoid conflicts.
|
💔 Build Failed
Failed CI Steps
Test FailuresX-Pack Jest Tests.x-pack/plugins/rollup/public/test/client_integration.Create Rollup Job, step 1: Logistics form validations index pattern should not allow spacesStandard Out
Stack Trace
X-Pack Jest Tests.x-pack/plugins/rollup/public/test/client_integration.Create Rollup Job, step 1: Logistics form validations index pattern should not allow an unknown index patternStandard Out
Stack Trace
X-Pack Jest Tests.x-pack/plugins/rollup/public/test/client_integration.Create Rollup Job, step 1: Logistics form validations index pattern should not allow an index pattern without time fieldsStandard Out
Stack Trace
and 83 more failures, only showing the first 3. Build metrics@kbn/optimizer bundle module count
async chunks size
page load bundle size
History
To update your PR or re-run it, just comment with: |
is this PR old and should be closed? 7.9.2 FF is today... also this doesn't seem like it should go into a patch release. Going to remove the label! |
Thanks for removing the label. It's still in progress but it's a big hairy change. |
Closing in favor of #78156. |
Resolves #73937
Updated all instances of
import { x } from 'lodash'
toimport x from 'lodash/x'
Used this codemod