@@ -59,7 +59,7 @@ const ruleTester = new RuleTester({
5959
6060ruleTester . run ( RULE_NAME , classnamesOrder , {
6161 valid : [
62- // Angular / Native HTML
62+ // Angular / Native HTML + static text
6363 ...[
6464 `<h1 class="flex">attributeVisitor with TextAttribute (single class gets skipped)</h1>` ,
6565 `<h1 class="unknown relative ">extra spaces</h1>` ,
@@ -72,46 +72,20 @@ ruleTester.run(RULE_NAME, classnamesOrder, {
7272 ...[
7373 `<h1 className="unkown relative">JSX static string</h1>` ,
7474 "<h1 className={`unkown relative`}>JSXAttribute/JSXExpressionContainer/TemplateLiteral</h1>" ,
75- `<h1 className={ctl('unknown relative')}>CallExpression inside a prop</h1>` ,
76- "<h1 className={ctl(`unknown relative ${live && 'unknown bg-black'}`)}>CallExpression inside a prop</h1>" ,
77- "<h1 className={ctl(`unknown relative ${extra}`)}>CallExpression inside a prop</h1>" ,
78- `<h1 class="unknown w-12 lg:w-[500px]">Allowed arbitrary value</h1>` ,
7975 `<h1 class="dark:focus:hover:bg-black md:dark:disabled:focus:hover:bg-gray-400">Stackable variants</h1>` ,
80- `<h1 className={clsx(\`absolute bottom-0 flex h-[270px] w-full flex-col\`)}>clsx</h1>` ,
76+ `<h1 class=" unknown relative ">Extra spaces</h1>` ,
77+ `<h1 className={\`relative w-full overflow-hidden \${yolo ? "flex flex-col" : "block"}\`}>Issue #131</h1>` ,
78+ `<h1 className={clsx(['unknown relative', { ...fn() }])}>Spread of a function return inside clsx</h1>` ,
79+ `<h1 class>No errors while typing</h1>` ,
80+ "clsx(`absolute bottom-0 flex h-[270px] w-full flex-col`)" ,
81+ "ctl('unknown relative')" ,
82+ "ctl(`unknown relative ${live && 'unknown bg-black'}`)" ,
83+ "ctl(`unknown relative ${extra}`)" ,
8184 `
8285 import tw from 'twin.macro';
8386 const Input = tw.input\`unknown relative\`;
8487 const PurpleInput = tw(Input)\`unknown relative\`;
8588 ` ,
86- `<div class=" unknown relative ">Extra spaces</div>` ,
87- `
88- <div class="custom custom2 group peer prose prose-slate aspect-h-9 aspect-w-16 bg-opacity-50 ring-opacity-50 pointer-events-auto visible sr-only sticky inset-0 inset-x-2 inset-y-1 top-3 right-4 bottom-5 left-6 isolate z-auto order-1 col-span-1 col-start-2 col-end-3 row-span-1 row-start-2 row-end-3 float-left clear-both container m-0 mx-1.5 my-px mt-1 mr-2 mb-3 ml-4 box-border line-clamp-2 block aspect-auto h-0 max-h-fit min-h-full w-0 max-w-fit min-w-full flex-none shrink grow basis-0 table-fixed border-collapse origin-bottom-right translate-x-px translate-y-2 scale-0 scale-x-75 scale-y-50 rotate-90 skew-x-2 skew-y-0 transform animate-spin cursor-text touch-auto resize-none snap-x snap-mandatory snap-center snap-always scroll-m-0 scroll-mx-1.5 scroll-my-px scroll-mt-1 scroll-mr-2 scroll-mb-3 scroll-ml-4 scroll-p-0 scroll-px-1.5 scroll-py-px scroll-pt-1 scroll-pr-2 scroll-pb-3 scroll-pl-4 list-outside list-decimal appearance-none columns-1 break-before-avoid-page break-inside-avoid-column break-after-auto auto-cols-min grid-flow-col auto-rows-min grid-cols-1 grid-rows-1 flex-col flex-wrap place-content-between place-items-stretch content-between items-baseline justify-start justify-items-center gap-0 space-y-0 space-y-reverse gap-x-1 space-x-1 space-x-reverse gap-y-2 divide-x-2 divide-y-4 divide-y-reverse divide-dashed divide-black place-self-end self-baseline justify-self-stretch overflow-hidden overflow-x-auto overflow-y-scroll overscroll-auto overscroll-x-contain overscroll-y-none scroll-smooth rounded rounded-t-xl rounded-l-none rounded-tl-xl rounded-r-2xl rounded-tr-2xl rounded-b-sm rounded-br-sm rounded-bl-none border-0 border-x-2 border-y-2 border-t-4 border-r-4 border-b border-l border-solid border-black border-x-slate-50 border-y-transparent border-t-white border-r-transparent border-b-inherit border-l-current bg-current bg-none from-current via-black to-orange-500 decoration-clone bg-auto bg-fixed bg-clip-padding bg-bottom bg-no-repeat bg-origin-border fill-white stroke-white stroke-2 object-contain object-bottom p-0 px-1.5 py-px pt-1 pr-2 pb-3 pl-4 text-left indent-px align-top font-sans text-lg leading-4 font-semibold tracking-normal break-words text-ellipsis whitespace-nowrap text-current uppercase italic ordinal underline decoration-black decoration-double decoration-from-font underline-offset-auto subpixel-antialiased caret-black accent-black opacity-50 bg-blend-lighten mix-blend-darken shadow-lg ring-1 shadow-white ring-white ring-offset-2 ring-offset-current outline-0 outline-offset-1 outline-current blur brightness-50 contrast-100 drop-shadow-xl grayscale hue-rotate-90 invert saturate-100 sepia filter backdrop-blur-lg backdrop-brightness-110 backdrop-contrast-125 backdrop-grayscale backdrop-hue-rotate-90 backdrop-invert backdrop-opacity-30 backdrop-saturate-100 backdrop-sepia transition-all delay-150 duration-1000 ease-linear will-change-scroll content-none outline-dotted select-none [--scroll-offset:56px] divide-x-reverse ring-inset sm:transform-gpu sm:box-decoration-clone sm:overflow-ellipsis md:transform-none">Kitchensink</div>
89- ` ,
90- `
91- <div className={\`relative w-full overflow-hidden \${yolo ? "flex flex-col" : "block"}\`}>Issue #131</div>
92- ` ,
93- `
94- <div>
95- <h1>Issue #142</h1>
96- <div class="unselectable absolute box-content cursor-pointer rounded-full p-1.5 text-center transition-colors duration-300 select-none sm:transition-transform">1</div>
97- <div class="dark:after:border-t-blue-dark/40 dark:after:border-l-blue-dark/40 before:border-l-blue-mid before:border-t-blue-mid after:border-t-blue-subtle after:border-l-blue-subtle border-transparent before:border-transparent dark:before:border-transparent">2</div>
98- <div class="text-neutral-750 theme-contrast:text-black absolute -top-4 -right-1 cursor-pointer rounded-tr-sm rounded-bl-sm px-2.5 py-2 text-sm opacity-0 transition-opacity group-hover:opacity-50 group-hover:hover:opacity-100">3</div>
99- <div class="text-yellow-darker/50 dark:text-yellow-strong/70 hover:text-yellow-darker dark:hover:text-yellow-strong relative flex cursor-pointer items-center justify-center pt-2 pb-2 transition-colors">4</div>
100- <div class="text-yellow-darker/50 dark:text-yellow-strong/70 hover:text-yellow-darker dark:hover:text-yellow-strong relative flex cursor-pointer items-center justify-center pt-2 pb-2 transition-colors">5</div>
101- <div class="group relative -mx-1.5 my-0 block rounded px-1.5 pt-3.5 pb-4 transition-colors duration-150 hover:text-black active:top-0 dark:hover:text-white">6</div>
102- <div class="bg-neutral-70 theme-contrast:bg-white dark:bg-gray-780 pointer-events-none fixed top-0 left-0 h-screen w-screen opacity-70">7</div>
103- <div class="dark:before:border-t-blue-dark/40 dark:before:border-l-blue-dark/40 dark:after:border-t-blue-dark/40 dark:after:border-l-blue-dark/40 before:border-t-blue-subtle before:border-l-blue-subtle after:border-t-blue-subtle after:border-l-blue-subtle border-transparent">8</div>
104- <div class="dark:bg-blue-dark/40 bg-blue-subtle dark:text-blue-strong border-none text-black">9</div>
105- <div class="m-3 inline-block h-4 w-4 rounded-full transition-transform">10</div>
106- </div>
107- ` ,
108- `<div class>No errors while typing</div>` ,
109- `
110- const func = () => ({ a: 12 });
111- <div className={clsx(['unknown relative', {
112- ...func()
113- }])}>Spread of a function return inside clsx</div>
114- ` ,
11589 `
11690 ctl(\`
11791 unknown
@@ -126,22 +100,17 @@ ruleTester.run(RULE_NAME, classnamesOrder, {
126100 const tw = (classes) => classes;
127101 const taggedTemplateExpression = tw\`unkown relative\`;
128102 ` ,
129- `
130- ctl(\`
131- container
132- flex
133- w-12
134- sm:w-6
135- lg:w-4
136- \`)` ,
137103 ] . map ( ( testedJsxCode ) => ( {
138104 code : testedJsxCode ,
139105 } ) ) ,
140106 // Vue SFC
141107 ...[
142- `<template><div class="unkown relative">vAttributeVisitor static</div></template>` ,
143- `<template><div v-bind:class="'unkown relative'">vAttributeVisitor(VAttribute)</div></template>` ,
144- `<template><div :class="'unknown relative'">vAttributeVisitor with text</div></template>` ,
108+ `<template><h1 class="unkown relative">vAttributeVisitor static</h1></template>` ,
109+ `<template><h1 v-bind:class="'unkown relative'">vAttributeVisitor binding a string</h1></template>` ,
110+ `<template><h1 :class="'unknown relative'">vAttributeVisitor binding short</h1></template>` ,
111+ `<template><h1 :class="{ 'unknown relative': isActive, 'bg-black': hasError }">vAttributeVisitor Object</h1></template>` ,
112+ `<template><h1 :class="['unkown relative', 'bg-black']">vAttributeVisitor Array</h1></template>` ,
113+ `<template><h1 :class="[isActive ? 'unknown relative' : '', 'bg-black']">Array with ternary</h1></template>` ,
145114 `
146115 <script>const ctl = (str) => str</script>
147116 <template><p :class="ctl('unknown relative')">{{ greeting }}</p></template>
@@ -161,13 +130,10 @@ ruleTester.run(RULE_NAME, classnamesOrder, {
161130 code : testedVueCode ,
162131 languageOptions : withVueParser ,
163132 } ) ) ,
164- // Vue SFC + No attribute
133+ // Vue SFC + Disabled attribute
165134 ...[
166135 `<template><div class="flex unkown relative">No attribute (skipped)</div></template>` ,
167- `
168- <script>const tw = (str) => str + str;</script>
169- <template><div :class="tw('unknown relative')">vAttributeVisitor with CallExpression</div></template>
170- ` ,
136+ `<template><div :class="tw('unknown relative')">No attribute but via CallExpression</div></template>` ,
171137 ] . map ( ( testedVueCode ) => ( {
172138 code : testedVueCode ,
173139 settings : { tailwindcss : { ...generalSettings , attributes : [ ] } } ,
@@ -177,7 +143,7 @@ ruleTester.run(RULE_NAME, classnamesOrder, {
177143 code : `<div className={'unknown tw:relative'}>Valid with custom prefix</div>` ,
178144 settings : { tailwindcss : { ...prefixedSettings } } ,
179145 } ,
180- // JSX + Custom functions
146+ // JSX + Custom functions/tag
181147 ...[
182148 `<div className={ctl('flex unknown relative')}>Ignored CallExpression inside a prop</div>` ,
183149 `<div title={myTag('unknown relative')}>Ignored CallExpression inside a prop</div>` ,
@@ -332,32 +298,59 @@ ruleTester.run(RULE_NAME, classnamesOrder, {
332298 } ,
333299 {
334300 /* prettier-ignore */
335- code : `<div className={'tw:flex unknown tw:relative'}>Error with custom prefix</div >` ,
336- output : `<div className={'unknown tw:relative tw:flex'}>Error with custom prefix</div >` ,
301+ code : `<h1 className={'tw:flex unknown tw:relative'}>Error with custom prefix</h1 >` ,
302+ output : `<h1 className={'unknown tw:relative tw:flex'}>Error with custom prefix</h1 >` ,
337303 settings : { tailwindcss : { ...prefixedSettings } } ,
338304 errors : errors ,
339305 } ,
340- {
341- /* prettier-ignore */
342- code : `<template><div class="relative unkown">??</div></template>` ,
343- output : `<template><div class="unkown relative">??</div></template>` ,
344- errors : errors ,
345- languageOptions : withVueParser ,
346- } ,
347- {
348- /* prettier-ignore */
349- code : `<template><div :class="['relative unknown']">??</div></template>` ,
350- output : `<template><div :class="['unknown relative']">??</div></template>` ,
351- errors : errors ,
306+ // Vue SFC + Disabled attribute
307+ ...[
308+ [
309+ `<template><h1 class="relative unkown">??</h1></template>` ,
310+ `<template><h1 class="unkown relative">??</h1></template>` ,
311+ ] ,
312+ [
313+ `<template><h1 :class="['relative unknown']">??</h1></template>` ,
314+ `<template><h1 :class="['unknown relative']">??</h1></template>` ,
315+ ] ,
316+ [
317+ `<template><h1 class="grid grid-cols-1 sm:grid-cols-2 sm:px-8 sm:py-12 sm:gap-x-8 md:py-16">:)</h1></template>` ,
318+ `<template><h1 class="grid grid-cols-1 sm:grid-cols-2 sm:gap-x-8 sm:px-8 sm:py-12 md:py-16">:)</h1></template>` ,
319+ ] ,
320+ [
321+ `<template><div :class="ctl(\`p-10 w-full \${some}\`)" /></template>` ,
322+ `<template><div :class="ctl(\`w-full p-10 \${some}\`)" /></template>` ,
323+ ] ,
324+ [
325+ `
326+ <template>
327+ <div v-bind="data" :class="[
328+ 'py-1.5 font-semibold transition',
329+ {
330+ 'text-white': variant === 'white',
331+ 'text-blue-500 hover:text-blue-400 border-blue-500': variant === 'primary',
332+ 'underline decoration-2 underline-offset-[10px]': active
333+ }
334+ ]" />
335+ </template>` ,
336+ `
337+ <template>
338+ <div v-bind="data" :class="[
339+ 'py-1.5 font-semibold transition',
340+ {
341+ 'text-white': variant === 'white',
342+ 'border-blue-500 text-blue-500 hover:text-blue-400': variant === 'primary',
343+ 'underline decoration-2 underline-offset-[10px]': active
344+ }
345+ ]" />
346+ </template>` ,
347+ ] ,
348+ ] . map ( ( [ input , result ] ) => ( {
349+ code : input ,
350+ output : result ,
352351 languageOptions : withVueParser ,
353- } ,
354- {
355- /* prettier-ignore */
356- code : `<template><div class="grid grid-cols-1 sm:grid-cols-2 sm:px-8 sm:py-12 sm:gap-x-8 md:py-16">:)</div></template>` ,
357- output : `<template><div class="grid grid-cols-1 sm:grid-cols-2 sm:gap-x-8 sm:px-8 sm:py-12 md:py-16">:)</div></template>` ,
358352 errors : errors ,
359- languageOptions : withVueParser ,
360- } ,
353+ } ) ) ,
361354 {
362355 /* prettier-ignore */
363356 code : `<div class="md:prose-2xl prose-xl prose sm:prose-sm"></div>` ,
@@ -509,38 +502,5 @@ ruleTester.run(RULE_NAME, classnamesOrder, {
509502 ])` ,
510503 errors : [ error , error ] ,
511504 } ,
512- {
513- /* prettier-ignore */
514- code : `<template><div :class="ctl(\`p-10 w-full \${some}\`)" /></template>` ,
515- output : `<template><div :class="ctl(\`w-full p-10 \${some}\`)" /></template>` ,
516- errors : errors ,
517- languageOptions : withVueParser ,
518- } ,
519- {
520- code : `
521- <template>
522- <div v-bind="data" :class="[
523- 'py-1.5 font-semibold transition',
524- {
525- 'text-white': variant === 'white',
526- 'text-blue-500 hover:text-blue-400 border-blue-500': variant === 'primary',
527- 'underline decoration-2 underline-offset-[10px]': active
528- }
529- ]" />
530- </template>` ,
531- output : `
532- <template>
533- <div v-bind="data" :class="[
534- 'py-1.5 font-semibold transition',
535- {
536- 'text-white': variant === 'white',
537- 'border-blue-500 text-blue-500 hover:text-blue-400': variant === 'primary',
538- 'underline decoration-2 underline-offset-[10px]': active
539- }
540- ]" />
541- </template>` ,
542- errors : errors ,
543- languageOptions : withVueParser ,
544- } ,
545505 ] ,
546506} ) ;
0 commit comments