Skip to content

Commit

Permalink
fix prettier formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
rbshop committed Feb 18, 2025
1 parent 4fcd3c6 commit f945b99
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 40 deletions.
2 changes: 1 addition & 1 deletion packages/hydrogen-react/src/ExternalVideo.test.helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export function getExternalVideoData(
mediaContentType: 'EXTERNAL_VIDEO',
embedUrl: externalVideo.embedUrl ?? faker.internet.url(),
host:
(externalVideo.host ?? faker.datatype.number({max: 2, min: 1}) === 1)
externalVideo.host ?? faker.datatype.number({max: 2, min: 1}) === 1
? 'YOUTUBE'
: 'VIMEO',
previewImage: getPreviewImage(externalVideo.previewImage ?? undefined),
Expand Down
22 changes: 11 additions & 11 deletions packages/hydrogen-react/src/Image.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -225,11 +225,11 @@ export const Image = React.forwardRef<HTMLImageElement, HydrogenImageProps>(
const nAspectRatio: string | undefined = aspectRatio
? aspectRatio
: normalizedData.unitsMatch
? [
getNormalizedFixedUnit(normalizedData.width),
getNormalizedFixedUnit(normalizedData.height),
].join('/')
: undefined;
? [
getNormalizedFixedUnit(normalizedData.width),
getNormalizedFixedUnit(normalizedData.height),
].join('/')
: undefined;

return {
width: nWidth,
Expand Down Expand Up @@ -371,10 +371,10 @@ const FixedWidthImage = React.forwardRef<
const fixedAspectRatio = aspectRatio
? aspectRatio
: unitsMatch(normalizedProps.width, normalizedProps.height)
? [intWidth, intHeight].join('/')
: normalizedProps.aspectRatio
? normalizedProps.aspectRatio
: undefined;
? [intWidth, intHeight].join('/')
: normalizedProps.aspectRatio
? normalizedProps.aspectRatio
: undefined;

/*
* The Sizes Array generates an array of all the parts
Expand All @@ -391,8 +391,8 @@ const FixedWidthImage = React.forwardRef<
const fixedHeight = intHeight
? intHeight
: fixedAspectRatio && intWidth
? intWidth * (parseAspectRatio(fixedAspectRatio) ?? 1)
: undefined;
? intWidth * (parseAspectRatio(fixedAspectRatio) ?? 1)
: undefined;

const srcSet = generateSrcSet(normalizedProps.src, sizesArray, loader);
const src = loader({
Expand Down
4 changes: 2 additions & 2 deletions packages/hydrogen-react/src/ProductPrice.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ export function ProductPrice<
let measurement: Partial<UnitPriceMeasurement> | undefined | null;

const variant = variantId
? (flattenConnection(product?.variants ?? {}).find(
? flattenConnection(product?.variants ?? {}).find(
(variant) => variant?.id === variantId,
) ?? null)
) ?? null
: null;

const variantPriceProperty =
Expand Down
23 changes: 10 additions & 13 deletions packages/hydrogen-react/src/ProductProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -243,20 +243,17 @@ function getSelectedVariant(
function getOptions(
variants: PartialDeep<ProductVariantType, {recurseIntoArrays: true}>[],
): OptionWithValues[] {
const map = variants.reduce(
(memo, variant) => {
if (!variant.selectedOptions) {
throw new Error(`'getOptions' requires 'variant.selectedOptions'`);
}
variant?.selectedOptions?.forEach((opt) => {
memo[opt?.name ?? ''] = memo[opt?.name ?? ''] || new Set();
memo[opt?.name ?? ''].add(opt?.value ?? '');
});
const map = variants.reduce((memo, variant) => {
if (!variant.selectedOptions) {
throw new Error(`'getOptions' requires 'variant.selectedOptions'`);
}
variant?.selectedOptions?.forEach((opt) => {
memo[opt?.name ?? ''] = memo[opt?.name ?? ''] || new Set();
memo[opt?.name ?? ''].add(opt?.value ?? '');
});

return memo;
},
{} as Record<string, Set<string>>,
);
return memo;
}, {} as Record<string, Set<string>>);

return Object.keys(map).map((option) => {
return {
Expand Down
26 changes: 13 additions & 13 deletions packages/hydrogen-react/src/flatten-connection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,19 @@ export function flattenConnection<
? // if it's not a PartialDeep, then return the infered type
ConnectionBaseType[]
: ConnectionGeneric extends
| PartialDeep<
{edges: {node: Array<infer ConnectionBaseType>}},
{recurseIntoArrays: true}
>
| PartialDeep<
{
nodes: Array<infer ConnectionBaseType>;
},
{recurseIntoArrays: true}
>
? // if it is a PartialDeep, return a PartialDeep inferred type
PartialDeep<ConnectionBaseType[], {recurseIntoArrays: true}>
: never {
| PartialDeep<
{edges: {node: Array<infer ConnectionBaseType>}},
{recurseIntoArrays: true}
>
| PartialDeep<
{
nodes: Array<infer ConnectionBaseType>;
},
{recurseIntoArrays: true}
>
? // if it is a PartialDeep, return a PartialDeep inferred type
PartialDeep<ConnectionBaseType[], {recurseIntoArrays: true}>
: never {
if (!connection) {
const noConnectionErr = `flattenConnection(): needs a 'connection' to flatten, but received '${
connection ?? ''
Expand Down

0 comments on commit f945b99

Please sign in to comment.