Conversation
Replace all lodash imports with native JS/TS equivalents: - isEmpty → local #utils/isEmpty utility - isFunction → typeof fn === 'function' - camelCase → String.replace with regex - capitalize → inline helper - compact → Array.filter(Boolean) - differenceBy → Set-based filter - first → arr[0] - get → optional chaining with type cast - has → Object.hasOwn - isArray → Array.isArray - isString → typeof val === 'string' - keys → Object.keys - last → Array.at(-1) - map (object) → Object.entries().map - map (array-like) → Array.from().forEach - without → Array.filter with exclusion list Also improve related types: - label prop now correctly typed as string | ReactNode | (() => ReactNode) in SubmitButton, PlaceOrderButton, SaveAddressesButton - infoMessage.text in PaypalPayment similarly updated Closes #742
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Removes
lodashand@types/lodashentirely, replacing all usages with native JS/TS equivalents.Closes #742
Changes
New utility
src/utils/isEmpty.ts— replaceslodash/isEmptyacross 18+ files (handles null/undefined, strings, arrays, objects, Map/Set)Lodash functions replaced
isEmpty#utils/isEmptyisFunctiontypeof fn === 'function'camelCasestr.replace(/_([a-z])/g, ...)capitalizecompact.filter(Boolean)differenceBySet-based filterfirstarr[0]gethasObject.hasOwnisArrayArray.isArrayisStringtypeof val === 'string'keysObject.keyslast.at(-1)map(obj/array-like)Object.entries().map/Array.from().forEachType improvements (uncovered by removing lodash's
any-based guards)labelprop inSubmitButton,PlaceOrderButton,SaveAddressesButtonnow correctly typed asstring | ReactNode | (() => ReactNode)infoMessage.textinPaypalPaymentsimilarly updatedTesting
tsup)