From 401a306e163adb4c3862ef472b5ca58df5d6ccd5 Mon Sep 17 00:00:00 2001 From: Brad Cornes Date: Tue, 29 Aug 2023 10:42:11 +0100 Subject: [PATCH] Fix recommended variant order linting in Tailwind v2 (#849) --- .../src/diagnostics/getRecommendedVariantOrderDiagnostics.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/packages/tailwindcss-language-service/src/diagnostics/getRecommendedVariantOrderDiagnostics.ts b/packages/tailwindcss-language-service/src/diagnostics/getRecommendedVariantOrderDiagnostics.ts index 82385d9..72a71ef 100644 --- a/packages/tailwindcss-language-service/src/diagnostics/getRecommendedVariantOrderDiagnostics.ts +++ b/packages/tailwindcss-language-service/src/diagnostics/getRecommendedVariantOrderDiagnostics.ts @@ -30,10 +30,9 @@ export async function getRecommendedVariantOrderDiagnostics( return } + let order = state.jitContext.variantOrder ?? state.jitContext.offsets.variantOffsets let { variants, offset } = getVariantsFromClassName(state, className.className) - let sortedVariants = [...variants].sort((a, b) => - jit.bigSign(state.jitContext.variantOrder.get(b) - state.jitContext.variantOrder.get(a)) - ) + let sortedVariants = [...variants].sort((a, b) => jit.bigSign(order.get(b) - order.get(a))) if (!equalExact(variants, sortedVariants)) { diagnostics.push({