1+ import { array , description , optional , pipe , strictObject , string } from "valibot" ;
2+
13import { createGetDissectedClasses , getDissectedClasses } from "better-tailwindcss:tailwindcss/dissect-classes.js" ;
24import { createGetUnknownClasses , getUnknownClasses } from "better-tailwindcss:tailwindcss/unknown-classes.js" ;
35import { buildClass } from "better-tailwindcss:utils/class.js" ;
46import { async } from "better-tailwindcss:utils/context.js" ;
57import { lintClasses } from "better-tailwindcss:utils/lint.js" ;
8+ import { getCachedRegex } from "better-tailwindcss:utils/regex.js" ;
69import { createRule } from "better-tailwindcss:utils/rule.js" ;
710import { replacePlaceholders , splitClasses } from "better-tailwindcss:utils/utils.js" ;
811
@@ -18,6 +21,18 @@ export const enforceLogicalProperties = createRule({
1821 name : "enforce-logical-properties" ,
1922 recommended : false ,
2023
24+ schema : strictObject ( {
25+ ignore : optional (
26+ pipe (
27+ array (
28+ string ( )
29+ ) ,
30+ description ( "A list of regular expression patterns for classes that should be ignored by the rule." )
31+ ) ,
32+ [ ]
33+ )
34+ } ) ,
35+
2136 messages : {
2237 multiple : "Physical class detected. Replace \"{{ className }}\" with logical classes \"{{fix}}\"." ,
2338 single : "Physical class detected. Replace \"{{ className }}\" with logical class \"{{fix}}\"."
@@ -96,6 +111,9 @@ const mappings = [
96111
97112
98113function lintLiterals ( ctx : Context < typeof enforceLogicalProperties > , literals : Literal [ ] ) {
114+ const { ignore } = ctx . options ;
115+ const ignoredClassRegexes = ignore . map ( ignoredClass => getCachedRegex ( ignoredClass ) ) ;
116+
99117 for ( const literal of literals ) {
100118 const classes = splitClasses ( literal . content ) ;
101119
@@ -114,6 +132,10 @@ function lintLiterals(ctx: Context<typeof enforceLogicalProperties>, literals: L
114132 const { unknownClasses } = getUnknownClasses ( async ( ctx ) , possibleFixes ) ;
115133
116134 lintClasses ( ctx , literal , className => {
135+ if ( ignoredClassRegexes . some ( ignoredClassRegex => ignoredClassRegex . test ( className ) ) ) {
136+ return ;
137+ }
138+
117139 const dissectedClass = dissectedClasses [ className ] ;
118140
119141 if ( ! dissectedClass ) {
0 commit comments