Skip to content

chore: remove lodash #6551

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

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 2 additions & 67 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 1 addition & 10 deletions packages/react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,6 @@
"focus-visible": "^5.2.1",
"history": "^5.0.0",
"hsluv": "1.0.1",
"lodash.isempty": "^4.4.0",
"lodash.isobject": "^3.0.2",
"react-compiler-runtime": "^19.1.0-rc.2",
"react-intersection-observer": "^9.16.0",
"styled-system": "^5.1.5",
Expand Down Expand Up @@ -139,10 +137,6 @@
"@testing-library/react": "^16.3.0",
"@testing-library/react-hooks": "^8.0.1",
"@testing-library/user-event": "^14.5.2",
"@types/lodash.groupby": "4.6.9",
"@types/lodash.isempty": "4.4.9",
"@types/lodash.isobject": "3.0.9",
"@types/lodash.keyby": "4.6.9",
"@types/node": "20.12.11",
"@types/react": "18.3.11",
"@types/react-dom": "18.3.1",
Expand Down Expand Up @@ -173,8 +167,6 @@
"front-matter": "4.0.2",
"gzip-size": "6.0.0",
"jscodeshift": "0.15.0",
"lodash.groupby": "4.6.0",
"lodash.keyby": "4.6.0",
"markdownlint": "^0.38.0",
"mdast-util-from-markdown": "2.0.1",
"mdast-util-frontmatter": "2.0.1",
Expand Down Expand Up @@ -231,5 +223,4 @@
"optional": true
}
}
}

}
10 changes: 9 additions & 1 deletion packages/react/script/components-json/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,22 @@ import Ajv from 'ajv'
import {pascalCase, kebabCase} from 'change-case'
import glob from 'fast-glob'
import fs from 'fs'
import keyBy from 'lodash.keyby'
import prettier from '@prettier/sync'
import chalk from 'chalk'
import type {LintError} from 'markdownlint'
import {lint as mdLint} from 'markdownlint/sync'
import componentSchema from './component.schema.json'
import outputSchema from './output.schema.json'

const _keyBy = (array: Array<any>, key: string) => (array || []).reduce((r, x) => ({ ...r, [key ? x[key] : x]: x }), {})

const keyBy = (collection: Object, key: string) => {
const c = collection || {};
return Array.isArray(c)
? _keyBy(c, key)
: _keyBy(Object.values(c), key);
}

const args = parseArgs({
options: {
'storybook-data': {
Expand Down
10 changes: 9 additions & 1 deletion packages/react/script/hooks-json/build.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
import glob from 'fast-glob'
import fs from 'fs'
import keyBy from 'lodash.keyby'
import hookSchema from '../hooks-json/hook.schema.json'
import outputSchema from './output.schema.json'
import Ajv from 'ajv'

const _keyBy = (array: Array<any>, key: string) => (array || []).reduce((r, x) => ({ ...r, [key ? x[key] : x]: x }), {})

const keyBy = (collection: Object, key: string) => {
const c = collection || {};
return Array.isArray(c)
? _keyBy(c, key)
: _keyBy(Object.values(c), key);
}

// Only includes fields we use in this script
type Hook = {
name: string
Expand Down
3 changes: 1 addition & 2 deletions packages/react/src/__tests__/storybook.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import fs from 'node:fs'
import path from 'node:path'
import {describe, expect, test} from 'vitest'
import glob from 'fast-glob'
import groupBy from 'lodash.groupby'

const ROOT_DIRECTORY = path.resolve(__dirname, '..', '..')

Expand Down Expand Up @@ -87,7 +86,7 @@ const stories = await Promise.all(
)

const components = Object.entries(
groupBy(stories, ({name}) => {
Object.groupBy(stories, ({name}) => {
return name
}),
)
Expand Down
9 changes: 7 additions & 2 deletions packages/react/src/utils/theme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,13 @@
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-nocheck

import isEmpty from 'lodash.isempty'
import isObject from 'lodash.isobject'
function isObject(obj: unknown): obj is Object {
return typeof obj === 'object' && obj !== null
}

function isEmpty(obj: unknown): boolean {
return [Object, Array].includes((obj || {}).constructor) && !Object.entries((obj || {})).length;
}

function fontStack(fonts) {
return fonts.map(font => (font.includes(' ') ? `"${font}"` : font)).join(', ')
Expand Down