From afcbe2017de8c1a557dca5325de328b92d0884c7 Mon Sep 17 00:00:00 2001 From: Felix Perron-Brault Date: Mon, 5 Aug 2024 14:46:04 -0400 Subject: [PATCH 1/4] chore: add automatic sorting for tailwind classes (#4233) This PR adds `prettier-plugin-tailwindcss`, which is the [recommended solution](https://tailwindcss.com/blog/automatic-class-sorting-with-prettier) to sort tailwind classes. https://coveord.atlassian.net/browse/KIT-3439 --------- Co-authored-by: Alex Prudhomme <78121423+alexprudhomme@users.noreply.github.com> --- .prettierrc.js | 5 +- package-lock.json | 75 +++++++++++++++++++ package.json | 1 + .../atomic-commerce-products-per-page.pcss | 2 +- .../atomic-commerce-search-box.tsx | 4 +- .../atomic-commerce-category-facet.pcss | 4 +- .../atomic-commerce-facet-number-input.tsx | 4 +- .../atomic-product-children.tsx | 2 +- .../atomic-product-description.tsx | 2 +- .../atomic-product-price.tsx | 4 +- .../atomic-product-rating.tsx | 2 +- .../common/atomic-modal/atomic-modal.pcss | 2 +- .../common/atomic-modal/atomic-modal.tsx | 15 ++-- .../common/atomic-rating/atomic-rating.tsx | 2 +- .../common/breadbox/breadcrumb-clear-all.tsx | 2 +- .../common/breadbox/breadcrumb-container.tsx | 6 +- .../common/breadbox/breadcrumb-content.tsx | 2 +- .../common/breadbox/breadcrumb-show-less.tsx | 2 +- .../common/breadbox/breadcrumb-show-more.tsx | 2 +- .../atomic/src/components/common/carousel.tsx | 4 +- .../facets/category-facet/search-value.tsx | 8 +- .../common/facets/facet-common.pcss | 4 +- .../facet-container/facet-container.tsx | 2 +- .../facet-date-input/facet-date-input.tsx | 4 +- .../facets/facet-header/facet-header.tsx | 8 +- .../facet-number-input/facet-number-input.tsx | 4 +- .../facet-placeholder/facet-placeholder.tsx | 6 +- .../facet-search/facet-search-input.tsx | 8 +- .../facet-search/facet-search-matches.tsx | 4 +- .../facet-value-box/facet-value-box.pcss | 2 +- .../facet-value-box/facet-value-box.tsx | 4 +- .../facet-value-checkbox.pcss | 4 +- .../facet-value-exclude.tsx | 2 +- .../facet-value-label-highlight.tsx | 2 +- .../facet-value-link/facet-value-link.tsx | 2 +- .../atomic-citation/atomic-citation.tsx | 14 ++-- ...atomic-generated-answer-feedback-modal.tsx | 16 ++-- .../common/generated-answer/copy-button.tsx | 2 +- .../generated-answer/feedback-button.tsx | 2 +- .../generated-answer-common.tsx | 8 +- .../generated-markdown-content.pcss | 14 ++-- .../generated-markdown-content.tsx | 2 +- .../generated-text-content.tsx | 2 +- .../generated-answer/rephrase-buttons.tsx | 8 +- .../common/generated-answer/retry-prompt.tsx | 4 +- .../common/generated-answer/show-button.tsx | 4 +- .../generated-answer/source-citations.tsx | 4 +- .../styles/generated-answer.pcss | 6 +- .../src/components/common/iconButton.tsx | 6 +- .../image-carousel-indicators.tsx | 10 +-- .../common/image-carousel/image-carousel.tsx | 2 +- .../common/items-per-page/label.tsx | 2 +- .../components/common/load-more/button.tsx | 2 +- .../common/load-more/progress-bar.tsx | 4 +- .../components/common/load-more/summary.tsx | 2 +- .../src/components/common/no-items/cancel.tsx | 2 +- .../components/common/no-items/container.tsx | 2 +- .../common/no-items/magnifying-glass.tsx | 2 +- .../components/common/no-items/no-items.tsx | 4 +- .../src/components/common/no-items/tips.tsx | 2 +- .../components/common/pager/pager-buttons.tsx | 6 +- .../query-correction/trigger-correction.tsx | 4 +- .../common/query-error/container.tsx | 2 +- .../common/query-error/description.tsx | 2 +- .../components/common/query-error/details.tsx | 2 +- .../components/common/query-error/link.tsx | 2 +- .../common/query-error/show-more.tsx | 2 +- .../components/common/query-error/title.tsx | 2 +- .../components/common/query-summary/guard.tsx | 2 +- .../components/common/refine-modal/body.tsx | 2 +- .../components/common/refine-modal/button.tsx | 2 +- .../common/refine-modal/filters.tsx | 4 +- .../components/common/refine-modal/guard.tsx | 2 +- .../components/common/refine-modal/modal.tsx | 6 +- .../components/common/refine-modal/sort.tsx | 8 +- .../common/search-box/clear-button.tsx | 4 +- .../common/search-box/search-box.pcss | 4 +- .../common/search-box/search-input.tsx | 6 +- .../common/search-box/search-text-area.tsx | 8 +- .../common/search-box/submit-button.tsx | 4 +- .../search-box/text-area-clear-button.tsx | 6 +- .../search-box/text-area-submit-button.tsx | 6 +- ...atomic-smart-snippet-collapse-wrapper.pcss | 2 +- .../atomic-smart-snippet-collapse-wrapper.tsx | 4 +- ...tomic-smart-snippet-expandable-answer.pcss | 2 +- ...atomic-smart-snippet-expandable-answer.tsx | 4 +- .../atomic-smart-snippet-feedback-banner.tsx | 4 +- .../atomic-smart-snippet-feedback-modal.pcss | 4 +- .../smart-snippet-feedback-modal-common.tsx | 8 +- .../smart-snippet-suggestions-common.tsx | 10 +-- .../smart-snippet-common.tsx | 2 +- .../src/components/common/sort/container.tsx | 2 +- .../src/components/common/sort/guard.tsx | 2 +- .../src/components/common/sort/label.tsx | 2 +- .../src/components/common/sort/select.tsx | 2 +- .../common/suggestions/query-suggestions.tsx | 6 +- .../common/suggestions/recent-queries.tsx | 8 +- .../common/tab-manager/tab-button.tsx | 2 +- .../common/tab-manager/tab-dropdown.tsx | 4 +- .../src/components/common/tabs/tab-bar.tsx | 2 +- .../components/common/tabs/tab-popover.tsx | 8 +- .../atomic-insight-full-search-button.pcss | 4 +- .../atomic-insight-query-summary.tsx | 2 +- .../atomic-insight-refine-modal.tsx | 4 +- .../atomic-insight-result-action-bar.pcss | 4 +- .../atomic-insight-search-box.pcss | 10 +-- .../atomic-insight-search-box.tsx | 4 +- .../atomic-insight-tab.pcss | 2 +- .../result-lists/styles/list-display.pcss | 2 +- .../ipx/atomic-ipx-body/atomic-ipx-body.pcss | 4 +- .../ipx/atomic-ipx-body/atomic-ipx-body.tsx | 4 +- .../atomic-ipx-button/atomic-ipx-button.pcss | 4 +- .../atomic-ipx-refine-modal.tsx | 4 +- .../atomic-ipx-refine-toggle.pcss | 4 +- .../ipx/atomic-ipx-tab/atomic-ipx-tab.pcss | 2 +- .../atomic-notifications.tsx | 6 +- .../atomic-relevance-inspector.tsx | 4 +- .../atomic-result-table-placeholder.tsx | 14 ++-- .../atomic-results-per-page.pcss | 2 +- .../atomic-search-box/atomic-search-box.pcss | 2 +- .../atomic-search-box/atomic-search-box.tsx | 4 +- .../atomic-category-facet.pcss | 4 +- .../atomic-color-facet/atomic-color-facet.tsx | 2 +- .../facets/atomic-popover/atomic-popover.tsx | 14 ++-- .../atomic-rating-range-facet.tsx | 2 +- .../atomic-segmented-facet-scrollable.tsx | 6 +- .../atomic-segmented-facet.tsx | 4 +- .../color-facet-checkbox.pcss | 2 +- .../facet-segmented-value.tsx | 4 +- .../atomic-quickview-modal.pcss | 2 +- .../atomic-quickview-modal.tsx | 6 +- .../atomic-quickview-sidebar.tsx | 14 ++-- .../atomic-quickview/atomic-quickview.tsx | 2 +- .../atomic-result-badge.tsx | 4 +- .../quickview-iframe/quickview-iframe.tsx | 2 +- .../atomic-tab-manager/atomic-tab-manager.tsx | 2 +- packages/atomic/src/global/global.pcss | 24 +++--- .../pages/examples/commerce-website/cart.html | 2 +- .../examples/commerce-website/homepage.html | 2 +- .../commerce-website/listing-pants.html | 2 +- .../listing-surf-accessories.html | 2 +- .../commerce-website/listing-towels.html | 2 +- .../examples/commerce-website/search.html | 6 +- .../src/pages/CommerceSearchPage.tsx | 2 +- 144 files changed, 384 insertions(+), 310 deletions(-) diff --git a/.prettierrc.js b/.prettierrc.js index ef1aec7470c..1f0b0cf9eef 100644 --- a/.prettierrc.js +++ b/.prettierrc.js @@ -5,7 +5,10 @@ const decoratorPlugin = JSON.stringify([ /** @type {import('prettier').Config} */ module.exports = { - plugins: ['@trivago/prettier-plugin-sort-imports'], + plugins: [ + '@trivago/prettier-plugin-sort-imports', + 'prettier-plugin-tailwindcss', + ], bracketSpacing: false, singleQuote: true, trailingComma: 'es5', diff --git a/package-lock.json b/package-lock.json index ca2201ee909..f7dac3070c0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -83,6 +83,7 @@ "nx": "19.0.4", "patch-package": "8.0.0", "prettier": "3.3.3", + "prettier-plugin-tailwindcss": "0.6.5", "react-syntax-highlighter": "15.5.0", "rimraf": "5.0.9", "semver": "7.6.3", @@ -47308,6 +47309,80 @@ "prettier": "^3.0.0" } }, + "node_modules/prettier-plugin-tailwindcss": { + "version": "0.6.5", + "resolved": "https://registry.npmjs.org/prettier-plugin-tailwindcss/-/prettier-plugin-tailwindcss-0.6.5.tgz", + "integrity": "sha512-axfeOArc/RiGHjOIy9HytehlC0ZLeMaqY09mm8YCkMzznKiDkwFzOpBvtuhuv3xG5qB73+Mj7OCe2j/L1ryfuQ==", + "dev": true, + "engines": { + "node": ">=14.21.3" + }, + "peerDependencies": { + "@ianvs/prettier-plugin-sort-imports": "*", + "@prettier/plugin-pug": "*", + "@shopify/prettier-plugin-liquid": "*", + "@trivago/prettier-plugin-sort-imports": "*", + "@zackad/prettier-plugin-twig-melody": "*", + "prettier": "^3.0", + "prettier-plugin-astro": "*", + "prettier-plugin-css-order": "*", + "prettier-plugin-import-sort": "*", + "prettier-plugin-jsdoc": "*", + "prettier-plugin-marko": "*", + "prettier-plugin-organize-attributes": "*", + "prettier-plugin-organize-imports": "*", + "prettier-plugin-sort-imports": "*", + "prettier-plugin-style-order": "*", + "prettier-plugin-svelte": "*" + }, + "peerDependenciesMeta": { + "@ianvs/prettier-plugin-sort-imports": { + "optional": true + }, + "@prettier/plugin-pug": { + "optional": true + }, + "@shopify/prettier-plugin-liquid": { + "optional": true + }, + "@trivago/prettier-plugin-sort-imports": { + "optional": true + }, + "@zackad/prettier-plugin-twig-melody": { + "optional": true + }, + "prettier-plugin-astro": { + "optional": true + }, + "prettier-plugin-css-order": { + "optional": true + }, + "prettier-plugin-import-sort": { + "optional": true + }, + "prettier-plugin-jsdoc": { + "optional": true + }, + "prettier-plugin-marko": { + "optional": true + }, + "prettier-plugin-organize-attributes": { + "optional": true + }, + "prettier-plugin-organize-imports": { + "optional": true + }, + "prettier-plugin-sort-imports": { + "optional": true + }, + "prettier-plugin-style-order": { + "optional": true + }, + "prettier-plugin-svelte": { + "optional": true + } + } + }, "node_modules/pretty-bytes": { "version": "5.6.0", "resolved": "https://registry.npmjs.org/pretty-bytes/-/pretty-bytes-5.6.0.tgz", diff --git a/package.json b/package.json index e7031a4eb17..44bd9beabe0 100644 --- a/package.json +++ b/package.json @@ -81,6 +81,7 @@ "nx": "19.0.4", "patch-package": "8.0.0", "prettier": "3.3.3", + "prettier-plugin-tailwindcss": "0.6.5", "react-syntax-highlighter": "15.5.0", "rimraf": "5.0.9", "semver": "7.6.3", diff --git a/packages/atomic/src/components/commerce/atomic-commerce-products-per-page/atomic-commerce-products-per-page.pcss b/packages/atomic/src/components/commerce/atomic-commerce-products-per-page/atomic-commerce-products-per-page.pcss index ba9ae1fb155..d8f29ba58f2 100644 --- a/packages/atomic/src/components/commerce/atomic-commerce-products-per-page/atomic-commerce-products-per-page.pcss +++ b/packages/atomic/src/components/commerce/atomic-commerce-products-per-page/atomic-commerce-products-per-page.pcss @@ -1,5 +1,5 @@ @import '../../../global/global.pcss'; .btn-page { - @apply w-10 h-10; + @apply h-10 w-10; } diff --git a/packages/atomic/src/components/commerce/atomic-commerce-search-box/atomic-commerce-search-box.tsx b/packages/atomic/src/components/commerce/atomic-commerce-search-box/atomic-commerce-search-box.tsx index cb3c8ffbd3e..2e5f573745d 100644 --- a/packages/atomic/src/components/commerce/atomic-commerce-search-box/atomic-commerce-search-box.tsx +++ b/packages/atomic/src/components/commerce/atomic-commerce-search-box/atomic-commerce-search-box.tsx @@ -535,7 +535,7 @@ export class AtomicCommerceSearchBox ? 'suggestions-double-list' : 'suggestions-single-list' }`} - class={`flex w-full z-10 absolute left-0 top-full rounded-md bg-background border border-neutral ${ + class={`bg-background border-neutral absolute left-0 top-full z-10 flex w-full rounded-md border ${ this.suggestionManager.hasSuggestions && this.isExpanded && !this.isSearchDisabledForEndUser(this.searchBoxState.value) @@ -604,7 +604,7 @@ export class AtomicCommerceSearchBox ); diff --git a/packages/atomic/src/components/commerce/facets/atomic-commerce-category-facet/atomic-commerce-category-facet.pcss b/packages/atomic/src/components/commerce/facets/atomic-commerce-category-facet/atomic-commerce-category-facet.pcss index ceeb35f0691..b7a0b473a13 100644 --- a/packages/atomic/src/components/commerce/facets/atomic-commerce-category-facet/atomic-commerce-category-facet.pcss +++ b/packages/atomic/src/components/commerce/facets/atomic-commerce-category-facet/atomic-commerce-category-facet.pcss @@ -11,9 +11,9 @@ [part~='all-categories-button'], [part~='parent-button'] { - @apply w-full py-2.5 pr-2 pl-7 text-left relative flex items-center; + @apply relative flex w-full items-center py-2.5 pl-7 pr-2 text-left; } [part~='back-arrow'] { - @apply h-5 w-5 absolute left-1; + @apply absolute left-1 h-5 w-5; } diff --git a/packages/atomic/src/components/commerce/facets/facet-number-input/atomic-commerce-facet-number-input.tsx b/packages/atomic/src/components/commerce/facets/facet-number-input/atomic-commerce-facet-number-input.tsx index 714956e069b..757d7d504a4 100644 --- a/packages/atomic/src/components/commerce/facets/facet-number-input/atomic-commerce-facet-number-input.tsx +++ b/packages/atomic/src/components/commerce/facets/facet-number-input/atomic-commerce-facet-number-input.tsx @@ -79,7 +79,7 @@ export class FacetNumberInput { return (
{ e.preventDefault(); @@ -133,7 +133,7 @@ export class FacetNumberInput { style="outline-primary" type="submit" part="input-apply-button" - class="p-2.5 flex-none truncate" + class="flex-none truncate p-2.5" ariaLabel={applyAria} text={apply} > diff --git a/packages/atomic/src/components/commerce/product-template-components/atomic-product-children/atomic-product-children.tsx b/packages/atomic/src/components/commerce/product-template-components/atomic-product-children/atomic-product-children.tsx index 43f1e5ca7e2..61460ba9135 100644 --- a/packages/atomic/src/components/commerce/product-template-components/atomic-product-children/atomic-product-children.tsx +++ b/packages/atomic/src/components/commerce/product-template-components/atomic-product-children/atomic-product-children.tsx @@ -146,7 +146,7 @@ export class AtomicProductChildren private renderLabel() { return ( -
+
diff --git a/packages/atomic/src/components/commerce/product-template-components/atomic-product-description/atomic-product-description.tsx b/packages/atomic/src/components/commerce/product-template-components/atomic-product-description/atomic-product-description.tsx index b827878c3f9..e00153f0ba8 100644 --- a/packages/atomic/src/components/commerce/product-template-components/atomic-product-description/atomic-product-description.tsx +++ b/packages/atomic/src/components/commerce/product-template-components/atomic-product-description/atomic-product-description.tsx @@ -128,7 +128,7 @@ export class AtomicProductDescription > {' '} {this.bindings.i18n.t('show-more')} diff --git a/packages/atomic/src/components/commerce/product-template-components/atomic-product-price/atomic-product-price.tsx b/packages/atomic/src/components/commerce/product-template-components/atomic-product-price/atomic-product-price.tsx index cadc6ebcb31..c224720fa78 100644 --- a/packages/atomic/src/components/commerce/product-template-components/atomic-product-price/atomic-product-price.tsx +++ b/packages/atomic/src/components/commerce/product-template-components/atomic-product-price/atomic-product-price.tsx @@ -46,14 +46,14 @@ export class AtomicProductPrice return (
{hasPromotionalPrice && ( {this.ratingDetails !== null && ( - + ({this.ratingDetails}) )} diff --git a/packages/atomic/src/components/common/atomic-modal/atomic-modal.pcss b/packages/atomic/src/components/common/atomic-modal/atomic-modal.pcss index ccf13faa23b..d4026b1094e 100644 --- a/packages/atomic/src/components/common/atomic-modal/atomic-modal.pcss +++ b/packages/atomic/src/components/common/atomic-modal/atomic-modal.pcss @@ -75,7 +75,7 @@ atomic-focus-trap { } [part='body-wrapper'] { - @apply px-6 pt-8 pb-5; + @apply px-6 pb-5 pt-8; } [part='footer-wrapper'] { diff --git a/packages/atomic/src/components/common/atomic-modal/atomic-modal.tsx b/packages/atomic/src/components/common/atomic-modal/atomic-modal.tsx index dc3d09937e2..2387dbd9f44 100644 --- a/packages/atomic/src/components/common/atomic-modal/atomic-modal.tsx +++ b/packages/atomic/src/components/common/atomic-modal/atomic-modal.tsx @@ -140,16 +140,14 @@ export class AtomicModal implements InitializableComponent { const Content = () => (
this.animationEnded.emit()} ref={(ref) => (this.animatableContainer = ref)} >
@@ -158,7 +156,7 @@ export class AtomicModal implements InitializableComponent {
{