From 2af1b0107a0d8992f9dcadf6c8f999a9610adf47 Mon Sep 17 00:00:00 2001 From: Daniel Ochoa Date: Thu, 22 Jan 2026 20:41:01 -0500 Subject: [PATCH] feat(): SMX-242 - migrate to ESLint 9 flat config --- core/.eslintrc.cjs | 69 - .../(faceted)/_components/facets.tsx | 4 +- .../(faceted)/_components/refine-by.tsx | 12 +- .../(faceted)/brand/[slug]/static/page.tsx | 8 +- .../[slug]/_components/sub-categories.tsx | 2 +- .../(faceted)/category/[slug]/static/page.tsx | 8 +- .../(faceted)/fetch-faceted-search.ts | 6 +- .../add/_components/add-address-form.tsx | 6 +- .../[slug]/_components/order-details.tsx | 26 +- .../orders/_components/orders-list.tsx | 144 +- .../orders/_components/product-snippet.tsx | 72 +- .../(default)/account/orders/page-data.ts | 16 +- core/app/[locale]/(default)/blog/page.tsx | 12 +- .../(default)/blog/tag/[tagId]/page.tsx | 6 +- .../(default)/cart/_components/cart-item.tsx | 2 +- .../cart/_components/cart-viewed.tsx | 30 +- .../cart/_components/checkout-button.tsx | 14 +- .../cart/_components/checkout-summary.tsx | 12 +- .../cart/_components/item-quantity/index.tsx | 5 +- .../cart/_components/remove-item.tsx | 30 +- .../_components/shipping-estimator/index.tsx | 18 +- .../_components/shipping-options/index.tsx | 2 +- .../product-form/_actions/add-to-cart.ts | 4 +- .../_components/product-review-schema.tsx | 34 +- .../product/[slug]/_components/reviews.tsx | 34 +- .../(default)/product/[slug]/static/page.tsx | 8 +- .../contact/[id]/contact-us/index.tsx | 2 +- core/app/favicon.ico/route.ts | 1 - core/app/login/token/[token]/route.ts | 1 - core/app/notifications.tsx | 22 +- core/app/robots.txt/route.ts | 1 - core/app/sitemap.xml/route.ts | 1 - core/app/xmlsitemap.php/route.ts | 1 - core/auth/customer-login-api.ts | 4 +- core/client/queries/get-cart.ts | 7 +- core/components/form-fields/checkboxes.tsx | 6 +- core/components/form-fields/password.tsx | 4 +- .../form-fields/shared/field-handlers.ts | 8 +- .../form-fields/shared/parse-fields.ts | 2 +- core/components/header/quick-search.tsx | 8 +- core/components/image/index.tsx | 1 - core/components/product-card/index.tsx | 2 +- core/components/ui/accordions/accordions.tsx | 36 +- core/components/ui/badge/badge.tsx | 24 +- .../ui/blog-post-card/blog-post-card.tsx | 66 +- core/components/ui/carousel/carousel.tsx | 32 +- .../ui/compare-drawer/compare-drawer.tsx | 32 +- core/components/ui/compare-drawer/context.tsx | 9 +- core/components/ui/dropdown/dropdown.tsx | 78 +- core/components/ui/form/checkbox/checkbox.tsx | 38 +- .../ui/form/date-picker/date-picker.tsx | 56 +- .../ui/form/text-area/text-area.tsx | 26 +- core/components/ui/header/search.tsx | 138 +- core/components/ui/product-card/compare.tsx | 6 +- core/components/ui/rating/rating.tsx | 4 +- .../ui/rating/star-icons/star-empty.tsx | 12 +- .../ui/rating/star-icons/star-filled.tsx | 12 +- .../ui/rating/star-icons/star-half.tsx | 12 +- core/components/ui/slideshow/slideshow.tsx | 31 +- core/components/ui/tag/tag.tsx | 42 +- core/lib/store-assets.ts | 20 +- core/middlewares/compose-middlewares.ts | 4 +- core/middlewares/with-channel-id.ts | 12 +- core/middlewares/with-intl.ts | 38 +- core/middlewares/with-routes.ts | 160 +- core/tests/fixtures/utils/account/index.ts | 2 +- core/tests/fixtures/utils/order/delete.ts | 1 + core/tests/fixtures/utils/order/index.ts | 2 +- core/tests/ui/components/radio-group.spec.ts | 1 - core/tests/ui/components/swatch.spec.ts | 1 - core/tests/ui/e2e/order-details.spec.ts | 6 +- core/userAgent.ts | 1 + eslint.config.mjs | 71 + package.json | 27 +- package.json.fe454-backup | 33 + packages/client/.eslintrc.cjs | 16 - packages/client/eslint.config.mjs | 45 + packages/client/package.json | 4 +- packages/create-catalyst/.eslintrc.cjs | 15 - packages/create-catalyst/eslint.config.mjs | 53 + packages/create-catalyst/package.json | 1 + pnpm-lock.yaml | 2254 ++++++++++++++++- 82 files changed, 3057 insertions(+), 1019 deletions(-) delete mode 100644 core/.eslintrc.cjs create mode 100644 eslint.config.mjs create mode 100644 package.json.fe454-backup delete mode 100644 packages/client/.eslintrc.cjs create mode 100644 packages/client/eslint.config.mjs delete mode 100644 packages/create-catalyst/.eslintrc.cjs create mode 100644 packages/create-catalyst/eslint.config.mjs diff --git a/core/.eslintrc.cjs b/core/.eslintrc.cjs deleted file mode 100644 index ce48062577..0000000000 --- a/core/.eslintrc.cjs +++ /dev/null @@ -1,69 +0,0 @@ -// @ts-check - -// eslint-disable-next-line import/no-extraneous-dependencies -require('@bigcommerce/eslint-config/patch'); - -/** @type {import('eslint').Linter.Config} */ -const config = { - root: true, - extends: [ - '@bigcommerce/catalyst/base', - '@bigcommerce/catalyst/react', - '@bigcommerce/catalyst/next', - '@bigcommerce/catalyst/prettier', - ], - rules: { - '@typescript-eslint/naming-convention': 'off', - '@next/next/no-html-link-for-pages': 'off', - 'import/dynamic-import-chunkname': 'off', - 'no-underscore-dangle': ['error', { allow: ['__typename'] }], - '@typescript-eslint/prefer-nullish-coalescing': 'off', - '@typescript-eslint/no-unsafe-enum-comparison': 'off', - '@typescript-eslint/no-restricted-imports': [ - 'error', - { - paths: [ - { - name: 'next/link', - message: "Please import 'Link' from '~/components/Link' instead.", - }, - { - name: 'next/image', - importNames: ['default'], - message: - "Please import 'Image' from '~/components/image' instead. This component handles CDN and static image optimization.", - }, - { - name: '~/i18n/routing', - importNames: ['Link'], - message: "Please import 'Link' from '~/components/Link' instead.", - }, - { - name: 'next/router', - importNames: ['useRouter'], - message: 'Please import from `~/i18n/routing` instead.', - }, - { - name: 'next/navigation', - importNames: ['redirect', 'permanentRedirect', 'useRouter', 'usePathname'], - message: 'Please import from `~/i18n/routing` instead.', - }, - ], - }, - ], - 'check-file/folder-naming-convention': [ - 'error', - { - '**': 'NEXT_JS_APP_ROUTER_CASE', - }, - ], - }, - ignorePatterns: [ - 'client/generated/**/*.ts', - 'playwright-report/**', - 'test-results/**', - '**/google_analytics4.js', - ], -}; - -module.exports = config; diff --git a/core/app/[locale]/(default)/(faceted)/_components/facets.tsx b/core/app/[locale]/(default)/(faceted)/_components/facets.tsx index 96cc0a0f94..7c64c3c9af 100644 --- a/core/app/[locale]/(default)/(faceted)/_components/facets.tsx +++ b/core/app/[locale]/(default)/(faceted)/_components/facets.tsx @@ -60,9 +60,7 @@ export const Facets = ({ facets, pageType }: Props) => { const sortParam = searchParams.get('sort'); const searchParam = searchParams.get('term'); const filteredSearchParams = Array.from(formData.entries()) - .filter((entry): entry is [string, string] => { - return !(entry instanceof File); - }) + .filter((entry): entry is [string, string] => !(entry instanceof File)) .filter(([, value]) => value !== ''); const newSearchParams = new URLSearchParams(filteredSearchParams); diff --git a/core/app/[locale]/(default)/(faceted)/_components/refine-by.tsx b/core/app/[locale]/(default)/(faceted)/_components/refine-by.tsx index 15a55475ce..11f939cd39 100644 --- a/core/app/[locale]/(default)/(faceted)/_components/refine-by.tsx +++ b/core/app/[locale]/(default)/(faceted)/_components/refine-by.tsx @@ -62,13 +62,11 @@ const mapFacetsToRefinements = ({ facets, pageType }: Props) => case 'ProductAttributeSearchFilter': return facet.attributes .filter(({ isSelected }) => isSelected) - .map>(({ value }) => { - return { - key: `attr_${facet.filterName}`, - display_name: value, - value, - }; - }); + .map>(({ value }) => ({ + key: `attr_${facet.filterName}`, + display_name: value, + value, + })); case 'OtherSearchFilter': { const { freeShipping, isFeatured, isInStock } = facet; diff --git a/core/app/[locale]/(default)/(faceted)/brand/[slug]/static/page.tsx b/core/app/[locale]/(default)/(faceted)/brand/[slug]/static/page.tsx index e484d64d67..9a95ac13be 100644 --- a/core/app/[locale]/(default)/(faceted)/brand/[slug]/static/page.tsx +++ b/core/app/[locale]/(default)/(faceted)/brand/[slug]/static/page.tsx @@ -43,12 +43,12 @@ const getBrands = cache(async (variables: Variables = {}) => { export async function generateStaticParams() { const brands = await getBrands(); - return locales.map((locale) => { - return brands.map((brand) => ({ + return locales.map((locale) => + brands.map((brand) => ({ locale, slug: brand.entityId.toString(), - })); - }); + })), + ); } export const dynamic = 'force-static'; diff --git a/core/app/[locale]/(default)/(faceted)/category/[slug]/_components/sub-categories.tsx b/core/app/[locale]/(default)/(faceted)/category/[slug]/_components/sub-categories.tsx index 8d38bae6f8..02a4690545 100644 --- a/core/app/[locale]/(default)/(faceted)/category/[slug]/_components/sub-categories.tsx +++ b/core/app/[locale]/(default)/(faceted)/category/[slug]/_components/sub-categories.tsx @@ -33,7 +33,7 @@ interface Props { export function SubCategories({ categoryTree }: Props) { const t = useTranslations('FacetedGroup.MobileSideNav'); - if (!categoryTree[0]?.children?.length) { + if (!categoryTree[0].children?.length) { return null; } diff --git a/core/app/[locale]/(default)/(faceted)/category/[slug]/static/page.tsx b/core/app/[locale]/(default)/(faceted)/category/[slug]/static/page.tsx index 0bad5694a9..9a7914c092 100644 --- a/core/app/[locale]/(default)/(faceted)/category/[slug]/static/page.tsx +++ b/core/app/[locale]/(default)/(faceted)/category/[slug]/static/page.tsx @@ -52,12 +52,12 @@ export async function generateStaticParams() { const entityIds = getEntityIdsOfChildren(categories); - return locales.map((locale) => { - return entityIds.map((entityId) => ({ + return locales.map((locale) => + entityIds.map((entityId) => ({ locale, slug: entityId.toString(), - })); - }); + })), + ); } export const dynamic = 'force-static'; diff --git a/core/app/[locale]/(default)/(faceted)/fetch-faceted-search.ts b/core/app/[locale]/(default)/(faceted)/fetch-faceted-search.ts index 798f43e5fc..49ef5ed00e 100644 --- a/core/app/[locale]/(default)/(faceted)/fetch-faceted-search.ts +++ b/core/app/[locale]/(default)/(faceted)/fetch-faceted-search.ts @@ -320,9 +320,9 @@ export const PublicSearchParamsSchema = z.object({ term: z.string().optional(), }); -const AttributeKey = z.custom<`attr_${string}`>((val) => { - return typeof val === 'string' ? /^attr_\w+$/.test(val) : false; -}); +const AttributeKey = z.custom<`attr_${string}`>((val) => + typeof val === 'string' ? /^attr_\w+$/.test(val) : false, +); const PublicToPrivateParams = PublicSearchParamsSchema.catchall(SearchParamToArray) .transform((publicParams) => { diff --git a/core/app/[locale]/(default)/account/addresses/add/_components/add-address-form.tsx b/core/app/[locale]/(default)/account/addresses/add/_components/add-address-form.tsx index 9a4786ee3c..773d2c6a9b 100644 --- a/core/app/[locale]/(default)/account/addresses/add/_components/add-address-form.tsx +++ b/core/app/[locale]/(default)/account/addresses/add/_components/add-address-form.tsx @@ -276,14 +276,12 @@ export const AddAddressForm = ({ addressFields, countries, defaultCountry }: Add { - return { entityId: name, label: name }; - })} + options={countryStates.map(({ name }) => ({ entityId: name, label: name }))} /> ); diff --git a/core/app/[locale]/(default)/account/order/[slug]/_components/order-details.tsx b/core/app/[locale]/(default)/account/order/[slug]/_components/order-details.tsx index 322ec3ff4f..18fac45f90 100644 --- a/core/app/[locale]/(default)/account/order/[slug]/_components/order-details.tsx +++ b/core/app/[locale]/(default)/account/order/[slug]/_components/order-details.tsx @@ -261,20 +261,18 @@ export const OrderDetails = async ({ data }: { data: OrderDataType }) => { /> )}
    - {lineItems.map((shipment) => { - return ( -
  • - }> - - -
  • - ); - })} + {lineItems.map((shipment) => ( +
  • + }> + + +
  • + ))}
); diff --git a/core/app/[locale]/(default)/account/orders/_components/orders-list.tsx b/core/app/[locale]/(default)/account/orders/_components/orders-list.tsx index fda7498b5b..6c1516dfb2 100644 --- a/core/app/[locale]/(default)/account/orders/_components/orders-list.tsx +++ b/core/app/[locale]/(default)/account/orders/_components/orders-list.tsx @@ -158,85 +158,81 @@ const OrderDetails = async ({ ); }; -export const OrdersList = ({ customerOrders }: OrdersListProps) => { - return ( -
    - {customerOrders.map(({ entityId, orderedAt, status, totalIncTax, consignments }) => { - const shippingConsignments = consignments.shipping - ? consignments.shipping.map(({ lineItems, shipments }) => ({ - lineItems: removeEdgesAndNodes(lineItems), - shipments: removeEdgesAndNodes(shipments), - })) - : undefined; - // NOTE: tracking url will be supported later - const trackingUrl = shippingConsignments - ? shippingConsignments - .flatMap(({ shipments }) => - shipments.map((shipment) => { - if ( - shipment.tracking?.__typename === 'OrderShipmentNumberAndUrlTracking' || - shipment.tracking?.__typename === 'OrderShipmentUrlOnlyTracking' - ) { - return shipment.tracking.url; - } +export const OrdersList = ({ customerOrders }: OrdersListProps) => ( +
      + {customerOrders.map(({ entityId, orderedAt, status, totalIncTax, consignments }) => { + const shippingConsignments = consignments.shipping + ? consignments.shipping.map(({ lineItems, shipments }) => ({ + lineItems: removeEdgesAndNodes(lineItems), + shipments: removeEdgesAndNodes(shipments), + })) + : undefined; + // NOTE: tracking url will be supported later + const trackingUrl = shippingConsignments + ? shippingConsignments + .flatMap(({ shipments }) => + shipments.map((shipment) => { + if ( + shipment.tracking?.__typename === 'OrderShipmentNumberAndUrlTracking' || + shipment.tracking?.__typename === 'OrderShipmentUrlOnlyTracking' + ) { + return shipment.tracking.url; + } - return null; - }), - ) - .find((url) => url !== null) - : undefined; + return null; + }), + ) + .find((url) => url !== null) + : undefined; - return ( -
    • - + +
      +
        + {(shippingConsignments ?? []).map(({ lineItems }) => + lineItems.slice(0, VisibleListItemsPerDevice.xl).map((shippedProduct) => ( +
      • + }> + + +
      • + )), + )} +
      + orderItems + shipment.lineItems.length, + 0, + )} /> -
      -
        - {(shippingConsignments ?? []).map(({ lineItems }) => { - return lineItems.slice(0, VisibleListItemsPerDevice.xl).map((shippedProduct) => { - return ( -
      • - }> - - -
      • - ); - }); - })} -
      - orderItems + shipment.lineItems.length, - 0, - )} - /> - -
      -
    • - ); - })} -
    - ); -}; + + + + ); + })} +
+); diff --git a/core/app/[locale]/(default)/account/orders/_components/product-snippet.tsx b/core/app/[locale]/(default)/account/orders/_components/product-snippet.tsx index f4b5b88565..9c82bd8a54 100644 --- a/core/app/[locale]/(default)/account/orders/_components/product-snippet.tsx +++ b/core/app/[locale]/(default)/account/orders/_components/product-snippet.tsx @@ -205,14 +205,12 @@ export const ProductSnippet = async ({
- {product.productOptions?.map(({ name: optionName, value }, idx) => { - return ( -

- {optionName}: - {value} -

- ); - })} + {product.productOptions?.map(({ name: optionName, value }, idx) => ( +

+ {optionName}: + {value} +

+ ))}

{t('qty')}: {product.quantity} @@ -244,36 +242,34 @@ export const ProductSnippet = async ({ ); }; -export const ProductSnippetSkeleton = ({ isExtended = false }: { isExtended?: boolean }) => { - return ( -

-
-
-
-
+export const ProductSnippetSkeleton = ({ isExtended = false }: { isExtended?: boolean }) => ( +
+
+
+
-
- {isExtended ? ( -
-
-
-
-
-
-
- ) : ( -
-
-
-
+
+
+ {isExtended ? ( +
+
+
+
+
- )} -
+
+ ) : ( +
+
+
+
+
+ )}
- ); -}; +
+); diff --git a/core/app/[locale]/(default)/account/orders/page-data.ts b/core/app/[locale]/(default)/account/orders/page-data.ts index ed411d4d2a..81e7c14360 100644 --- a/core/app/[locale]/(default)/account/orders/page-data.ts +++ b/core/app/[locale]/(default)/account/orders/page-data.ts @@ -112,15 +112,13 @@ export const getCustomerOrders = cache( } const data = { - orders: removeEdgesAndNodes(orders).map((order) => { - return { - ...order, - consignments: { - shipping: - order.consignments?.shipping && removeEdgesAndNodes(order.consignments.shipping), - }, - }; - }), + orders: removeEdgesAndNodes(orders).map((order) => ({ + ...order, + consignments: { + shipping: + order.consignments?.shipping && removeEdgesAndNodes(order.consignments.shipping), + }, + })), pageInfo: orders.pageInfo, }; diff --git a/core/app/[locale]/(default)/blog/page.tsx b/core/app/[locale]/(default)/blog/page.tsx index 7e3a18d83e..4e258ede5b 100644 --- a/core/app/[locale]/(default)/blog/page.tsx +++ b/core/app/[locale]/(default)/blog/page.tsx @@ -39,13 +39,11 @@ export default async function Blog(props: Props) {

{blogPosts.name}

    - {blogPosts.posts.items.map((post) => { - return ( -
  • - -
  • - ); - })} + {blogPosts.posts.items.map((post) => ( +
  • + +
  • + ))}
{blogPosts.name}
- {blogPosts.posts.items.map((post) => { - return ; - })} + {blogPosts.posts.items.map((post) => ( + + ))}
; type PhysicalItem = FragmentResult['physicalItems'][number]; type DigitalItem = FragmentResult['digitalItems'][number]; -export type Product = PhysicalItem | DigitalItem; +export type Product = PhysicalItem; interface Props { product: Product; diff --git a/core/app/[locale]/(default)/cart/_components/cart-viewed.tsx b/core/app/[locale]/(default)/cart/_components/cart-viewed.tsx index 06d7edba0d..13141020c6 100644 --- a/core/app/[locale]/(default)/cart/_components/cart-viewed.tsx +++ b/core/app/[locale]/(default)/cart/_components/cart-viewed.tsx @@ -11,7 +11,7 @@ import { CheckoutSummaryFragment } from './checkout-summary'; type FragmentResult = FragmentOf; type PhysicalItem = FragmentResult['physicalItems'][number]; type DigitalItem = FragmentResult['digitalItems'][number]; -type lineItem = PhysicalItem | DigitalItem; +type lineItem = PhysicalItem; interface Props { checkout: FragmentOf | null; @@ -19,21 +19,19 @@ interface Props { lineItems: lineItem[]; } -const lineItemTransform = (item: lineItem) => { - return { - product_id: item.productEntityId.toString(), - product_name: item.name, - brand_name: item.brand ?? undefined, - sku: item.sku ?? undefined, - sale_price: item.extendedSalePrice.value, - purchase_price: item.listPrice.value, - base_price: item.originalPrice.value, - retail_price: item.listPrice.value, - currency: item.listPrice.currencyCode, - variant_id: item.variantEntityId ? [item.variantEntityId] : undefined, - quantity: item.quantity, - }; -}; +const lineItemTransform = (item: lineItem) => ({ + product_id: item.productEntityId.toString(), + product_name: item.name, + brand_name: item.brand ?? undefined, + sku: item.sku ?? undefined, + sale_price: item.extendedSalePrice.value, + purchase_price: item.listPrice.value, + base_price: item.originalPrice.value, + retail_price: item.listPrice.value, + currency: item.listPrice.currencyCode, + variant_id: item.variantEntityId ? [item.variantEntityId] : undefined, + quantity: item.quantity, +}); export const CartViewed = ({ checkout, currencyCode, lineItems }: Props) => { useEffect(() => { diff --git a/core/app/[locale]/(default)/cart/_components/checkout-button.tsx b/core/app/[locale]/(default)/cart/_components/checkout-button.tsx index 91b23f213e..8ea49701ca 100644 --- a/core/app/[locale]/(default)/cart/_components/checkout-button.tsx +++ b/core/app/[locale]/(default)/cart/_components/checkout-button.tsx @@ -18,11 +18,9 @@ const InternalButton = () => { ); }; -export const CheckoutButton = ({ cartId }: { cartId: string }) => { - return ( -
- - - - ); -}; +export const CheckoutButton = ({ cartId }: { cartId: string }) => ( +
+ + + +); diff --git a/core/app/[locale]/(default)/cart/_components/checkout-summary.tsx b/core/app/[locale]/(default)/cart/_components/checkout-summary.tsx index 743a0f5124..451b40ef38 100644 --- a/core/app/[locale]/(default)/cart/_components/checkout-summary.tsx +++ b/core/app/[locale]/(default)/cart/_components/checkout-summary.tsx @@ -58,16 +58,16 @@ export const CheckoutSummary = async ({ checkout, geography }: Props) => {
{t('subTotal')} - {format.number(subtotal?.value || 0, { + {format.number(subtotal.value || 0, { style: 'currency', - currency: cart?.currencyCode, + currency: cart.currencyCode, })}
- {cart?.discountedAmount && ( + {cart.discountedAmount && (
{t('discounts')} @@ -88,7 +88,7 @@ export const CheckoutSummary = async ({ checkout, geography }: Props) => { {format.number(taxTotal.value, { style: 'currency', - currency: cart?.currencyCode, + currency: cart.currencyCode, })}
@@ -97,9 +97,9 @@ export const CheckoutSummary = async ({ checkout, geography }: Props) => {
{t('grandTotal')} - {format.number(grandTotal?.value || 0, { + {format.number(grandTotal.value || 0, { style: 'currency', - currency: cart?.currencyCode, + currency: cart.currencyCode, })}
diff --git a/core/app/[locale]/(default)/cart/_components/item-quantity/index.tsx b/core/app/[locale]/(default)/cart/_components/item-quantity/index.tsx index a7f2531044..e397e441fa 100644 --- a/core/app/[locale]/(default)/cart/_components/item-quantity/index.tsx +++ b/core/app/[locale]/(default)/cart/_components/item-quantity/index.tsx @@ -14,8 +14,8 @@ import { updateItemQuantity } from './update-item-quantity'; type CartSelectedOptionsInput = ReturnType>; -const parseSelectedOptions = (selectedOptions: Product['selectedOptions']) => { - return selectedOptions.reduce((accum, option) => { +const parseSelectedOptions = (selectedOptions: Product['selectedOptions']) => + selectedOptions.reduce((accum, option) => { let multipleChoicesOptionInput; let checkboxOptionInput; let numberFieldOptionInput; @@ -111,7 +111,6 @@ const parseSelectedOptions = (selectedOptions: Product['selectedOptions']) => { return accum; }, {}); -}; const SubmitButton = ({ children, ...props }: ComponentPropsWithoutRef<'button'>) => { const { pending } = useFormStatus(); diff --git a/core/app/[locale]/(default)/cart/_components/remove-item.tsx b/core/app/[locale]/(default)/cart/_components/remove-item.tsx index d0fc01baf1..457ec5d6e7 100644 --- a/core/app/[locale]/(default)/cart/_components/remove-item.tsx +++ b/core/app/[locale]/(default)/cart/_components/remove-item.tsx @@ -16,28 +16,26 @@ type FragmentResult = FragmentOf; type PhysicalItem = FragmentResult['physicalItems'][number]; type DigitalItem = FragmentResult['digitalItems'][number]; -export type Product = PhysicalItem | DigitalItem; +export type Product = PhysicalItem; interface Props { currency: string; product: Product; } -const lineItemTransform = (item: Product) => { - return { - product_id: item.productEntityId.toString(), - product_name: item.name, - brand_name: item.brand ?? undefined, - sku: item.sku ?? undefined, - sale_price: item.extendedSalePrice.value, - purchase_price: item.listPrice.value, - base_price: item.originalPrice.value, - retail_price: item.listPrice.value, - currency: item.listPrice.currencyCode, - variant_id: item.variantEntityId ? [item.variantEntityId] : undefined, - quantity: item.quantity, - }; -}; +const lineItemTransform = (item: Product) => ({ + product_id: item.productEntityId.toString(), + product_name: item.name, + brand_name: item.brand ?? undefined, + sku: item.sku ?? undefined, + sale_price: item.extendedSalePrice.value, + purchase_price: item.listPrice.value, + base_price: item.originalPrice.value, + retail_price: item.listPrice.value, + currency: item.listPrice.currencyCode, + variant_id: item.variantEntityId ? [item.variantEntityId] : undefined, + quantity: item.quantity, +}); export const RemoveItem = ({ currency, product }: Props) => { const t = useTranslations('Cart.SubmitRemoveItem'); diff --git a/core/app/[locale]/(default)/cart/_components/shipping-estimator/index.tsx b/core/app/[locale]/(default)/cart/_components/shipping-estimator/index.tsx index 7199863ac8..879ea14ab2 100644 --- a/core/app/[locale]/(default)/cart/_components/shipping-estimator/index.tsx +++ b/core/app/[locale]/(default)/cart/_components/shipping-estimator/index.tsx @@ -97,16 +97,14 @@ export const ShippingEstimator = ({ checkout, shippingCountries }: Props) => { {showShippingOptions && checkout.shippingConsignments && (
- {checkout.shippingConsignments.map((consignment) => { - return ( - - ); - })} + {checkout.shippingConsignments.map((consignment) => ( + + ))}
)}
diff --git a/core/app/[locale]/(default)/cart/_components/shipping-options/index.tsx b/core/app/[locale]/(default)/cart/_components/shipping-options/index.tsx index d23fc5bdfd..5d441ae83d 100644 --- a/core/app/[locale]/(default)/cart/_components/shipping-options/index.tsx +++ b/core/app/[locale]/(default)/cart/_components/shipping-options/index.tsx @@ -21,7 +21,7 @@ export const ShippingOptions = ({ data, checkoutEntityId, currencyCode }: Props) const format = useFormatter(); const { availableShippingOptions, entityId } = data; - const shippingOptions = availableShippingOptions?.map( + const shippingOptions = availableShippingOptions.map( ({ cost, description, entityId: shippingOptionEntityId, isRecommended }) => ({ cost: cost.value, description, diff --git a/core/app/[locale]/(default)/product/[slug]/_components/product-form/_actions/add-to-cart.ts b/core/app/[locale]/(default)/product/[slug]/_components/product-form/_actions/add-to-cart.ts index 73adec219e..c7a2de6e90 100644 --- a/core/app/[locale]/(default)/product/[slug]/_components/product-form/_actions/add-to-cart.ts +++ b/core/app/[locale]/(default)/product/[slug]/_components/product-form/_actions/add-to-cart.ts @@ -43,7 +43,9 @@ export async function handleAddToCart( let dateFieldOptionInput; // Skip empty strings since option is empty - if (optionValueEntityId === '') return accum; + if (optionValueEntityId === '') { + return accum; + } switch (option.__typename) { case 'MultipleChoiceOption': diff --git a/core/app/[locale]/(default)/product/[slug]/_components/product-review-schema.tsx b/core/app/[locale]/(default)/product/[slug]/_components/product-review-schema.tsx index 8e143a7684..482a7873d1 100644 --- a/core/app/[locale]/(default)/product/[slug]/_components/product-review-schema.tsx +++ b/core/app/[locale]/(default)/product/[slug]/_components/product-review-schema.tsx @@ -29,24 +29,22 @@ export const ProductReviewSchema = ({ reviews, productId }: Props) => { '@context': 'https://schema.org', '@type': 'Product', '@id': `product-${productId}`, - review: reviews.map((review) => { - return { - '@type': 'Review' as const, - datePublished: format.dateTime(new Date(review.createdAt.utc)), - name: review.title, - reviewBody: review.text, - author: { - '@type': 'Person' as const, - name: review.author.name, - }, - reviewRating: { - '@type': 'Rating' as const, - bestRating: 5, - ratingValue: review.rating, - worstRating: 1, - }, - }; - }), + review: reviews.map((review) => ({ + '@type': 'Review' as const, + datePublished: format.dateTime(new Date(review.createdAt.utc)), + name: review.title, + reviewBody: review.text, + author: { + '@type': 'Person' as const, + name: review.author.name, + }, + reviewRating: { + '@type': 'Rating' as const, + bestRating: 5, + ratingValue: review.rating, + worstRating: 1, + }, + })), }; return ( diff --git a/core/app/[locale]/(default)/product/[slug]/_components/reviews.tsx b/core/app/[locale]/(default)/product/[slug]/_components/reviews.tsx index def993ece2..4b6b4dfa37 100644 --- a/core/app/[locale]/(default)/product/[slug]/_components/reviews.tsx +++ b/core/app/[locale]/(default)/product/[slug]/_components/reviews.tsx @@ -77,24 +77,22 @@ export const Reviews = async ({ productId }: Props) => {

{t('unreviewed')}

) : ( - reviews.map((review) => { - return ( -
  • -

    - - {t('reviewRating', { rating: review.rating })} -

    -

    {review.title}

    -

    - {t('reviewAuthor', { author: review.author.name })}{' '} - {format.dateTime(new Date(review.createdAt.utc), { - dateStyle: 'medium', - })} -

    -

    {review.text}

    -
  • - ); - }) + reviews.map((review) => ( +
  • +

    + + {t('reviewRating', { rating: review.rating })} +

    +

    {review.title}

    +

    + {t('reviewAuthor', { author: review.author.name })}{' '} + {format.dateTime(new Date(review.createdAt.utc), { + dateStyle: 'medium', + })} +

    +

    {review.text}

    +
  • + )) )} {reviews.length > 0 && } diff --git a/core/app/[locale]/(default)/product/[slug]/static/page.tsx b/core/app/[locale]/(default)/product/[slug]/static/page.tsx index 2cb5384e7c..f03230b285 100644 --- a/core/app/[locale]/(default)/product/[slug]/static/page.tsx +++ b/core/app/[locale]/(default)/product/[slug]/static/page.tsx @@ -51,12 +51,12 @@ const getFeaturedProducts = cache(async ({ first = 12 }: Options = {}) => { export async function generateStaticParams() { const products = await getFeaturedProducts(); - return locales.map((locale) => { - return products.map((product) => ({ + return locales.map((locale) => + products.map((product) => ({ locale, slug: product.entityId.toString(), - })); - }); + })), + ); } interface Props { diff --git a/core/app/[locale]/(default)/webpages/contact/[id]/contact-us/index.tsx b/core/app/[locale]/(default)/webpages/contact/[id]/contact-us/index.tsx index 7096ceb77c..93fe3e824f 100644 --- a/core/app/[locale]/(default)/webpages/contact/[id]/contact-us/index.tsx +++ b/core/app/[locale]/(default)/webpages/contact/[id]/contact-us/index.tsx @@ -74,7 +74,7 @@ export const ContactUs = ({ node, reCaptchaSettings }: Props) => { const t = useTranslations('WebPages.ContactUs.Form'); - if (node?.__typename !== 'ContactPage') { + if (node.__typename !== 'ContactPage') { return null; } diff --git a/core/app/favicon.ico/route.ts b/core/app/favicon.ico/route.ts index f79e7bf387..b9dab82b91 100644 --- a/core/app/favicon.ico/route.ts +++ b/core/app/favicon.ico/route.ts @@ -1,4 +1,3 @@ -/* eslint-disable check-file/folder-naming-convention */ /* * Proxy to the store's favicon URL * diff --git a/core/app/login/token/[token]/route.ts b/core/app/login/token/[token]/route.ts index bab85d14c0..72fca1a1f9 100644 --- a/core/app/login/token/[token]/route.ts +++ b/core/app/login/token/[token]/route.ts @@ -5,7 +5,6 @@ */ import { decodeJwt } from 'jose'; -// eslint-disable-next-line @typescript-eslint/no-restricted-imports import { redirect, unstable_rethrow as rethrow } from 'next/navigation'; import { signIn } from '~/auth'; diff --git a/core/app/notifications.tsx b/core/app/notifications.tsx index a529a4892b..baf4c0651e 100644 --- a/core/app/notifications.tsx +++ b/core/app/notifications.tsx @@ -1,14 +1,12 @@ import { Toaster } from 'react-hot-toast'; -export const Notifications = () => { - return ( - svg]:!shrink-0', - }} - /> - ); -}; +export const Notifications = () => ( + svg]:!shrink-0', + }} + /> +); diff --git a/core/app/robots.txt/route.ts b/core/app/robots.txt/route.ts index d32dc5eb34..0cfb1f3c76 100644 --- a/core/app/robots.txt/route.ts +++ b/core/app/robots.txt/route.ts @@ -1,4 +1,3 @@ -/* eslint-disable check-file/folder-naming-convention */ /* * Robots.txt route * diff --git a/core/app/sitemap.xml/route.ts b/core/app/sitemap.xml/route.ts index 2a3f4d9c1d..4ff60316d2 100644 --- a/core/app/sitemap.xml/route.ts +++ b/core/app/sitemap.xml/route.ts @@ -1,4 +1,3 @@ -/* eslint-disable check-file/folder-naming-convention */ /* * Proxy to the existing BigCommerce sitemap index on the canonical URL */ diff --git a/core/app/xmlsitemap.php/route.ts b/core/app/xmlsitemap.php/route.ts index cd9b7815bf..c7e2eb9234 100644 --- a/core/app/xmlsitemap.php/route.ts +++ b/core/app/xmlsitemap.php/route.ts @@ -1,4 +1,3 @@ -/* eslint-disable check-file/folder-naming-convention */ import { defaultLocale, permanentRedirect } from '~/i18n/routing'; /* diff --git a/core/auth/customer-login-api.ts b/core/auth/customer-login-api.ts index dcf8ca8873..7e626d108e 100644 --- a/core/auth/customer-login-api.ts +++ b/core/auth/customer-login-api.ts @@ -21,7 +21,7 @@ import { SignJWT } from 'jose'; export const generateCustomerLoginApiJwt = async ( customerId: number, channelId: number, - redirectTo: string = '/account/orders', + redirectTo = '/account/orders', additionalClaims?: Record, ): Promise => { const clientId = process.env.BIGCOMMERCE_CLIENT_ID; @@ -56,5 +56,5 @@ export const generateCustomerLoginApiJwt = async ( const secretKey = new TextEncoder().encode(clientSecret); // Create and sign the JWT - return await new SignJWT(payload).setProtectedHeader({ alg: 'HS256', typ: 'JWT' }).sign(secretKey); + return new SignJWT(payload).setProtectedHeader({ alg: 'HS256', typ: 'JWT' }).sign(secretKey); }; diff --git a/core/client/queries/get-cart.ts b/core/client/queries/get-cart.ts index 1adbebb68a..06c945a13e 100644 --- a/core/client/queries/get-cart.ts +++ b/core/client/queries/get-cart.ts @@ -143,9 +143,10 @@ export const getCart = cache(async (cartId?: string, channelId?: string) => { return; } - const totalExtendedListPrice = cart.lineItems.physicalItems.reduce((acc, item) => { - return acc + item.extendedListPrice.value; - }, 0); + const totalExtendedListPrice = cart.lineItems.physicalItems.reduce( + (acc, item) => acc + item.extendedListPrice.value, + 0, + ); return { ...cart, diff --git a/core/components/form-fields/checkboxes.tsx b/core/components/form-fields/checkboxes.tsx index f198119f43..fc2a2ccb80 100644 --- a/core/components/form-fields/checkboxes.tsx +++ b/core/components/form-fields/checkboxes.tsx @@ -89,9 +89,9 @@ export const Checkboxes = ({ if (checked) { setCheckboxValues((prevState) => [...prevState, +entityId]); } else { - setCheckboxValues((prevState) => { - return prevState.filter((prevValue) => prevValue !== +entityId); - }); + setCheckboxValues((prevState) => + prevState.filter((prevValue) => prevValue !== +entityId), + ); } }} required={field.isRequired && checkboxValues.length === 0 ? true : undefined} diff --git a/core/components/form-fields/password.tsx b/core/components/form-fields/password.tsx index 06ee523e75..bcbf7e8c32 100644 --- a/core/components/form-fields/password.tsx +++ b/core/components/form-fields/password.tsx @@ -57,9 +57,7 @@ export const Password = ({ defaultValue, field, isValid, name, onChange }: Passw {fieldName === 'confirmPassword' && ( { - return !isValid; - }} + match={() => !isValid} > {t('confirmPassword')} diff --git a/core/components/form-fields/shared/field-handlers.ts b/core/components/form-fields/shared/field-handlers.ts index a3402b1b0f..de15b01916 100644 --- a/core/components/form-fields/shared/field-handlers.ts +++ b/core/components/form-fields/shared/field-handlers.ts @@ -37,7 +37,9 @@ const createPreSubmitPicklistValidationHandler = ( ); return (form: HTMLFormElement | null) => { - if (!form) return; + if (!form) { + return; + } const multipleChoices = Object.fromEntries( [...new FormData(form).entries()] @@ -79,7 +81,9 @@ const createPreSubmitCheckboxesValidationHandler = ( ); return (form: HTMLFormElement | null) => { - if (!form) return; + if (!form) { + return; + } const checkboxesFormFields = Object.fromEntries( [...new FormData(form).entries()] diff --git a/core/components/form-fields/shared/parse-fields.ts b/core/components/form-fields/shared/parse-fields.ts index bd3434ddba..445ef88123 100644 --- a/core/components/form-fields/shared/parse-fields.ts +++ b/core/components/form-fields/shared/parse-fields.ts @@ -72,7 +72,7 @@ const updateFormFields = ({ fieldValueEntityIds: [Number(fieldValue)], fieldEntityId, }; - const previouslyParsedCheckbox = definedCheckboxes?.find( + const previouslyParsedCheckbox = definedCheckboxes.find( (defined) => fieldEntityId === defined.fieldEntityId, ); diff --git a/core/components/header/quick-search.tsx b/core/components/header/quick-search.tsx index c3b5908580..e42b3d46cc 100644 --- a/core/components/header/quick-search.tsx +++ b/core/components/header/quick-search.tsx @@ -58,9 +58,7 @@ export const QuickSearch = ({ logo }: SearchProps) => { return categories; }, {}), - ).map(([name, path]) => { - return { label: name, href: path }; - }) + ).map(([name, path]) => ({ label: name, href: path })) : [], brands: searchResults.products.length > 0 @@ -72,9 +70,7 @@ export const QuickSearch = ({ logo }: SearchProps) => { return brands; }, {}), - ).map(([name, path]) => { - return { label: name, href: path }; - }) + ).map(([name, path]) => ({ label: name, href: path })) : [], }; } diff --git a/core/components/image/index.tsx b/core/components/image/index.tsx index 1d2b14502d..7ef7e6b449 100644 --- a/core/components/image/index.tsx +++ b/core/components/image/index.tsx @@ -1,6 +1,5 @@ 'use client'; -// eslint-disable-next-line @typescript-eslint/no-restricted-imports import NextImage, { ImageProps } from 'next/image'; import bcCdnImageLoader from '~/lib/cdn-image-loader'; diff --git a/core/components/product-card/index.tsx b/core/components/product-card/index.tsx index 953a4289c0..2e9521637a 100644 --- a/core/components/product-card/index.tsx +++ b/core/components/product-card/index.tsx @@ -39,7 +39,7 @@ export const ProductCard = ({ name={name} price={price} showCompare={showCompare} - subtitle={brand?.name} + subtitle={brand.name} /> ); }; diff --git a/core/components/ui/accordions/accordions.tsx b/core/components/ui/accordions/accordions.tsx index 6a833f12c7..c2fb3dfdf8 100644 --- a/core/components/ui/accordions/accordions.tsx +++ b/core/components/ui/accordions/accordions.tsx @@ -21,24 +21,22 @@ type Props = type: 'multiple'; }; -const Accordions = ({ accordions, ...props }: Props) => { - return ( - - {accordions.map((accordion, i) => ( - - - - {accordion.title} - - - - - {accordion.content} - - - ))} - - ); -}; +const Accordions = ({ accordions, ...props }: Props) => ( + + {accordions.map((accordion, i) => ( + + + + {accordion.title} + + + + + {accordion.content} + + + ))} + +); export { Accordions }; diff --git a/core/components/ui/badge/badge.tsx b/core/components/ui/badge/badge.tsx index b1a68131c4..430e6c6b2b 100644 --- a/core/components/ui/badge/badge.tsx +++ b/core/components/ui/badge/badge.tsx @@ -7,18 +7,16 @@ interface Props { className?: string; } -const Badge = ({ children, className, ...props }: Props) => { - return ( - - {children} - - ); -}; +const Badge = ({ children, className, ...props }: Props) => ( + + {children} + +); export { Badge }; diff --git a/core/components/ui/blog-post-card/blog-post-card.tsx b/core/components/ui/blog-post-card/blog-post-card.tsx index 41975b91a6..ae3336151d 100644 --- a/core/components/ui/blog-post-card/blog-post-card.tsx +++ b/core/components/ui/blog-post-card/blog-post-card.tsx @@ -26,40 +26,38 @@ const BlogPostCard = ({ image, title, ...props -}: Props) => { - return ( -
    - {image ? ( -
    - - {image.altText} - -
    - ) : ( -
    -

    - {title} -

    - {date} -
    - )} -

    - {title} -

    -

    {content}

    - - {date} - {Boolean(author) && , by {author}} - -
    - ); -}; +}: Props) => ( +
    + {image ? ( +
    + + {image.altText} + +
    + ) : ( +
    +

    + {title} +

    + {date} +
    + )} +

    + {title} +

    +

    {content}

    + + {date} + {Boolean(author) && , by {author}} + +
    +); BlogPostCard.displayName = 'BlogPostCard'; diff --git a/core/components/ui/carousel/carousel.tsx b/core/components/ui/carousel/carousel.tsx index 209b2d3a39..71d6421057 100644 --- a/core/components/ui/carousel/carousel.tsx +++ b/core/components/ui/carousel/carousel.tsx @@ -26,21 +26,23 @@ const Carousel = ({ className, title, pageSize = 4, products, ...props }: Props) const t = useTranslations('Components.Carousel'); - const groupedProducts = useMemo(() => { - return products.reduce((batches, _, index) => { - if (index % itemsPerGroup === 0) { - batches.push([]); - } - - const product = products[index]; - - if (batches[batches.length - 1] && product) { - batches[batches.length - 1]?.push(product); - } - - return batches; - }, []); - }, [products, itemsPerGroup]); + const groupedProducts = useMemo( + () => + products.reduce((batches, _, index) => { + if (index % itemsPerGroup === 0) { + batches.push([]); + } + + const product = products[index]; + + if (batches[batches.length - 1] && product) { + batches[batches.length - 1]?.push(product); + } + + return batches; + }, []), + [products, itemsPerGroup], + ); const [canScrollPrev, setCanScrollPrev] = useState(false); const [canScrollNext, setCanScrollNext] = useState(false); diff --git a/core/components/ui/compare-drawer/compare-drawer.tsx b/core/components/ui/compare-drawer/compare-drawer.tsx index 90a143520d..c4d8ddde94 100644 --- a/core/components/ui/compare-drawer/compare-drawer.tsx +++ b/core/components/ui/compare-drawer/compare-drawer.tsx @@ -79,15 +79,13 @@ const CompareDrawer = () => {
      - {products.map((product) => { - return ( - setProducts(products.filter(({ id }) => id !== product.id))} - product={product} - /> - ); - })} + {products.map((product) => ( + setProducts(products.filter(({ id }) => id !== product.id))} + product={product} + /> + ))}
    @@ -101,15 +99,13 @@ const CompareDrawer = () => {
      - {products.map((product) => { - return ( - setProducts(products.filter(({ id }) => id !== product.id))} - product={product} - /> - ); - })} + {products.map((product) => ( + setProducts(products.filter(({ id }) => id !== product.id))} + product={product} + /> + ))}
    diff --git a/core/components/ui/compare-drawer/context.tsx b/core/components/ui/compare-drawer/context.tsx index 833b4da99a..0f3dfff951 100644 --- a/core/components/ui/compare-drawer/context.tsx +++ b/core/components/ui/compare-drawer/context.tsx @@ -18,12 +18,9 @@ const CompareDrawerContext = createContext<{ setProducts: (products: Product[]) => void; } | null>(null); -const isCheckedProducts = (products: unknown): products is Product[] => { - return ( - Array.isArray(products) && - products.every((product) => product !== null && typeof product === 'object' && 'id' in product) - ); -}; +const isCheckedProducts = (products: unknown): products is Product[] => + Array.isArray(products) && + products.every((product) => product !== null && typeof product === 'object' && 'id' in product); const CompareDrawerProvider = ({ children }: PropsWithChildren) => { const [products, setProducts] = useState([]); diff --git a/core/components/ui/dropdown/dropdown.tsx b/core/components/ui/dropdown/dropdown.tsx index 2658a272ec..a5c77040af 100644 --- a/core/components/ui/dropdown/dropdown.tsx +++ b/core/components/ui/dropdown/dropdown.tsx @@ -22,47 +22,45 @@ interface Props { trigger: ReactNode; } -const Dropdown = ({ align = 'center', className, items, trigger }: Props) => { - return ( - - - {trigger} - +const Dropdown = ({ align = 'center', className, items, trigger }: Props) => ( + + + {trigger} + - - - {items.map((item) => - 'href' in item ? ( - - + + {items.map((item) => + 'href' in item ? ( + + + {item.label} + + + ) : ( + +
    + -
    -
    - ), - )} -
    -
    -
    - ); -}; + {item.name} + + + + ), + )} + + +
    +); export { Dropdown }; diff --git a/core/components/ui/form/checkbox/checkbox.tsx b/core/components/ui/form/checkbox/checkbox.tsx index d298d8ad4b..63847b49ed 100644 --- a/core/components/ui/form/checkbox/checkbox.tsx +++ b/core/components/ui/form/checkbox/checkbox.tsx @@ -9,26 +9,24 @@ interface Props extends ComponentPropsWithRef { } const Checkbox = forwardRef, Props>( - ({ className, defaultChecked, error = false, onCheckedChange, ...props }, ref) => { - return ( - - - - - - ); - }, + ({ className, defaultChecked, error = false, onCheckedChange, ...props }, ref) => ( + + + + + + ), ); Checkbox.displayName = 'Checkbox'; diff --git a/core/components/ui/form/date-picker/date-picker.tsx b/core/components/ui/form/date-picker/date-picker.tsx index bc48163d38..e2770eb16f 100644 --- a/core/components/ui/form/date-picker/date-picker.tsx +++ b/core/components/ui/form/date-picker/date-picker.tsx @@ -11,36 +11,34 @@ import { DayPicker, DayPickerSingleProps } from 'react-day-picker'; import { Input } from '../input'; -const Calendar = ({ ...props }: ComponentPropsWithoutRef) => { - return ( - ) => ( + , - IconRight: () => , - }} - {...props} - /> - ); -}; + day_today: 'bg-secondary/10', + day_disabled: 'text-gray-400 aria-selected:bg-gray-100 aria-selected:text-white', + }} + components={{ + IconLeft: () => , + IconRight: () => , + }} + {...props} + /> +); Calendar.displayName = 'Calendar'; diff --git a/core/components/ui/form/text-area/text-area.tsx b/core/components/ui/form/text-area/text-area.tsx index d7f6df3ae6..e29e11ee36 100644 --- a/core/components/ui/form/text-area/text-area.tsx +++ b/core/components/ui/form/text-area/text-area.tsx @@ -7,20 +7,18 @@ interface Props extends ComponentPropsWithRef<'textarea'> { } const TextArea = forwardRef, Props>( - ({ className, error = false, ...props }, ref) => { - return ( -