Skip to content

Commit

Permalink
remove use of camelcase for es-toolkit, remove use of picky
Browse files Browse the repository at this point in the history
  • Loading branch information
ndelangen committed Sep 25, 2024
1 parent 715be6a commit d8c9595
Show file tree
Hide file tree
Showing 13 changed files with 30 additions and 40 deletions.
3 changes: 1 addition & 2 deletions code/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,6 @@
"babel-plugin-react-docgen": "4.2.1",
"boxen": "^7.1.1",
"browser-dtector": "^3.4.0",
"camelcase": "^8.0.0",
"chai": "^4.4.1",
"chalk": "^5.3.0",
"cli-table3": "^0.6.1",
Expand All @@ -360,7 +359,7 @@
"diff": "^5.2.0",
"downshift": "^9.0.4",
"ejs": "^3.1.10",
"es-toolkit": "^1.20.0",
"es-toolkit": "^1.21.0",
"esbuild": "^0.18.0 || ^0.19.0 || ^0.20.0 || ^0.21.0 || ^0.22.0 || ^0.23.0",
"esbuild-plugin-alias": "^0.2.1",
"execa": "^8.0.1",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import { camelCase } from 'es-toolkit';

/**
* Get a valid variable name for a component.
*
* @param name The name of the component.
* @returns A valid variable name.
*/
export const getComponentVariableName = async (name: string) => {
const camelCase = await import('camelcase');
const camelCased = camelCase.default(name.replace(/^[^a-zA-Z_$]*/, ''), { pascalCase: true });
const camelCased = camelCase(name.replace(/^[^a-zA-Z_$]*/, ''));
const sanitized = camelCased.replace(/[^a-zA-Z_$]+/, '');
return sanitized;
};
7 changes: 0 additions & 7 deletions code/core/src/manager-api/lib/merge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,3 @@ export const noArrayMerge = <TObj = any>(a: TObj, ...b: Partial<TObj>[]): TObj =

return target as TObj;
};

export function picky<T extends Record<string, any>, K extends keyof T>(
obj: T,
keys: K[]
): Partial<Pick<T, K>> {
return omitBy(pick(obj, keys), (v) => v === undefined);
}
8 changes: 4 additions & 4 deletions code/core/src/manager-api/modules/layout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import { global } from '@storybook/global';

import { SET_CONFIG } from '@storybook/core/core-events';

import { isEqual as deepEqual, omitBy, pick, toMerged } from 'es-toolkit';
import { isEqual as deepEqual, pick, toMerged } from 'es-toolkit';

import merge, { picky } from '../lib/merge';
import merge from '../lib/merge';
import type { ModuleFn } from '../lib/types';
import type { State } from '../root';

Expand Down Expand Up @@ -354,14 +354,14 @@ export const init: ModuleFn<SubAPI, SubState> = ({ store, provider, singleStory
const updatedLayout = {
...layout,
...(options.layout || {}),
...picky(options, Object.keys(layout)),
...pick(options, Object.keys(layout)),
...(singleStory && { navSize: 0 }),
};

const updatedUi = {
...ui,
...options.ui,
...toMerged(options.ui || {}, picky(options, Object.keys(ui))),
...toMerged(options.ui || {}, pick(options, Object.keys(ui))),
};

const updatedTheme = {
Expand Down
2 changes: 1 addition & 1 deletion code/lib/blocks/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
"@storybook/icons": "^1.2.10",
"color-convert": "^2.0.1",
"dequal": "^2.0.2",
"es-toolkit": "^1.20.0",
"es-toolkit": "^1.21.0",
"markdown-to-jsx": "^7.4.5",
"memoizerific": "^1.11.3",
"polished": "^4.2.2",
Expand Down
3 changes: 1 addition & 2 deletions code/lib/codemod/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
"@storybook/csf": "^0.1.11",
"@types/cross-spawn": "^6.0.2",
"cross-spawn": "^7.0.3",
"es-toolkit": "^1.20.0",
"es-toolkit": "^1.21.0",
"globby": "^14.0.1",
"jscodeshift": "^0.15.1",
"prettier": "^3.1.1",
Expand All @@ -71,7 +71,6 @@
"devDependencies": {
"@types/jscodeshift": "^0.11.10",
"ansi-regex": "^6.0.1",
"camelcase": "^8.0.0",
"mdast-util-mdx-jsx": "^3.0.0",
"mdast-util-mdxjs-esm": "^2.0.1",
"remark": "^15.0.1",
Expand Down
2 changes: 1 addition & 1 deletion code/lib/codemod/src/transforms/mdx-to-csf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
types as t,
} from '@storybook/core/babel';

import camelCase from 'camelcase';
import { camelCase } from 'es-toolkit';
import type { FileInfo } from 'jscodeshift';
import type { MdxFlowExpression } from 'mdast-util-mdx-expression';
import type {
Expand Down
2 changes: 1 addition & 1 deletion code/lib/source-loader/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
},
"dependencies": {
"@storybook/csf": "^0.1.11",
"es-toolkit": "^1.20.0",
"es-toolkit": "^1.21.0",
"estraverse": "^5.2.0",
"prettier": "^3.1.1"
},
Expand Down
2 changes: 1 addition & 1 deletion code/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@
"create-storybook": "workspace:*",
"cross-env": "^7.0.3",
"danger": "^12.3.3",
"es-toolkit": "^1.20.0",
"es-toolkit": "^1.21.0",
"esbuild": "^0.18.0 || ^0.19.0 || ^0.20.0 || ^0.21.0 || ^0.22.0 || ^0.23.0",
"esbuild-loader": "^4.2.0",
"esbuild-plugin-alias": "^0.2.1",
Expand Down
2 changes: 1 addition & 1 deletion code/renderers/react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
"@types/semver": "^7.3.4",
"@types/util-deprecate": "^1.0.0",
"babel-plugin-react-docgen": "^4.2.1",
"es-toolkit": "^1.20.0",
"es-toolkit": "^1.21.0",
"expect-type": "^0.15.0",
"require-from-string": "^2.0.2"
},
Expand Down
22 changes: 10 additions & 12 deletions code/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5757,7 +5757,7 @@ __metadata:
"@types/color-convert": "npm:^2.0.0"
color-convert: "npm:^2.0.1"
dequal: "npm:^2.0.2"
es-toolkit: "npm:^1.20.0"
es-toolkit: "npm:^1.21.0"
markdown-to-jsx: "npm:^7.4.5"
memoizerific: "npm:^1.11.3"
polished: "npm:^4.2.2"
Expand Down Expand Up @@ -5928,9 +5928,8 @@ __metadata:
"@types/cross-spawn": "npm:^6.0.2"
"@types/jscodeshift": "npm:^0.11.10"
ansi-regex: "npm:^6.0.1"
camelcase: "npm:^8.0.0"
cross-spawn: "npm:^7.0.3"
es-toolkit: "npm:^1.20.0"
es-toolkit: "npm:^1.21.0"
globby: "npm:^14.0.1"
jscodeshift: "npm:^0.15.1"
mdast-util-mdx-jsx: "npm:^3.0.0"
Expand Down Expand Up @@ -6054,7 +6053,6 @@ __metadata:
boxen: "npm:^7.1.1"
browser-assert: "npm:^1.2.1"
browser-dtector: "npm:^3.4.0"
camelcase: "npm:^8.0.0"
chai: "npm:^4.4.1"
chalk: "npm:^5.3.0"
cli-table3: "npm:^0.6.1"
Expand All @@ -6072,7 +6070,7 @@ __metadata:
diff: "npm:^5.2.0"
downshift: "npm:^9.0.4"
ejs: "npm:^3.1.10"
es-toolkit: "npm:^1.20.0"
es-toolkit: "npm:^1.21.0"
esbuild: "npm:^0.18.0 || ^0.19.0 || ^0.20.0 || ^0.21.0 || ^0.22.0 || ^0.23.0"
esbuild-plugin-alias: "npm:^0.2.1"
esbuild-register: "npm:^3.5.0"
Expand Down Expand Up @@ -6757,7 +6755,7 @@ __metadata:
acorn-jsx: "npm:^5.3.1"
acorn-walk: "npm:^7.2.0"
babel-plugin-react-docgen: "npm:^4.2.1"
es-toolkit: "npm:^1.20.0"
es-toolkit: "npm:^1.21.0"
escodegen: "npm:^2.1.0"
expect-type: "npm:^0.15.0"
html-tags: "npm:^3.1.0"
Expand Down Expand Up @@ -6881,7 +6879,7 @@ __metadata:
create-storybook: "workspace:*"
cross-env: "npm:^7.0.3"
danger: "npm:^12.3.3"
es-toolkit: "npm:^1.20.0"
es-toolkit: "npm:^1.21.0"
esbuild: "npm:^0.18.0 || ^0.19.0 || ^0.20.0 || ^0.21.0 || ^0.22.0 || ^0.23.0"
esbuild-loader: "npm:^4.2.0"
esbuild-plugin-alias: "npm:^0.2.1"
Expand Down Expand Up @@ -6983,7 +6981,7 @@ __metadata:
resolution: "@storybook/source-loader@workspace:lib/source-loader"
dependencies:
"@storybook/csf": "npm:^0.1.11"
es-toolkit: "npm:^1.20.0"
es-toolkit: "npm:^1.21.0"
estraverse: "npm:^5.2.0"
prettier: "npm:^3.1.1"
typescript: "npm:^5.3.2"
Expand Down Expand Up @@ -14060,10 +14058,10 @@ __metadata:
languageName: node
linkType: hard

"es-toolkit@npm:^1.20.0":
version: 1.20.0
resolution: "es-toolkit@npm:1.20.0"
checksum: 10c0/566a517ec97d4b2431d220d4eb9a7cc37a1b397521b4e230c9e53d647c2b4e0b8c2e91030e1de6e8080c30f9f05ee5281d13d3c2dd37ec1193a13bc24e2fd70c
"es-toolkit@npm:^1.21.0":
version: 1.21.0
resolution: "es-toolkit@npm:1.21.0"
checksum: 10c0/894a63f8ce5b2e5c1be242c8e8eace6364ea1212d01cdf89594d2cc582c5e1574114ad2ee7022ad5206561c4d5170511d83b38853257249860e56178768854ea
languageName: node
linkType: hard

Expand Down
2 changes: 1 addition & 1 deletion scripts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@
"detect-port": "^1.6.1",
"ejs": "^3.1.10",
"ejs-lint": "^2.0.0",
"es-toolkit": "^1.20.0",
"es-toolkit": "^1.21.0",
"esbuild": "^0.23.0",
"esbuild-plugin-alias": "^0.2.1",
"eslint": "^8.57.0",
Expand Down
10 changes: 5 additions & 5 deletions scripts/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1558,7 +1558,7 @@ __metadata:
detect-port: "npm:^1.6.1"
ejs: "npm:^3.1.10"
ejs-lint: "npm:^2.0.0"
es-toolkit: "npm:^1.20.0"
es-toolkit: "npm:^1.21.0"
esbuild: "npm:^0.23.0"
esbuild-plugin-alias: "npm:^0.2.1"
eslint: "npm:^8.57.0"
Expand Down Expand Up @@ -5271,10 +5271,10 @@ __metadata:
languageName: node
linkType: hard

"es-toolkit@npm:^1.20.0":
version: 1.20.0
resolution: "es-toolkit@npm:1.20.0"
checksum: 10c0/566a517ec97d4b2431d220d4eb9a7cc37a1b397521b4e230c9e53d647c2b4e0b8c2e91030e1de6e8080c30f9f05ee5281d13d3c2dd37ec1193a13bc24e2fd70c
"es-toolkit@npm:^1.21.0":
version: 1.21.0
resolution: "es-toolkit@npm:1.21.0"
checksum: 10c0/894a63f8ce5b2e5c1be242c8e8eace6364ea1212d01cdf89594d2cc582c5e1574114ad2ee7022ad5206561c4d5170511d83b38853257249860e56178768854ea
languageName: node
linkType: hard

Expand Down

0 comments on commit d8c9595

Please sign in to comment.