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

Codify lodash usage in eslint #1270

Merged
merged 13 commits into from
Jul 13, 2023
Merged

Codify lodash usage in eslint #1270

merged 13 commits into from
Jul 13, 2023

Conversation

Janpot
Copy link
Member

@Janpot Janpot commented Nov 3, 2022

Avoid kitchensink libraries, especially unmaintained ones like lodash. We write a slightly more verbose, but a universally understood style of javascript.

@Janpot Janpot added the core Infrastructure work going on behind the scenes label Nov 3, 2022
@render
Copy link

render bot commented Nov 3, 2022

@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged label Jun 5, 2023
Signed-off-by: Jan Potoms <2109932+Janpot@users.noreply.github.com>
@github-actions github-actions bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged label Jun 15, 2023
@Janpot Janpot marked this pull request as ready for review July 12, 2023 18:56
@Janpot Janpot requested a review from apedroferreira July 12, 2023 18:57
@@ -34,6 +34,8 @@ import {
JsExpressionAttrValue,
} from '@mui/toolpad-core';
import { createProvidedContext, useAssertedContext } from '@mui/toolpad-utils/react';
import { filterKeys, mapProperties, mapValues } from '@mui/toolpad-utils/collections';
import { set as setObjectPath } from 'lodash-es';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we plan to eventually completely get rid of lodash we could maybe create utility methods for these operations, which for now would still use lodash but then we would know where to replace it.
Just a possibility, maybe it helps to have the lodash imports less spread out.

Copy link
Member Author

@Janpot Janpot Jul 13, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be honest, I'm not sure we should even have utility functions for this. ideally we improve the algorithm altogether to be not so lodashy. setObjectPath also makes us write type-unsafe code, I don't want to enable that sort of code in our codebase

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it, yeah for this specific type of operation maybe just normal Javascript would be possible and be more type-safe.

Copy link
Member

@apedroferreira apedroferreira left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good, should we create an issue to replace lodash in the todo comments?

@@ -1226,7 +1228,7 @@ function QueryNode({ page, node }: QueryNodeProps) {
Object.fromEntries(node.params ?? []),
);

const configBindings = _.pick(node.attributes, USE_DATA_QUERY_CONFIG_KEYS);
const configBindings = filterKeys(node.attributes, (key) => USE_DATA_QUERY_CONFIG_KEYS.has(key));
Copy link
Member

@apedroferreira apedroferreira Jul 13, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could abstract this to our own pick function maybe?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing it altogether

@Janpot Janpot enabled auto-merge (squash) July 13, 2023 17:55
@Janpot Janpot disabled auto-merge July 13, 2023 17:55
@Janpot Janpot enabled auto-merge (squash) July 13, 2023 18:02
@Janpot Janpot merged commit 757aa63 into master Jul 13, 2023
@Janpot Janpot deleted the WIP-lodash-restriction branch July 13, 2023 19:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Infrastructure work going on behind the scenes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants