oxlint-tailwindcss 0.1.4 → 0.1.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -491,6 +491,21 @@ function getArbitraryValue(cls) {
491
491
  }
492
492
  //#endregion
493
493
  //#region src/design-system/cache.ts
494
+ /** Strip `!` modifier from start or end: `!flex` → `flex`, `flex!` → `flex` */
495
+ function stripImportant(cls) {
496
+ if (cls.startsWith("!")) return {
497
+ bare: cls.slice(1),
498
+ important: true
499
+ };
500
+ if (cls.endsWith("!")) return {
501
+ bare: cls.slice(0, -1),
502
+ important: true
503
+ };
504
+ return {
505
+ bare: cls,
506
+ important: false
507
+ };
508
+ }
494
509
  var DesignSystemCache = class DesignSystemCache {
495
510
  canonicalMap = /* @__PURE__ */ new Map();
496
511
  validitySet = /* @__PURE__ */ new Set();
@@ -499,12 +514,18 @@ var DesignSystemCache = class DesignSystemCache {
499
514
  variantOrderMap = /* @__PURE__ */ new Map();
500
515
  arbitraryEquivMap = /* @__PURE__ */ new Map();
501
516
  _validClasses = [];
517
+ _knownPrefixes = null;
518
+ _maxOrder = 0n;
502
519
  static fromPrecomputed(data) {
503
520
  const cache = new DesignSystemCache();
504
521
  cache._validClasses = data.validClasses;
505
522
  for (const cls of data.validClasses) cache.validitySet.add(cls);
506
523
  for (const [from, to] of Object.entries(data.canonical)) cache.canonicalMap.set(from, roundRemValue(to));
507
- for (const [cls, val] of Object.entries(data.order)) cache.orderMap.set(cls, BigInt(val));
524
+ for (const [cls, val] of Object.entries(data.order)) {
525
+ const order = BigInt(val);
526
+ cache.orderMap.set(cls, order);
527
+ if (order > cache._maxOrder) cache._maxOrder = order;
528
+ }
508
529
  for (const [cls, props] of Object.entries(data.cssProps)) cache.cssPropsMap.set(cls, props);
509
530
  if (data.variantOrder) for (const [name, index] of Object.entries(data.variantOrder)) cache.variantOrderMap.set(name, index);
510
531
  if (data.componentClasses) for (const cls of data.componentClasses) cache.validitySet.add(cls);
@@ -522,30 +543,133 @@ var DesignSystemCache = class DesignSystemCache {
522
543
  const canonicalUtility = this.canonicalMap.get(utility);
523
544
  if (canonicalUtility !== void 0) return className.slice(0, className.length - utility.length) + canonicalUtility;
524
545
  }
546
+ const { bare, important } = stripImportant(utility);
547
+ if (important) {
548
+ const canonicalBare = this.canonicalMap.get(bare);
549
+ if (canonicalBare !== void 0) return className.slice(0, className.length - utility.length) + "!" + canonicalBare;
550
+ }
525
551
  return className;
526
552
  }
553
+ /**
554
+ * Resolve a variant name to its priority in the CSS output order.
555
+ * Named variants use the precomputed map. Arbitrary variants use pattern-based heuristics
556
+ * to approximate their position relative to named variants.
557
+ */
558
+ resolveVariantPriority(variant) {
559
+ const direct = this.variantOrderMap.get(variant);
560
+ if (direct !== void 0) return direct;
561
+ if (variant.includes("/")) {
562
+ const stripped = variant.slice(0, variant.indexOf("/"));
563
+ const p = this.variantOrderMap.get(stripped);
564
+ if (p !== void 0) return p;
565
+ }
566
+ if (variant.startsWith("group-") || variant.startsWith("peer-")) {
567
+ const prefix = variant.startsWith("group-") ? "group-" : "peer-";
568
+ const inner = variant.slice(prefix.length);
569
+ const innerClean = inner.includes("/") ? inner.slice(0, inner.indexOf("/")) : inner;
570
+ return this.resolveVariantPriority(innerClean);
571
+ }
572
+ if (variant.startsWith("data-")) return this.variantOrderMap.get("data-open") ?? 121;
573
+ if (variant.startsWith("[")) return (this.variantOrderMap.get("data-ending-style") ?? 124) + 10;
574
+ if (variant.startsWith("has-") || variant.startsWith("not-") || variant.startsWith("in-")) return (this.variantOrderMap.get("inert") ?? 48) + 1;
575
+ if (variant.startsWith("aria-")) return (this.variantOrderMap.get("inert") ?? 48) + 2;
576
+ return 0;
577
+ }
578
+ /** Find the order of the first class matching a prefix (e.g. "max-w-" → order of "max-w-0") */
579
+ findOrderByPrefix(prefix) {
580
+ const withoutDash = prefix.endsWith("-") ? prefix.slice(0, -1) : null;
581
+ if (withoutDash) {
582
+ const order = this.orderMap.get(withoutDash);
583
+ if (order != null) return order;
584
+ }
585
+ for (const [cls, order] of this.orderMap) if (cls.startsWith(prefix) && order != null) return order;
586
+ }
587
+ getKnownPrefixes() {
588
+ if (!this._knownPrefixes) {
589
+ this._knownPrefixes = /* @__PURE__ */ new Set();
590
+ for (const cls of this._validClasses) {
591
+ const dash = cls.lastIndexOf("-");
592
+ if (dash > 0) this._knownPrefixes.add(cls.slice(0, dash));
593
+ }
594
+ }
595
+ return this._knownPrefixes;
596
+ }
527
597
  isValid(className) {
528
598
  if (this.validitySet.has(className)) return true;
529
599
  const utility = extractUtility(className);
530
600
  if (utility !== className && this.validitySet.has(utility)) return true;
601
+ const { bare } = stripImportant(utility);
602
+ if (bare !== utility && this.validitySet.has(bare)) return true;
603
+ const slashIdx = bare.lastIndexOf("/");
604
+ if (slashIdx > 0) {
605
+ const base = bare.slice(0, slashIdx);
606
+ if (this.validitySet.has(base)) return true;
607
+ if (/^(.+)-(\d+\.?\d*)$/.test(base)) {
608
+ const dashIdx = base.lastIndexOf("-");
609
+ if (dashIdx > 0 && this.getKnownPrefixes().has(base.slice(0, dashIdx))) return true;
610
+ }
611
+ }
612
+ const numericMatch = /^(.+)-(\d+\.?\d*)$/.exec(bare);
613
+ if (numericMatch && this.getKnownPrefixes().has(numericMatch[1])) return true;
531
614
  if (hasArbitraryValue(className)) return true;
615
+ if (bare.includes("(") && bare.includes(")")) return true;
532
616
  return false;
533
617
  }
534
618
  getOrder(className) {
535
619
  const cached = this.orderMap.get(className);
536
620
  if (cached !== void 0) return cached;
537
621
  const utility = extractUtility(className);
538
- if (utility !== className) {
539
- const baseOrder = this.orderMap.get(utility);
540
- if (baseOrder !== void 0) return baseOrder;
622
+ const hasVariant = utility !== className;
623
+ let baseOrder = this.orderMap.get(utility) ?? void 0;
624
+ if (baseOrder === void 0) {
625
+ const { bare, important } = stripImportant(utility);
626
+ if (important) baseOrder = this.orderMap.get(bare) ?? void 0;
541
627
  }
542
- return null;
628
+ if (baseOrder === void 0) {
629
+ const slashIdx = utility.lastIndexOf("/");
630
+ if (slashIdx > 0) {
631
+ const base = utility.slice(0, slashIdx);
632
+ baseOrder = this.orderMap.get(base) ?? void 0;
633
+ if (baseOrder === void 0) {
634
+ const { bare, important } = stripImportant(base);
635
+ if (important) baseOrder = this.orderMap.get(bare) ?? void 0;
636
+ }
637
+ }
638
+ }
639
+ if (baseOrder === void 0) {
640
+ const stripped = stripImportant(utility).bare;
641
+ const bracketIdx = stripped.indexOf("[");
642
+ if (bracketIdx > 0) {
643
+ const prefix = stripped.slice(0, bracketIdx);
644
+ baseOrder = this.findOrderByPrefix(prefix);
645
+ }
646
+ }
647
+ if (baseOrder === void 0) {
648
+ const stripped = stripImportant(utility).bare;
649
+ const parenIdx = stripped.indexOf("(");
650
+ if (parenIdx > 0) {
651
+ const prefix = stripped.slice(0, parenIdx);
652
+ baseOrder = this.findOrderByPrefix(prefix);
653
+ }
654
+ }
655
+ if (baseOrder === void 0) return null;
656
+ if (!hasVariant) return baseOrder;
657
+ const variants = extractVariants(className);
658
+ const firstPriority = this.resolveVariantPriority(variants[0]) + 1;
659
+ let subPriority = 0;
660
+ for (let i = 1; i < variants.length; i++) subPriority += this.resolveVariantPriority(variants[i]) + 1;
661
+ const bucketSize = this._maxOrder + 1n;
662
+ return BigInt(firstPriority) * 1000n * bucketSize + BigInt(subPriority) * bucketSize + baseOrder;
543
663
  }
544
664
  getClassOrder(classes) {
545
665
  return classes.map((cls) => [cls, this.getOrder(cls)]);
546
666
  }
547
667
  getCssProperties(className) {
548
- return this.cssPropsMap.get(className) ?? [];
668
+ const result = this.cssPropsMap.get(className);
669
+ if (result) return result;
670
+ const { bare, important } = stripImportant(className);
671
+ if (important) return this.cssPropsMap.get(bare) ?? [];
672
+ return [];
549
673
  }
550
674
  getVariantPriority(variant) {
551
675
  return this.variantOrderMap.get(variant) ?? null;
@@ -554,7 +678,11 @@ var DesignSystemCache = class DesignSystemCache {
554
678
  return this.variantOrderMap.size > 0;
555
679
  }
556
680
  getNamedEquivalent(className) {
557
- return this.arbitraryEquivMap.get(className) ?? null;
681
+ const result = this.arbitraryEquivMap.get(className);
682
+ if (result) return result;
683
+ const { bare, important } = stripImportant(className);
684
+ if (important) return this.arbitraryEquivMap.get(bare) ?? null;
685
+ return null;
558
686
  }
559
687
  };
560
688
  //#endregion
@@ -573,18 +701,58 @@ const { __unstable__loadDesignSystem } = require('@tailwindcss/node');
573
701
  const { readFileSync } = require('fs');
574
702
  const { dirname, resolve } = require('path');
575
703
 
704
+ function resolveImport(specifier, baseDir) {
705
+ // Relative import: ./file.css, ../file.css
706
+ if (specifier.startsWith('.')) return resolve(baseDir, specifier);
707
+ // Package import: tw-animate-css, @scope/pkg
708
+ const { join } = require('path');
709
+ const { existsSync } = require('fs');
710
+ // Walk up to find node_modules (monorepo support)
711
+ let dir = baseDir;
712
+ while (true) {
713
+ const pkgDir = join(dir, 'node_modules', specifier);
714
+ if (existsSync(pkgDir)) {
715
+ // Read package.json to find CSS entry (main, style, exports.style)
716
+ try {
717
+ const pkg = JSON.parse(readFileSync(join(pkgDir, 'package.json'), 'utf-8'));
718
+ const entry = pkg.style || pkg.main || '';
719
+ if (entry.endsWith('.css')) return resolve(pkgDir, entry);
720
+ // Check exports["."].style
721
+ const exp = pkg.exports && pkg.exports['.'];
722
+ const styleEntry = typeof exp === 'object' && exp !== null ? exp.style : null;
723
+ if (styleEntry) return resolve(pkgDir, styleEntry);
724
+ } catch {}
725
+ // Fallback: try common CSS filenames
726
+ const fallbacks = ['index.css', 'dist/index.css', 'style.css', 'styles.css'];
727
+ for (const f of fallbacks) {
728
+ const p = join(pkgDir, f);
729
+ if (existsSync(p)) return p;
730
+ }
731
+ return null;
732
+ }
733
+ const parent = dirname(dir);
734
+ if (parent === dir) break;
735
+ dir = parent;
736
+ }
737
+ return null;
738
+ }
739
+
576
740
  function extractComponentClasses(cssPath, baseDir) {
577
741
  let css;
578
742
  try { css = readFileSync(cssPath, 'utf-8'); } catch { return []; }
579
743
  const files = [css];
580
- const importRe = /@import\\s+['"](\\.[\\/][^'"]+)['"]/g;
744
+ const importRe = /@import\\s+['"]([^'"]+)['"]/g;
581
745
  let m;
582
746
  while ((m = importRe.exec(css)) !== null) {
583
- try { files.push(readFileSync(resolve(baseDir, m[1]), 'utf-8')); } catch {}
747
+ const resolved = resolveImport(m[1], baseDir);
748
+ if (resolved) {
749
+ try { files.push(readFileSync(resolved, 'utf-8')); } catch {}
750
+ }
584
751
  }
585
752
  const result = [];
586
753
  for (const content of files) {
587
- const layerRe = /@layer\\s+components\\s*\\{/g;
754
+ // Scan both @layer components AND @layer utilities
755
+ const layerRe = /@layer\\s+(?:components|utilities)\\s*\\{/g;
588
756
  let lm;
589
757
  while ((lm = layerRe.exec(content)) !== null) {
590
758
  let depth = 1, i = lm.index + lm[0].length;
@@ -598,6 +766,10 @@ function extractComponentClasses(cssPath, baseDir) {
598
766
  let sm;
599
767
  while ((sm = selRe.exec(block)) !== null) result.push(sm[1]);
600
768
  }
769
+ // Scan all class selectors anywhere in the file (.class-name)
770
+ const classSelRe = /\\.([a-zA-Z_][\\w-]*)/g;
771
+ let cs;
772
+ while ((cs = classSelRe.exec(content)) !== null) result.push(cs[1]);
601
773
  }
602
774
  return [...new Set(result)];
603
775
  }
@@ -615,6 +787,50 @@ async function main() {
615
787
  const cssResults = ds.candidatesToCss(classNames);
616
788
  const validClasses = classNames.filter((_, i) => cssResults[i] != null);
617
789
 
790
+ // Expand: validate extra candidates not in getClassList() but valid in v4
791
+ const validSet = new Set(validClasses);
792
+ const knownPrefixes = new Set();
793
+ for (const cls of validClasses) {
794
+ const dash = cls.lastIndexOf('-');
795
+ if (dash > 0) knownPrefixes.add(cls.slice(0, dash));
796
+ }
797
+ const extraCandidates = [];
798
+ const breakpoints = ['sm', 'md', 'lg', 'xl', '2xl'];
799
+ for (const prefix of knownPrefixes) {
800
+ // Bare utilities: rounded, shadow, blur, etc.
801
+ if (!validSet.has(prefix)) extraCandidates.push(prefix);
802
+ // Screen breakpoint variants: max-w-screen-lg, etc.
803
+ for (const bp of breakpoints) {
804
+ const candidate = prefix + '-screen-' + bp;
805
+ if (!validSet.has(candidate)) extraCandidates.push(candidate);
806
+ }
807
+ }
808
+ if (extraCandidates.length > 0) {
809
+ const extraResults = ds.candidatesToCss(extraCandidates);
810
+ for (let i = 0; i < extraCandidates.length; i++) {
811
+ if (extraResults[i] != null) {
812
+ validClasses.push(extraCandidates[i]);
813
+ validSet.add(extraCandidates[i]);
814
+ }
815
+ }
816
+ }
817
+
818
+ // Marker classes: group/peer don't produce CSS but enable group-hover:/peer-checked: variants
819
+ const allVariants = ds.getVariants();
820
+ for (const v of allVariants) {
821
+ if (v.name === 'group' || v.name.startsWith('group-')) {
822
+ validClasses.push('group'); validSet.add('group'); break;
823
+ }
824
+ }
825
+ for (const v of allVariants) {
826
+ if (v.name === 'peer' || v.name.startsWith('peer-')) {
827
+ validClasses.push('peer'); validSet.add('peer'); break;
828
+ }
829
+ }
830
+
831
+ // Named groups/peers: group/name, peer/name — the /name part is user-defined
832
+ // These are validated by the variant system, not by candidatesToCss
833
+
618
834
  // Canonical forms (only store diffs)
619
835
  // NOTE: canonicalizeCandidates deduplicates, so we must call it one class at a time
620
836
  const canonical = {};
@@ -625,15 +841,20 @@ async function main() {
625
841
  }
626
842
  }
627
843
 
628
- // Sort order
844
+ // Sort order — include extra candidates so bare utilities (rounded, blur, etc.) get order
845
+ const allForOrder = [...classNames];
846
+ for (const cls of validClasses) {
847
+ if (!classNames.includes(cls)) allForOrder.push(cls);
848
+ }
629
849
  const order = {};
630
- const orderResults = ds.getClassOrder(classNames);
850
+ const orderResults = ds.getClassOrder(allForOrder);
631
851
  for (const [name, val] of orderResults) {
632
852
  if (val !== null) order[name] = val.toString();
633
853
  }
634
854
 
635
- // CSS properties per class
855
+ // CSS properties per class — extract only from the class rule block, skip @property descriptors
636
856
  const cssProps = {};
857
+ const atPropertyDescriptors = new Set(['syntax', 'inherits', 'initial-value']);
637
858
  const propRegex = /^\\s+([\\w-]+)\\s*:/gm;
638
859
  for (let i = 0; i < classNames.length; i++) {
639
860
  if (cssResults[i]) {
@@ -641,7 +862,7 @@ async function main() {
641
862
  let match;
642
863
  propRegex.lastIndex = 0;
643
864
  while ((match = propRegex.exec(cssResults[i])) !== null) {
644
- props.push(match[1]);
865
+ if (!atPropertyDescriptors.has(match[1])) props.push(match[1]);
645
866
  }
646
867
  if (props.length > 0) cssProps[classNames[i]] = props;
647
868
  }
@@ -697,8 +918,9 @@ async function main() {
697
918
  main().catch(e => { process.stderr.write(e.message); process.exit(1); });
698
919
  `;
699
920
  const CACHE_DIR = (0, node_path.join)((0, node_os.tmpdir)(), "oxlint-tailwindcss");
921
+ const CACHE_VERSION = 8;
700
922
  function getCachePath(cssPath, mtime) {
701
- return (0, node_path.join)(CACHE_DIR, `${(0, node_crypto.createHash)("md5").update(`${cssPath}:${mtime}`).digest("hex")}.json`);
923
+ return (0, node_path.join)(CACHE_DIR, `${(0, node_crypto.createHash)("md5").update(`v${CACHE_VERSION}:${cssPath}:${mtime}`).digest("hex")}.json`);
702
924
  }
703
925
  function loadDesignSystemSync(cssPath) {
704
926
  const resolvedPath = (0, node_path.resolve)(cssPath);
@@ -815,8 +1037,8 @@ function entryPointFromSettings(settings) {
815
1037
  *
816
1038
  * Resolution order: rule option `entryPoint` > `settings.tailwindcss.entryPoint` > auto-detect.
817
1039
  */
818
- function getLoadedDesignSystem(entryPoint, settings) {
819
- const cssPath = entryPoint ?? entryPointFromSettings(settings) ?? singleton?.path ?? autoDetectEntryPoint();
1040
+ function getLoadedDesignSystem(entryPoint, settings, filePath) {
1041
+ const cssPath = entryPoint ?? entryPointFromSettings(settings) ?? singleton?.path ?? autoDetectEntryPoint(filePath);
820
1042
  if (!cssPath) return null;
821
1043
  const resolvedPath = (0, node_path.resolve)(cssPath);
822
1044
  try {
@@ -841,6 +1063,36 @@ function getLoadedDesignSystem(entryPoint, settings) {
841
1063
  return null;
842
1064
  }
843
1065
  }
1066
+ /**
1067
+ * Creates a lazy DS loader that retries with more context as it becomes available.
1068
+ *
1069
+ * In `createOnce`, `context.settings` and `context.filename` throw. When visitors
1070
+ * run, they become available. This function retries until it has the file path
1071
+ * (meaning we're in a visitor with full context), then gives up.
1072
+ */
1073
+ function createLazyLoader(context) {
1074
+ let result = null;
1075
+ let lastFilePath;
1076
+ return () => {
1077
+ if (result) return result;
1078
+ let entryPoint;
1079
+ try {
1080
+ entryPoint = (context.options?.[0])?.entryPoint;
1081
+ } catch {}
1082
+ let settings;
1083
+ try {
1084
+ settings = context.settings;
1085
+ } catch {}
1086
+ let filePath;
1087
+ try {
1088
+ filePath = context.filename;
1089
+ } catch {}
1090
+ if (filePath && filePath === lastFilePath) return null;
1091
+ if (filePath) lastFilePath = filePath;
1092
+ result = getLoadedDesignSystem(entryPoint, settings, filePath);
1093
+ return result;
1094
+ };
1095
+ }
844
1096
  //#endregion
845
1097
  //#region src/types.ts
846
1098
  /**
@@ -859,19 +1111,104 @@ function safeOptions(context) {
859
1111
  return;
860
1112
  }
861
1113
  }
862
- /**
863
- * Safely read context.settings.
864
- *
865
- * Like `safeOptions`, `context.settings` may not be accessible in `createOnce()`.
866
- * The try/catch handles that gracefully.
867
- */
868
- function safeSettings(context) {
869
- try {
870
- return context.settings ?? void 0;
871
- } catch {
872
- return;
1114
+ //#endregion
1115
+ //#region src/rules/no-deprecated-classes.ts
1116
+ const DEPRECATED_MAP = {
1117
+ "flex-grow": "grow",
1118
+ "flex-grow-0": "grow-0",
1119
+ "flex-shrink": "shrink",
1120
+ "flex-shrink-0": "shrink-0",
1121
+ "overflow-ellipsis": "text-ellipsis",
1122
+ "decoration-slice": "box-decoration-slice",
1123
+ "decoration-clone": "box-decoration-clone",
1124
+ "bg-gradient-to-t": "bg-linear-to-t",
1125
+ "bg-gradient-to-tr": "bg-linear-to-tr",
1126
+ "bg-gradient-to-r": "bg-linear-to-r",
1127
+ "bg-gradient-to-br": "bg-linear-to-br",
1128
+ "bg-gradient-to-b": "bg-linear-to-b",
1129
+ "bg-gradient-to-bl": "bg-linear-to-bl",
1130
+ "bg-gradient-to-l": "bg-linear-to-l",
1131
+ "bg-gradient-to-tl": "bg-linear-to-tl"
1132
+ };
1133
+ const noDeprecatedClasses = (0, _oxlint_plugins.defineRule)({
1134
+ meta: {
1135
+ type: "problem",
1136
+ docs: { description: "Disallow deprecated Tailwind CSS v4 classes" },
1137
+ fixable: "code",
1138
+ schema: [{
1139
+ type: "object",
1140
+ properties: { entryPoint: { type: "string" } },
1141
+ additionalProperties: false
1142
+ }],
1143
+ messages: { deprecated: "\"{{className}}\" is deprecated in Tailwind v4. Use \"{{replacement}}\" instead." }
1144
+ },
1145
+ createOnce(context) {
1146
+ const getDS = createLazyLoader(context);
1147
+ function check(locations) {
1148
+ const dsResult = getDS();
1149
+ for (const loc of locations) {
1150
+ const classes = splitClasses(loc.value);
1151
+ const offending = [];
1152
+ for (const cls of classes) {
1153
+ const { utility, variant } = splitUtilityAndVariant(cls);
1154
+ const hasImportantPrefix = utility.startsWith("!");
1155
+ const hasImportantSuffix = !hasImportantPrefix && utility.endsWith("!");
1156
+ const bareUtility = hasImportantPrefix ? utility.slice(1) : hasImportantSuffix ? utility.slice(0, -1) : utility;
1157
+ const replacement = DEPRECATED_MAP[bareUtility];
1158
+ if (!replacement) continue;
1159
+ if (dsResult) {
1160
+ const canonical = dsResult.cache.canonicalize(bareUtility);
1161
+ if (canonical !== bareUtility && canonical === replacement) {}
1162
+ }
1163
+ const fullReplacement = variant + (hasImportantPrefix ? "!" : "") + replacement + (hasImportantSuffix ? "!" : "");
1164
+ offending.push({
1165
+ cls,
1166
+ replacement: fullReplacement
1167
+ });
1168
+ }
1169
+ if (offending.length === 0) continue;
1170
+ const replacements = new Map(offending.map(({ cls, replacement }) => [cls, replacement]));
1171
+ const fixedValue = classes.map((cls) => replacements.get(cls) ?? cls).join(" ");
1172
+ for (let i = 0; i < offending.length; i++) {
1173
+ const { cls, replacement } = offending[i];
1174
+ if (i === 0) context.report({
1175
+ node: loc.node,
1176
+ messageId: "deprecated",
1177
+ data: {
1178
+ className: cls,
1179
+ replacement
1180
+ },
1181
+ fix(fixer) {
1182
+ return fixer.replaceTextRange(loc.range, preserveSpaces(loc, fixedValue));
1183
+ }
1184
+ });
1185
+ else context.report({
1186
+ node: loc.node,
1187
+ messageId: "deprecated",
1188
+ data: {
1189
+ className: cls,
1190
+ replacement
1191
+ }
1192
+ });
1193
+ }
1194
+ }
1195
+ }
1196
+ return {
1197
+ JSXAttribute(node) {
1198
+ check(extractFromJSXAttribute(node, DEFAULT_EXTRACTOR_CONFIG));
1199
+ },
1200
+ CallExpression(node) {
1201
+ check(extractFromCallExpression(node, DEFAULT_EXTRACTOR_CONFIG));
1202
+ },
1203
+ TaggedTemplateExpression(node) {
1204
+ check(extractFromTaggedTemplate(node, DEFAULT_EXTRACTOR_CONFIG));
1205
+ },
1206
+ VariableDeclarator(node) {
1207
+ check(extractFromVariableDeclarator(node, DEFAULT_EXTRACTOR_CONFIG));
1208
+ }
1209
+ };
873
1210
  }
874
- }
1211
+ });
875
1212
  //#endregion
876
1213
  //#region src/rules/no-unknown-classes.ts
877
1214
  const noUnknownClasses = (0, _oxlint_plugins.defineRule)({
@@ -899,28 +1236,42 @@ const noUnknownClasses = (0, _oxlint_plugins.defineRule)({
899
1236
  }
900
1237
  },
901
1238
  createOnce(context) {
902
- const options = safeOptions(context);
903
- const result = getLoadedDesignSystem(options?.entryPoint, safeSettings(context));
904
- if (!result) return {};
905
- const { cache } = result;
906
- const allowlist = new Set(options?.allowlist ?? []);
907
- const ignorePrefixes = options?.ignorePrefixes ?? [];
1239
+ const getDS = createLazyLoader(context);
1240
+ let _allowlist = null;
1241
+ let _ignorePrefixes = null;
1242
+ function getLazyOptions() {
1243
+ if (_allowlist === null) {
1244
+ const opts = safeOptions(context);
1245
+ _allowlist = new Set(opts?.allowlist ?? []);
1246
+ _ignorePrefixes = opts?.ignorePrefixes ?? [];
1247
+ }
1248
+ return {
1249
+ allowlist: _allowlist,
1250
+ ignorePrefixes: _ignorePrefixes
1251
+ };
1252
+ }
908
1253
  function shouldIgnore(className) {
1254
+ const { allowlist, ignorePrefixes } = getLazyOptions();
909
1255
  if (allowlist.has(className)) return true;
910
1256
  return ignorePrefixes.some((prefix) => className.startsWith(prefix));
911
1257
  }
912
1258
  function stripModifiers(className) {
913
1259
  let stripped = className;
914
1260
  if (stripped.startsWith("!")) stripped = stripped.slice(1);
1261
+ if (stripped.endsWith("!")) stripped = stripped.slice(0, -1);
915
1262
  return stripped;
916
1263
  }
917
1264
  function check(locations) {
1265
+ const ds = getDS();
1266
+ if (!ds) return;
1267
+ const { cache } = ds;
918
1268
  for (const loc of locations) {
919
1269
  const classes = splitClasses(loc.value);
920
1270
  for (const cls of classes) {
921
1271
  if (shouldIgnore(cls)) continue;
922
1272
  const stripped = stripModifiers(cls);
923
1273
  if (cache.isValid(stripped)) continue;
1274
+ if (DEPRECATED_MAP[stripped]) continue;
924
1275
  const suggestion = findBestSuggestion(stripped, cache.validClasses);
925
1276
  if (suggestion) context.report({
926
1277
  node: loc.node,
@@ -968,10 +1319,11 @@ const noConflictingClasses = (0, _oxlint_plugins.defineRule)({
968
1319
  messages: { conflict: "\"{{classA}}\" and \"{{classB}}\" affect {{properties}}. \"{{winner}}\" takes precedence (appears later)." }
969
1320
  },
970
1321
  createOnce(context) {
971
- const result = getLoadedDesignSystem(safeOptions(context)?.entryPoint, safeSettings(context));
972
- if (!result) return {};
973
- const { cache } = result;
1322
+ const getDS = createLazyLoader(context);
974
1323
  function check(locations) {
1324
+ const ds = getDS();
1325
+ if (!ds) return;
1326
+ const { cache } = ds;
975
1327
  for (const loc of locations) {
976
1328
  const classes = splitClasses(loc.value);
977
1329
  if (classes.length < 2) continue;
@@ -986,16 +1338,43 @@ const noConflictingClasses = (0, _oxlint_plugins.defineRule)({
986
1338
  if (variantClasses.length < 2) continue;
987
1339
  const propsMap = /* @__PURE__ */ new Map();
988
1340
  for (const cls of variantClasses) {
989
- const utility = extractUtility(cls);
1341
+ let utility = extractUtility(cls);
1342
+ if (utility.startsWith("!")) utility = utility.slice(1);
1343
+ else if (utility.endsWith("!")) utility = utility.slice(0, -1);
990
1344
  const props = cache.getCssProperties(utility);
991
1345
  propsMap.set(cls, props);
992
1346
  }
1347
+ const COMPLEMENTARY_GROUPS = [
1348
+ /^(?:from|via|to)-/,
1349
+ /^(?:shadow|ring|ring-offset)-/,
1350
+ /^(?:transition|duration|ease|delay)(?:-|$)/,
1351
+ /^-?(?:translate|scale|rotate|skew)-/,
1352
+ /^prose(?:-|$)/
1353
+ ];
1354
+ const COMPOSITION_PAIRS = [
1355
+ [/^text-/, /^leading-/],
1356
+ [/^border(?:-[0-9]|$)/, /^border-(?:solid|dashed|dotted|double|hidden|none)$/],
1357
+ [/^divide-/, /^border(?:-[trblxyse])?-/],
1358
+ [/^prose(?:-|$)/, /^max-w-/]
1359
+ ];
1360
+ function shouldSkipPair(a, b) {
1361
+ let ua = extractUtility(a);
1362
+ let ub = extractUtility(b);
1363
+ if (ua.startsWith("!")) ua = ua.slice(1);
1364
+ else if (ua.endsWith("!")) ua = ua.slice(0, -1);
1365
+ if (ub.startsWith("!")) ub = ub.slice(1);
1366
+ else if (ub.endsWith("!")) ub = ub.slice(0, -1);
1367
+ for (const re of COMPLEMENTARY_GROUPS) if (re.test(ua) && re.test(ub)) return true;
1368
+ for (const [reA, reB] of COMPOSITION_PAIRS) if (reA.test(ua) && reB.test(ub) || reA.test(ub) && reB.test(ua)) return true;
1369
+ return false;
1370
+ }
993
1371
  for (let i = 0; i < variantClasses.length; i++) {
994
1372
  const classA = variantClasses[i];
995
1373
  const propsA = propsMap.get(classA) ?? [];
996
1374
  for (let j = i + 1; j < variantClasses.length; j++) {
997
1375
  const classB = variantClasses[j];
998
1376
  const propsB = propsMap.get(classB) ?? [];
1377
+ if (shouldSkipPair(classA, classB)) continue;
999
1378
  const overlap = propsA.filter((p) => propsB.includes(p));
1000
1379
  if (overlap.length > 0) {
1001
1380
  const propList = overlap.length <= 3 ? `"${overlap.join("\", \"")}"` : `${overlap.length} CSS properties`;
@@ -1032,74 +1411,6 @@ const noConflictingClasses = (0, _oxlint_plugins.defineRule)({
1032
1411
  }
1033
1412
  });
1034
1413
  //#endregion
1035
- //#region src/rules/no-deprecated-classes.ts
1036
- const DEPRECATED_MAP = {
1037
- "flex-grow": "grow",
1038
- "flex-grow-0": "grow-0",
1039
- "flex-shrink": "shrink",
1040
- "flex-shrink-0": "shrink-0",
1041
- "overflow-ellipsis": "text-ellipsis",
1042
- "decoration-slice": "box-decoration-slice",
1043
- "decoration-clone": "box-decoration-clone"
1044
- };
1045
- const noDeprecatedClasses = (0, _oxlint_plugins.defineRule)({
1046
- meta: {
1047
- type: "problem",
1048
- docs: { description: "Disallow deprecated Tailwind CSS v4 classes" },
1049
- fixable: "code",
1050
- schema: [{
1051
- type: "object",
1052
- properties: { entryPoint: { type: "string" } },
1053
- additionalProperties: false
1054
- }],
1055
- messages: { deprecated: "\"{{className}}\" is deprecated in Tailwind v4. Use \"{{replacement}}\" instead." }
1056
- },
1057
- createOnce(context) {
1058
- const result = getLoadedDesignSystem(safeOptions(context)?.entryPoint, safeSettings(context));
1059
- function check(locations) {
1060
- for (const loc of locations) {
1061
- const classes = splitClasses(loc.value);
1062
- for (const cls of classes) {
1063
- const { utility, variant } = splitUtilityAndVariant(cls);
1064
- const replacement = DEPRECATED_MAP[utility];
1065
- if (!replacement) continue;
1066
- if (result) {
1067
- const canonical = result.cache.canonicalize(utility);
1068
- if (canonical !== utility && canonical === replacement) {}
1069
- }
1070
- const fullReplacement = variant + replacement;
1071
- context.report({
1072
- node: loc.node,
1073
- messageId: "deprecated",
1074
- data: {
1075
- className: cls,
1076
- replacement: fullReplacement
1077
- },
1078
- fix(fixer) {
1079
- const fixed = loc.value.replace(cls, fullReplacement);
1080
- return fixer.replaceTextRange(loc.range, preserveSpaces(loc, fixed));
1081
- }
1082
- });
1083
- }
1084
- }
1085
- }
1086
- return {
1087
- JSXAttribute(node) {
1088
- check(extractFromJSXAttribute(node, DEFAULT_EXTRACTOR_CONFIG));
1089
- },
1090
- CallExpression(node) {
1091
- check(extractFromCallExpression(node, DEFAULT_EXTRACTOR_CONFIG));
1092
- },
1093
- TaggedTemplateExpression(node) {
1094
- check(extractFromTaggedTemplate(node, DEFAULT_EXTRACTOR_CONFIG));
1095
- },
1096
- VariableDeclarator(node) {
1097
- check(extractFromVariableDeclarator(node, DEFAULT_EXTRACTOR_CONFIG));
1098
- }
1099
- };
1100
- }
1101
- });
1102
- //#endregion
1103
1414
  //#region src/rules/enforce-canonical.ts
1104
1415
  const enforceCanonical = (0, _oxlint_plugins.defineRule)({
1105
1416
  meta: {
@@ -1114,10 +1425,11 @@ const enforceCanonical = (0, _oxlint_plugins.defineRule)({
1114
1425
  messages: { nonCanonical: "\"{{className}}\" can be written as \"{{canonical}}\". Use the canonical form." }
1115
1426
  },
1116
1427
  createOnce(context) {
1117
- const result = getLoadedDesignSystem(safeOptions(context)?.entryPoint, safeSettings(context));
1118
- if (!result) return {};
1119
- const { cache } = result;
1428
+ const getDS = createLazyLoader(context);
1120
1429
  function check(locations) {
1430
+ const ds = getDS();
1431
+ if (!ds) return;
1432
+ const { cache } = ds;
1121
1433
  for (const loc of locations) {
1122
1434
  const classes = splitClasses(loc.value);
1123
1435
  const canonicals = classes.map((cls) => cache.canonicalize(cls));
@@ -1168,6 +1480,187 @@ const enforceCanonical = (0, _oxlint_plugins.defineRule)({
1168
1480
  }
1169
1481
  });
1170
1482
  //#endregion
1483
+ //#region src/design-system/sort-service.ts
1484
+ /**
1485
+ * Persistent sort service using named pipes (FIFOs) for synchronous IPC.
1486
+ *
1487
+ * The problem: `ds.getClassOrder()` is the only way to get the exact official
1488
+ * Tailwind CSS sort order (matching oxfmt/prettier-plugin-tailwindcss), but the
1489
+ * design system is async to load and the oxlint plugin API is sync.
1490
+ *
1491
+ * The solution: spawn a persistent child process that loads the DS once, then
1492
+ * accepts sort requests via FIFOs. File descriptors are opened ONCE and kept
1493
+ * open for the entire lint session, using newline-delimited JSON framing.
1494
+ *
1495
+ * Falls back gracefully on platforms without FIFO support (Windows).
1496
+ */
1497
+ const SORT_WORKER_SCRIPT = `
1498
+ const { openSync, readSync, writeSync, closeSync } = require('fs');
1499
+ const { dirname } = require('path');
1500
+
1501
+ function readLine(fd) {
1502
+ let line = '';
1503
+ const buf = Buffer.alloc(1);
1504
+ while (true) {
1505
+ const n = readSync(fd, buf, 0, 1);
1506
+ if (n === 0) return null;
1507
+ if (buf[0] === 10) return line;
1508
+ line += String.fromCharCode(buf[0]);
1509
+ }
1510
+ }
1511
+
1512
+ async function main() {
1513
+ const cssPath = process.env.TAILWIND_CSS_PATH;
1514
+ const reqPipe = process.env.REQ_PIPE;
1515
+ const resPipe = process.env.RES_PIPE;
1516
+
1517
+ const { __unstable__loadDesignSystem } = require('@tailwindcss/node');
1518
+ const { readFileSync } = require('fs');
1519
+ const css = readFileSync(cssPath, 'utf-8');
1520
+ const ds = await __unstable__loadDesignSystem(css, { base: dirname(cssPath) });
1521
+
1522
+ const reqFd = openSync(reqPipe, 'r');
1523
+ const resFd = openSync(resPipe, 'w');
1524
+
1525
+ let req;
1526
+ while ((req = readLine(reqFd)) !== null) {
1527
+ if (!req) continue;
1528
+ try {
1529
+ const classes = JSON.parse(req);
1530
+ const ordered = ds.getClassOrder(classes);
1531
+ const sorted = [...ordered]
1532
+ .sort((a, b) => {
1533
+ if (a[1] === null && b[1] === null) return 0;
1534
+ if (a[1] === null) return -1;
1535
+ if (b[1] === null) return 1;
1536
+ return a[1] < b[1] ? -1 : a[1] > b[1] ? 1 : 0;
1537
+ })
1538
+ .map(([name]) => name);
1539
+ const out = Buffer.from(JSON.stringify(sorted) + '\\n', 'utf-8');
1540
+ writeSync(resFd, out, 0, out.length);
1541
+ } catch {
1542
+ const out = Buffer.from('null\\n', 'utf-8');
1543
+ writeSync(resFd, out, 0, out.length);
1544
+ }
1545
+ }
1546
+
1547
+ closeSync(reqFd);
1548
+ closeSync(resFd);
1549
+ }
1550
+ main().catch(() => process.exit(1));
1551
+ `;
1552
+ let child = null;
1553
+ let reqPipe = null;
1554
+ let resPipe = null;
1555
+ let reqFd = null;
1556
+ let resFd = null;
1557
+ let initialized = false;
1558
+ let available = true;
1559
+ let readBuffer = "";
1560
+ /** Read a newline-delimited line from an open file descriptor (blocking). */
1561
+ function readLineSync(fd) {
1562
+ while (true) {
1563
+ const nlIdx = readBuffer.indexOf("\n");
1564
+ if (nlIdx >= 0) {
1565
+ const line = readBuffer.slice(0, nlIdx);
1566
+ readBuffer = readBuffer.slice(nlIdx + 1);
1567
+ return line;
1568
+ }
1569
+ const buf = Buffer.alloc(65536);
1570
+ const n = (0, node_fs.readSync)(fd, buf, 0, buf.length, null);
1571
+ if (n === 0) throw new Error("EOF");
1572
+ readBuffer += buf.toString("utf-8", 0, n);
1573
+ }
1574
+ }
1575
+ function ensureService(cssPath) {
1576
+ if (initialized) return available;
1577
+ initialized = true;
1578
+ try {
1579
+ const id = `${process.pid}-${Date.now()}`;
1580
+ reqPipe = (0, node_path.join)((0, node_os.tmpdir)(), `oxlint-tw-req-${id}`);
1581
+ resPipe = (0, node_path.join)((0, node_os.tmpdir)(), `oxlint-tw-res-${id}`);
1582
+ (0, node_child_process.execFileSync)("mkfifo", [reqPipe]);
1583
+ (0, node_child_process.execFileSync)("mkfifo", [resPipe]);
1584
+ child = (0, node_child_process.spawn)(process.execPath, ["-e", SORT_WORKER_SCRIPT], {
1585
+ env: {
1586
+ ...process.env,
1587
+ TAILWIND_CSS_PATH: cssPath,
1588
+ REQ_PIPE: reqPipe,
1589
+ RES_PIPE: resPipe
1590
+ },
1591
+ cwd: (0, node_path.dirname)(cssPath),
1592
+ stdio: "ignore",
1593
+ detached: false
1594
+ });
1595
+ child.unref();
1596
+ child.on("error", () => {
1597
+ child = null;
1598
+ available = false;
1599
+ });
1600
+ child.on("exit", () => {
1601
+ child = null;
1602
+ });
1603
+ reqFd = (0, node_fs.openSync)(reqPipe, "w");
1604
+ resFd = (0, node_fs.openSync)(resPipe, "r");
1605
+ process.on("exit", cleanup);
1606
+ return true;
1607
+ } catch {
1608
+ available = false;
1609
+ cleanup();
1610
+ return false;
1611
+ }
1612
+ }
1613
+ function cleanup() {
1614
+ if (reqFd !== null) {
1615
+ try {
1616
+ (0, node_fs.closeSync)(reqFd);
1617
+ } catch {}
1618
+ reqFd = null;
1619
+ }
1620
+ if (resFd !== null) {
1621
+ try {
1622
+ (0, node_fs.closeSync)(resFd);
1623
+ } catch {}
1624
+ resFd = null;
1625
+ }
1626
+ if (child) {
1627
+ try {
1628
+ child.kill();
1629
+ } catch {}
1630
+ child = null;
1631
+ }
1632
+ if (reqPipe) {
1633
+ try {
1634
+ (0, node_fs.unlinkSync)(reqPipe);
1635
+ } catch {}
1636
+ reqPipe = null;
1637
+ }
1638
+ if (resPipe) {
1639
+ try {
1640
+ (0, node_fs.unlinkSync)(resPipe);
1641
+ } catch {}
1642
+ resPipe = null;
1643
+ }
1644
+ }
1645
+ /**
1646
+ * Sort classes using the official Tailwind CSS sort order via persistent child process.
1647
+ * Returns the sorted class array, or null if the service is unavailable.
1648
+ */
1649
+ function sortClassesSync(cssPath, classes) {
1650
+ if (!ensureService(cssPath)) return null;
1651
+ if (reqFd === null || resFd === null) return null;
1652
+ try {
1653
+ const payload = Buffer.from(JSON.stringify(classes) + "\n", "utf-8");
1654
+ (0, node_fs.writeSync)(reqFd, payload, 0, payload.length);
1655
+ const line = readLineSync(resFd);
1656
+ return JSON.parse(line);
1657
+ } catch {
1658
+ available = false;
1659
+ cleanup();
1660
+ return null;
1661
+ }
1662
+ }
1663
+ //#endregion
1171
1664
  //#region src/rules/enforce-sort-order.ts
1172
1665
  const enforceSortOrder = (0, _oxlint_plugins.defineRule)({
1173
1666
  meta: {
@@ -1188,60 +1681,65 @@ const enforceSortOrder = (0, _oxlint_plugins.defineRule)({
1188
1681
  messages: { unsorted: "Tailwind classes are not in the recommended order." }
1189
1682
  },
1190
1683
  createOnce(context) {
1191
- const result = getLoadedDesignSystem(safeOptions(context)?.entryPoint, safeSettings(context));
1192
- if (!result) return {};
1193
- const { cache } = result;
1684
+ const getDS = createLazyLoader(context);
1194
1685
  let _mode = null;
1195
1686
  function getMode() {
1196
1687
  if (_mode === null) _mode = safeOptions(context)?.mode ?? "default";
1197
1688
  return _mode;
1198
1689
  }
1199
- function sortDefault(classes) {
1200
- return [...cache.getClassOrder(classes)].sort((a, b) => {
1201
- const orderA = a[1] ?? 0n;
1202
- const orderB = b[1] ?? 0n;
1203
- if (orderA < orderB) return -1;
1204
- if (orderA > orderB) return 1;
1205
- return 0;
1206
- }).map(([name]) => name);
1207
- }
1208
- function sortStrict(classes) {
1209
- const groups = /* @__PURE__ */ new Map();
1210
- const groupOrder = [];
1211
- for (const cls of classes) {
1212
- const { variant } = splitUtilityAndVariant(cls);
1213
- if (!groups.has(variant)) {
1214
- groups.set(variant, []);
1215
- groupOrder.push(variant);
1216
- }
1217
- groups.get(variant).push(cls);
1218
- }
1219
- for (const [, groupClasses] of groups) {
1220
- const ordered = cache.getClassOrder(groupClasses);
1221
- ordered.sort((a, b) => {
1690
+ function check(locations) {
1691
+ const ds = getDS();
1692
+ if (!ds) return;
1693
+ const { cache, entryPoint } = ds;
1694
+ const mode = getMode();
1695
+ function sortDefault(classes) {
1696
+ const dynamic = sortClassesSync(entryPoint, classes);
1697
+ if (dynamic) return dynamic;
1698
+ return [...cache.getClassOrder(classes)].sort((a, b) => {
1222
1699
  const orderA = a[1] ?? 0n;
1223
1700
  const orderB = b[1] ?? 0n;
1224
1701
  if (orderA < orderB) return -1;
1225
1702
  if (orderA > orderB) return 1;
1226
1703
  return 0;
1704
+ }).map(([name]) => name);
1705
+ }
1706
+ function sortStrict(classes) {
1707
+ const groups = /* @__PURE__ */ new Map();
1708
+ const groupOrder = [];
1709
+ for (const cls of classes) {
1710
+ const { variant } = splitUtilityAndVariant(cls);
1711
+ if (!groups.has(variant)) {
1712
+ groups.set(variant, []);
1713
+ groupOrder.push(variant);
1714
+ }
1715
+ groups.get(variant).push(cls);
1716
+ }
1717
+ for (const [, groupClasses] of groups) {
1718
+ const ordered = cache.getClassOrder(groupClasses);
1719
+ ordered.sort((a, b) => {
1720
+ const orderA = a[1] ?? 0n;
1721
+ const orderB = b[1] ?? 0n;
1722
+ if (orderA < orderB) return -1;
1723
+ if (orderA > orderB) return 1;
1724
+ return 0;
1725
+ });
1726
+ groupClasses.length = 0;
1727
+ for (const [name] of ordered) groupClasses.push(name);
1728
+ }
1729
+ const sortedGroupKeys = [...groups.keys()].sort((a, b) => {
1730
+ if (a === "" && b !== "") return -1;
1731
+ if (a !== "" && b === "") return 1;
1732
+ if (a === "" && b === "") return 0;
1733
+ const variantA = a.slice(0, -1);
1734
+ const variantB = b.slice(0, -1);
1735
+ const firstA = variantA.includes(":") ? variantA.split(":")[0] : variantA;
1736
+ const firstB = variantB.includes(":") ? variantB.split(":")[0] : variantB;
1737
+ return (cache.getVariantPriority(firstA) ?? Number.MAX_SAFE_INTEGER) - (cache.getVariantPriority(firstB) ?? Number.MAX_SAFE_INTEGER);
1227
1738
  });
1228
- groupClasses.length = 0;
1229
- for (const [name] of ordered) groupClasses.push(name);
1739
+ const result = [];
1740
+ for (const key of sortedGroupKeys) result.push(...groups.get(key));
1741
+ return result;
1230
1742
  }
1231
- const sortedGroupKeys = [...groups.keys()].sort((a, b) => {
1232
- if (a === "" && b !== "") return -1;
1233
- if (a !== "" && b === "") return 1;
1234
- if (a === "" && b === "") return 0;
1235
- const variantA = a.slice(0, -1);
1236
- const variantB = b.slice(0, -1);
1237
- return (cache.getVariantPriority(variantA) ?? Number.MAX_SAFE_INTEGER) - (cache.getVariantPriority(variantB) ?? Number.MAX_SAFE_INTEGER);
1238
- });
1239
- const result = [];
1240
- for (const key of sortedGroupKeys) result.push(...groups.get(key));
1241
- return result;
1242
- }
1243
- function check(locations) {
1244
- const mode = getMode();
1245
1743
  for (const loc of locations) {
1246
1744
  const classes = splitClasses(loc.value);
1247
1745
  if (classes.length < 2) continue;
@@ -1275,6 +1773,15 @@ const enforceSortOrder = (0, _oxlint_plugins.defineRule)({
1275
1773
  //#endregion
1276
1774
  //#region src/rules/enforce-shorthand.ts
1277
1775
  const VALUE_RE = /^(?:m[trbl]|p[trbl]|[wh]|rounded-t[lr]|rounded-b[lr]|min-[wh]|max-[wh])-(.+)$/;
1776
+ const INVALID_SIZE_VALUES = new Set([
1777
+ "screen",
1778
+ "dvw",
1779
+ "dvh",
1780
+ "svw",
1781
+ "svh",
1782
+ "lvw",
1783
+ "lvh"
1784
+ ]);
1278
1785
  /**
1279
1786
  * Generates shorthand rules parameterized by value.
1280
1787
  * E.g.: mt-2 + mr-2 + mb-2 + ml-2 -> m-2
@@ -1315,10 +1822,10 @@ function createShorthandRules(value) {
1315
1822
  parts: [`pl-${value}`, `pr-${value}`],
1316
1823
  replacement: `px-${value}`
1317
1824
  },
1318
- {
1825
+ ...!INVALID_SIZE_VALUES.has(value) ? [{
1319
1826
  parts: [`w-${value}`, `h-${value}`],
1320
1827
  replacement: `size-${value}`
1321
- },
1828
+ }] : [],
1322
1829
  {
1323
1830
  parts: [
1324
1831
  `rounded-tl-${value}`,
@@ -1346,20 +1853,28 @@ const enforceShorthand = (0, _oxlint_plugins.defineRule)({
1346
1853
  const classSet = new Set(classes);
1347
1854
  const values = /* @__PURE__ */ new Set();
1348
1855
  for (const cls of classes) {
1349
- const match = VALUE_RE.exec(cls);
1856
+ const bare = cls.startsWith("!") ? cls.slice(1) : cls.endsWith("!") ? cls.slice(0, -1) : cls;
1857
+ const match = VALUE_RE.exec(bare);
1350
1858
  if (match) values.add(match[1]);
1351
1859
  }
1352
1860
  for (const value of values) {
1353
1861
  const rules = createShorthandRules(value);
1354
- for (const rule of rules) if (rule.parts.every((p) => classSet.has(p))) {
1355
- const remaining = classes.filter((c) => !rule.parts.includes(c));
1356
- remaining.push(rule.replacement);
1862
+ for (const rule of rules) {
1863
+ const hasImportantPrefix = rule.parts.every((p) => classSet.has(`!${p}`));
1864
+ const hasImportantSuffix = !hasImportantPrefix && rule.parts.every((p) => classSet.has(`${p}!`));
1865
+ const hasPlain = rule.parts.every((p) => classSet.has(p));
1866
+ if (!hasImportantPrefix && !hasImportantSuffix && !hasPlain) continue;
1867
+ const importantStart = hasImportantPrefix ? "!" : "";
1868
+ const importantEnd = hasImportantSuffix ? "!" : "";
1869
+ const matchParts = rule.parts.map((p) => `${importantStart}${p}${importantEnd}`);
1870
+ const remaining = classes.filter((c) => !matchParts.includes(c));
1871
+ remaining.push(`${importantStart}${rule.replacement}${importantEnd}`);
1357
1872
  context.report({
1358
1873
  node: loc.node,
1359
1874
  messageId: "shorthand",
1360
1875
  data: {
1361
- parts: rule.parts.map((p) => `"${p}"`).join(", "),
1362
- replacement: rule.replacement
1876
+ parts: matchParts.map((p) => `"${p}"`).join(", "),
1877
+ replacement: `${importantStart}${rule.replacement}${importantEnd}`
1363
1878
  },
1364
1879
  fix(fixer) {
1365
1880
  return fixer.replaceTextRange(loc.range, preserveSpaces(loc, remaining.join(" ")));
@@ -1418,7 +1933,13 @@ const enforceLogical = (0, _oxlint_plugins.defineRule)({
1418
1933
  createOnce(context) {
1419
1934
  function convertClass(cls) {
1420
1935
  const { utility, variant } = splitUtilityAndVariant(cls);
1421
- for (const [physical, logical] of Object.entries(PHYSICAL_TO_LOGICAL)) if (utility === physical || utility.startsWith(`${physical}-`)) return `${variant}${logical}${utility.slice(physical.length)}`;
1936
+ const hasImportantPrefix = utility.startsWith("!");
1937
+ const hasImportantSuffix = !hasImportantPrefix && utility.endsWith("!");
1938
+ const bareUtility = hasImportantPrefix ? utility.slice(1) : hasImportantSuffix ? utility.slice(0, -1) : utility;
1939
+ for (const [physical, logical] of Object.entries(PHYSICAL_TO_LOGICAL)) if (bareUtility === physical || bareUtility.startsWith(`${physical}-`)) {
1940
+ const suffix = bareUtility.slice(physical.length);
1941
+ return `${variant}${hasImportantPrefix ? "!" : ""}${logical}${suffix}${hasImportantSuffix ? "!" : ""}`;
1942
+ }
1422
1943
  return null;
1423
1944
  }
1424
1945
  function check(locations) {
@@ -1476,6 +1997,84 @@ const enforceLogical = (0, _oxlint_plugins.defineRule)({
1476
1997
  }
1477
1998
  });
1478
1999
  //#endregion
2000
+ //#region src/rules/enforce-physical.ts
2001
+ const LOGICAL_TO_PHYSICAL = {};
2002
+ for (const [physical, logical] of Object.entries(PHYSICAL_TO_LOGICAL)) LOGICAL_TO_PHYSICAL[logical] = physical;
2003
+ const enforcePhysical = (0, _oxlint_plugins.defineRule)({
2004
+ meta: {
2005
+ type: "suggestion",
2006
+ docs: { description: "Enforce physical Tailwind CSS properties instead of logical ones for consistency in LTR-only projects" },
2007
+ fixable: "code",
2008
+ schema: [],
2009
+ messages: { usePhysical: "\"{{className}}\" uses a logical property. Use \"{{replacement}}\" for consistency." }
2010
+ },
2011
+ createOnce(context) {
2012
+ function convertClass(cls) {
2013
+ const { utility, variant } = splitUtilityAndVariant(cls);
2014
+ const hasImportantPrefix = utility.startsWith("!");
2015
+ const hasImportantSuffix = !hasImportantPrefix && utility.endsWith("!");
2016
+ const bareUtility = hasImportantPrefix ? utility.slice(1) : hasImportantSuffix ? utility.slice(0, -1) : utility;
2017
+ for (const [logical, physical] of Object.entries(LOGICAL_TO_PHYSICAL)) if (bareUtility === logical || bareUtility.startsWith(`${logical}-`)) {
2018
+ const suffix = bareUtility.slice(logical.length);
2019
+ return `${variant}${hasImportantPrefix ? "!" : ""}${physical}${suffix}${hasImportantSuffix ? "!" : ""}`;
2020
+ }
2021
+ return null;
2022
+ }
2023
+ function check(locations) {
2024
+ for (const loc of locations) {
2025
+ const classes = splitClasses(loc.value);
2026
+ const offending = [];
2027
+ for (const cls of classes) {
2028
+ const converted = convertClass(cls);
2029
+ if (converted) offending.push({
2030
+ cls,
2031
+ replacement: converted
2032
+ });
2033
+ }
2034
+ if (offending.length === 0) continue;
2035
+ const replacements = new Map(offending.map(({ cls, replacement }) => [cls, replacement]));
2036
+ const fixedValue = classes.map((cls) => replacements.get(cls) ?? cls).join(" ");
2037
+ for (let i = 0; i < offending.length; i++) {
2038
+ const { cls, replacement } = offending[i];
2039
+ if (i === 0) context.report({
2040
+ node: loc.node,
2041
+ messageId: "usePhysical",
2042
+ data: {
2043
+ className: cls,
2044
+ replacement
2045
+ },
2046
+ fix(fixer) {
2047
+ return fixer.replaceTextRange(loc.range, preserveSpaces(loc, fixedValue));
2048
+ }
2049
+ });
2050
+ else context.report({
2051
+ node: loc.node,
2052
+ messageId: "usePhysical",
2053
+ data: {
2054
+ className: cls,
2055
+ replacement
2056
+ }
2057
+ });
2058
+ }
2059
+ }
2060
+ }
2061
+ return {
2062
+ JSXAttribute(node) {
2063
+ check(extractFromJSXAttribute(node, DEFAULT_EXTRACTOR_CONFIG));
2064
+ },
2065
+ CallExpression(node) {
2066
+ check(extractFromCallExpression(node, DEFAULT_EXTRACTOR_CONFIG));
2067
+ },
2068
+ TaggedTemplateExpression(node) {
2069
+ check(extractFromTaggedTemplate(node, DEFAULT_EXTRACTOR_CONFIG));
2070
+ },
2071
+ VariableDeclarator(node) {
2072
+ check(extractFromVariableDeclarator(node, DEFAULT_EXTRACTOR_CONFIG));
2073
+ }
2074
+ };
2075
+ }
2076
+ });
2077
+ //#endregion
1479
2078
  //#region src/rules/max-class-count.ts
1480
2079
  const DEFAULT_MAX = 20;
1481
2080
  const maxClassCount = (0, _oxlint_plugins.defineRule)({
@@ -1652,7 +2251,10 @@ const noArbitraryValue = (0, _oxlint_plugins.defineRule)({
1652
2251
  const classes = splitClasses(loc.value);
1653
2252
  for (const cls of classes) {
1654
2253
  if (!hasArbitraryValue(cls)) continue;
1655
- if (isAllowed(extractUtility(cls))) continue;
2254
+ let utility = extractUtility(cls);
2255
+ if (utility.startsWith("!")) utility = utility.slice(1);
2256
+ else if (utility.endsWith("!")) utility = utility.slice(0, -1);
2257
+ if (isAllowed(utility)) continue;
1656
2258
  context.report({
1657
2259
  node: loc.node,
1658
2260
  messageId: "noArbitrary",
@@ -1769,14 +2371,18 @@ const enforceConsistentImportantPosition = (0, _oxlint_plugins.defineRule)({
1769
2371
  //#region src/rules/enforce-negative-arbitrary-values.ts
1770
2372
  function fixClass(cls) {
1771
2373
  const { utility, variant } = splitUtilityAndVariant(cls);
1772
- if (!utility.startsWith("-")) return null;
1773
- const bracketOpen = utility.indexOf("[");
2374
+ const hasImportantPrefix = utility.startsWith("!");
2375
+ const hasImportantSuffix = !hasImportantPrefix && utility.endsWith("!");
2376
+ const bare = hasImportantPrefix ? utility.slice(1) : hasImportantSuffix ? utility.slice(0, -1) : utility;
2377
+ if (!bare.startsWith("-")) return null;
2378
+ const bracketOpen = bare.indexOf("[");
1774
2379
  if (bracketOpen === -1) return null;
1775
- const bracketClose = utility.lastIndexOf("]");
2380
+ const bracketClose = bare.lastIndexOf("]");
1776
2381
  if (bracketClose === -1 || bracketClose < bracketOpen) return null;
1777
- const innerValue = utility.slice(bracketOpen + 1, bracketClose);
2382
+ const innerValue = bare.slice(bracketOpen + 1, bracketClose);
1778
2383
  if (innerValue.startsWith("-")) return null;
1779
- return `${variant}${utility.slice(1, bracketOpen)}[-${innerValue}]`;
2384
+ const baseUtility = bare.slice(1, bracketOpen);
2385
+ return `${variant}${hasImportantPrefix ? "!" : ""}${baseUtility}[-${innerValue}]${hasImportantSuffix ? "!" : ""}`;
1780
2386
  }
1781
2387
  /**
1782
2388
  * Detects `-utility-[value]` and suggests `utility-[-value]`.
@@ -1851,17 +2457,22 @@ const EXPLICIT_VAR_RE = /^([a-z][a-z0-9-]*(?:-[a-z0-9]+)*)-\[var\((--[a-zA-Z0-9-
1851
2457
  const SHORTHAND_VAR_RE = /^([a-z][a-z0-9-]*(?:-[a-z0-9]+)*)-\((--[a-zA-Z0-9-]+)\)$/;
1852
2458
  function convertClass(cls, syntax) {
1853
2459
  const { utility, variant } = splitUtilityAndVariant(cls);
2460
+ const hasImportantPrefix = utility.startsWith("!");
2461
+ const hasImportantSuffix = !hasImportantPrefix && utility.endsWith("!");
2462
+ const bareUtility = hasImportantPrefix ? utility.slice(1) : hasImportantSuffix ? utility.slice(0, -1) : utility;
2463
+ const importantStart = hasImportantPrefix ? "!" : "";
2464
+ const importantEnd = hasImportantSuffix ? "!" : "";
1854
2465
  if (syntax === "shorthand") {
1855
- const match = EXPLICIT_VAR_RE.exec(utility);
2466
+ const match = EXPLICIT_VAR_RE.exec(bareUtility);
1856
2467
  if (match) {
1857
2468
  const [, prefix, varName] = match;
1858
- return `${variant}${prefix}-(${varName})`;
2469
+ return `${variant}${importantStart}${prefix}-(${varName})${importantEnd}`;
1859
2470
  }
1860
2471
  } else {
1861
- const match = SHORTHAND_VAR_RE.exec(utility);
2472
+ const match = SHORTHAND_VAR_RE.exec(bareUtility);
1862
2473
  if (match) {
1863
2474
  const [, prefix, varName] = match;
1864
- return `${variant}${prefix}-[var(${varName})]`;
2475
+ return `${variant}${importantStart}${prefix}-[var(${varName})]${importantEnd}`;
1865
2476
  }
1866
2477
  }
1867
2478
  return null;
@@ -1988,6 +2599,7 @@ const KNOWN_PREFIXES = [
1988
2599
  function getUtilityPrefix(utility) {
1989
2600
  let u = utility;
1990
2601
  if (u.startsWith("!")) u = u.slice(1);
2602
+ else if (u.endsWith("!")) u = u.slice(0, -1);
1991
2603
  if (u.startsWith("-")) u = u.slice(1);
1992
2604
  for (const prefix of KNOWN_PREFIXES) if (u === prefix || u.startsWith(`${prefix}-`)) return prefix;
1993
2605
  const dashIdx = u.indexOf("-");
@@ -2140,7 +2752,10 @@ const noHardcodedColors = (0, _oxlint_plugins.defineRule)({
2140
2752
  for (const cls of classes) {
2141
2753
  if (allowlist.has(cls)) continue;
2142
2754
  if (!hasArbitraryValue(cls)) continue;
2143
- if (!isColorUtility(extractUtility(cls))) continue;
2755
+ let utility = extractUtility(cls);
2756
+ if (utility.startsWith("!")) utility = utility.slice(1);
2757
+ else if (utility.endsWith("!")) utility = utility.slice(0, -1);
2758
+ if (!isColorUtility(utility)) continue;
2144
2759
  const value = getArbitraryValue(cls);
2145
2760
  if (!value) continue;
2146
2761
  if (isHardcodedColor(value)) context.report({
@@ -2324,17 +2939,19 @@ const consistentVariantOrder = (0, _oxlint_plugins.defineRule)({
2324
2939
  messages: { wrongOrder: "\"{{className}}\" has variants in wrong order. Use \"{{replacement}}\" instead." }
2325
2940
  },
2326
2941
  createOnce(context) {
2327
- const dsCache = getLoadedDesignSystem(void 0, safeSettings(context))?.cache ?? null;
2942
+ const getDS = createLazyLoader(context);
2328
2943
  let _config = null;
2329
2944
  function getConfig() {
2330
2945
  if (_config === null) {
2331
2946
  const options = safeOptions(context);
2947
+ const dsCache = getDS()?.cache ?? null;
2332
2948
  const priorityMap = /* @__PURE__ */ new Map();
2333
2949
  if (options?.order) {
2334
2950
  for (let i = 0; i < options.order.length; i++) priorityMap.set(options.order[i], i);
2335
2951
  _config = {
2336
2952
  priorityMap,
2337
- fallbackPriority: options.order.length
2953
+ fallbackPriority: options.order.length,
2954
+ dsCache
2338
2955
  };
2339
2956
  } else if (dsCache && dsCache.hasVariantOrder()) {
2340
2957
  for (const variant of DEFAULT_VARIANT_ORDER) {
@@ -2343,20 +2960,22 @@ const consistentVariantOrder = (0, _oxlint_plugins.defineRule)({
2343
2960
  }
2344
2961
  _config = {
2345
2962
  priorityMap,
2346
- fallbackPriority: Number.MAX_SAFE_INTEGER
2963
+ fallbackPriority: Number.MAX_SAFE_INTEGER,
2964
+ dsCache
2347
2965
  };
2348
2966
  } else {
2349
2967
  for (let i = 0; i < DEFAULT_VARIANT_ORDER.length; i++) priorityMap.set(DEFAULT_VARIANT_ORDER[i], i);
2350
2968
  _config = {
2351
2969
  priorityMap,
2352
- fallbackPriority: DEFAULT_VARIANT_ORDER.length
2970
+ fallbackPriority: DEFAULT_VARIANT_ORDER.length,
2971
+ dsCache
2353
2972
  };
2354
2973
  }
2355
2974
  }
2356
2975
  return _config;
2357
2976
  }
2358
2977
  function getVariantPriority(variant) {
2359
- const { priorityMap, fallbackPriority } = getConfig();
2978
+ const { priorityMap, fallbackPriority, dsCache } = getConfig();
2360
2979
  const priority = priorityMap.get(variant);
2361
2980
  if (priority !== void 0) return priority;
2362
2981
  if (dsCache && dsCache.hasVariantOrder()) {
@@ -2533,21 +3152,25 @@ const noUnnecessaryArbitraryValue = (0, _oxlint_plugins.defineRule)({
2533
3152
  messages: { unnecessaryArbitrary: "\"{{className}}\" can be written as \"{{replacement}}\". Use the named class instead." }
2534
3153
  },
2535
3154
  createOnce(context) {
2536
- const result = getLoadedDesignSystem(safeOptions(context)?.entryPoint, safeSettings(context));
2537
- if (!result) return {};
2538
- const { cache } = result;
3155
+ const getDS = createLazyLoader(context);
2539
3156
  function check(locations) {
3157
+ const ds = getDS();
3158
+ if (!ds) return;
3159
+ const { cache } = ds;
2540
3160
  for (const loc of locations) {
2541
3161
  const classes = splitClasses(loc.value);
2542
3162
  const offending = [];
2543
3163
  for (const cls of classes) {
2544
3164
  if (!hasArbitraryValue(cls)) continue;
2545
3165
  const { utility, variant } = splitUtilityAndVariant(cls);
2546
- const named = cache.getNamedEquivalent(utility);
3166
+ const hasImportantPrefix = utility.startsWith("!");
3167
+ const hasImportantSuffix = !hasImportantPrefix && utility.endsWith("!");
3168
+ const bareUtility = hasImportantPrefix ? utility.slice(1) : hasImportantSuffix ? utility.slice(0, -1) : utility;
3169
+ const named = cache.getNamedEquivalent(bareUtility);
2547
3170
  if (!named) continue;
2548
3171
  offending.push({
2549
3172
  cls,
2550
- replacement: variant + named
3173
+ replacement: variant + (hasImportantPrefix ? "!" : "") + named + (hasImportantSuffix ? "!" : "")
2551
3174
  });
2552
3175
  }
2553
3176
  if (offending.length === 0) continue;
@@ -2607,6 +3230,7 @@ const plugin = (0, _oxlint_plugins.definePlugin)({
2607
3230
  "enforce-sort-order": enforceSortOrder,
2608
3231
  "enforce-shorthand": enforceShorthand,
2609
3232
  "enforce-logical": enforceLogical,
3233
+ "enforce-physical": enforcePhysical,
2610
3234
  "max-class-count": maxClassCount,
2611
3235
  "no-restricted-classes": noRestrictedClasses,
2612
3236
  "no-arbitrary-value": noArbitraryValue,