oxlint-tailwindcss 1.6.0 → 1.7.1

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/README.md CHANGED
@@ -990,6 +990,13 @@ the box. If you find one that doesn't, open an issue.
990
990
  - Tailwind CSS v4
991
991
  - oxlint >= 1.43.0
992
992
 
993
+ > **oxlint 1.77.0 crashes the language server.** Not a plugin bug, but you'll hit it through us:
994
+ > 1.77.0 panics the oxlint **language server** on any diagnostic from any JS plugin
995
+ > (`disable_fix.rs:52`, then SIGABRT and a restart loop). The upstream repro uses a different plugin
996
+ > — [oxc#25278](https://github.com/oxc-project/oxc/issues/25278) — and the fix
997
+ > ([oxc#25280](https://github.com/oxc-project/oxc/pull/25280)) is not released yet. The CLI is
998
+ > unaffected, so CI is fine; if you use the editor extension, pin `oxlint@1.76.0` for now.
999
+
993
1000
  ## License
994
1001
 
995
1002
  MIT
package/dist/index.cjs CHANGED
@@ -3,7 +3,7 @@ let node_crypto = require("node:crypto");
3
3
  let node_fs = require("node:fs");
4
4
  let node_path = require("node:path");
5
5
  let node_os = require("node:os");
6
- //#region ../../node_modules/.pnpm/@oxlint+plugins@1.74.0/node_modules/@oxlint/plugins/index.js
6
+ //#region ../../node_modules/.pnpm/@oxlint+plugins@1.77.0/node_modules/@oxlint/plugins/index.js
7
7
  /**
8
8
  * Define a plugin.
9
9
  *
@@ -960,6 +960,14 @@ function roundRemValue(className) {
960
960
  //#region src/design-system/cache.ts
961
961
  const EMPTY_DECLARATIONS = [];
962
962
  const EMPTY_TOKEN_VALUES = [];
963
+ /** Off-scale numeric value: `w-45`, `min-h-17.5`, `gap-13`. */
964
+ const DYNAMIC_NUMERIC_RE = /^(.+)-\d+\.?\d*$/;
965
+ /**
966
+ * Off-scale percentage: `from-33%`, `via-51%`, `mask-b-from-70%`. The integer is
967
+ * not an accident — Tailwind compiles `from-33%` and does NOT compile
968
+ * `from-33.5%`, so a decimal here would be tolerance with nothing behind it.
969
+ */
970
+ const DYNAMIC_PERCENT_RE = /^(.+)-\d+%$/;
963
971
  var DesignSystemCache = class DesignSystemCache {
964
972
  canonicalMap = /* @__PURE__ */ new Map();
965
973
  deprecatedMap = /* @__PURE__ */ new Map();
@@ -976,7 +984,7 @@ var DesignSystemCache = class DesignSystemCache {
976
984
  variantFactsMap = /* @__PURE__ */ new Map();
977
985
  arbitraryEquivMap = /* @__PURE__ */ new Map();
978
986
  _validClasses = [];
979
- _knownPrefixes = null;
987
+ _prefixSets = null;
980
988
  _maxOrder = 0n;
981
989
  _prefix = "";
982
990
  componentSet = /* @__PURE__ */ new Set();
@@ -1116,15 +1124,56 @@ var DesignSystemCache = class DesignSystemCache {
1116
1124
  if (!this._prefixOrderMap) this._prefixOrderMap = this.buildPrefixOrderMap();
1117
1125
  return this._prefixOrderMap.get(prefix);
1118
1126
  }
1119
- getKnownPrefixes() {
1120
- if (!this._knownPrefixes) {
1121
- this._knownPrefixes = /* @__PURE__ */ new Set();
1127
+ /**
1128
+ * The two prefix sets the off-scale heuristics need, derived in ONE pass over
1129
+ * the ~23 600 valid class names.
1130
+ *
1131
+ * `known` is every dash-bounded prefix. `percent` is the subset that has at
1132
+ * least one enumerated class ending in `%`, and it exists because Tailwind
1133
+ * enumerates only 21 of the 101 percentages it compiles (0, 5, …, 100): a
1134
+ * `from-33%` is as real as a `w-45`, and was reported as a typo of `from-35%`
1135
+ * — a quick-fix that silently moves the gradient stop.
1136
+ *
1137
+ * The narrower set is the point. Accepting `<any known prefix>-N%` would reach
1138
+ * the ~1 780 prefixes Tailwind has, when only 22 take a percentage, and the
1139
+ * directional rules guard their replacements with `isValid` alone (no design
1140
+ * system to refute them), so `ml-33%` → `ms-33%` would start being reported and
1141
+ * autofixed from one dead class to another. Derived rather than listed: it
1142
+ * self-extends when a plugin enumerates percentage classes and self-prunes when
1143
+ * Tailwind stops emitting them.
1144
+ */
1145
+ prefixSets() {
1146
+ if (!this._prefixSets) {
1147
+ const known = /* @__PURE__ */ new Set();
1148
+ const percent = /* @__PURE__ */ new Set();
1122
1149
  for (const cls of this._validClasses) {
1123
1150
  const dash = cls.lastIndexOf("-");
1124
- if (dash > 0) this._knownPrefixes.add(cls.slice(0, dash));
1151
+ if (dash <= 0) continue;
1152
+ const prefix = cls.slice(0, dash);
1153
+ known.add(prefix);
1154
+ if (cls.endsWith("%")) percent.add(prefix);
1125
1155
  }
1156
+ this._prefixSets = {
1157
+ known,
1158
+ percent
1159
+ };
1126
1160
  }
1127
- return this._knownPrefixes;
1161
+ return this._prefixSets;
1162
+ }
1163
+ getKnownPrefixes() {
1164
+ return this.prefixSets().known;
1165
+ }
1166
+ /**
1167
+ * The utility prefix of an off-scale dynamic value, or null when the shape
1168
+ * doesn't match or the prefix doesn't take that kind of value. Shared by
1169
+ * `isValid` and `getOrder` so the two can't drift on what "dynamic" means.
1170
+ */
1171
+ dynamicValuePrefix(bare) {
1172
+ const numeric = DYNAMIC_NUMERIC_RE.exec(bare);
1173
+ if (numeric) return this.getKnownPrefixes().has(numeric[1]) ? numeric[1] : null;
1174
+ const percent = DYNAMIC_PERCENT_RE.exec(bare);
1175
+ if (percent) return this.prefixSets().percent.has(percent[1]) ? percent[1] : null;
1176
+ return null;
1128
1177
  }
1129
1178
  /**
1130
1179
  * Is this class name in the precomputed set VERBATIM?
@@ -1139,6 +1188,38 @@ var DesignSystemCache = class DesignSystemCache {
1139
1188
  isKnownClass(className) {
1140
1189
  return this.validitySet.has(this.stripProjectPrefix(className));
1141
1190
  }
1191
+ /**
1192
+ * Is this a NAMED group/peer marker — `group/menu-item`, `peer/menu-button`?
1193
+ *
1194
+ * A marker binds a variant to one specific ancestor or sibling, and the
1195
+ * consumer's compiled selector hard-codes it as a class selector:
1196
+ * `group-hover/menu-item:underline` emits
1197
+ * `:is(:where(.group\/menu-item):hover *)`. A class selector matches whole
1198
+ * tokens, so bare `group` does not satisfy it — the named marker is required
1199
+ * markup. Tailwind emits no CSS for the marker itself, which is why
1200
+ * `no-unknown-classes` cannot ask "does it compile?" about one.
1201
+ *
1202
+ * Derived, not listed: the base must be a precomputed class that emits ZERO
1203
+ * declarations, which across every fixture resolves to exactly `group` and
1204
+ * `peer` (2 of ~23.6k). It self-prunes if Tailwind drops the variants,
1205
+ * self-extends if a new CSS-less marker appears, and excludes `@container/main`
1206
+ * for free — that one HAS declarations. The component set is subtracted
1207
+ * because a class referenced only through `[class~="…"]` (`not-prose`) also has
1208
+ * no declarations of its own, and `not-prose/x` is not Tailwind syntax.
1209
+ *
1210
+ * The name is user-chosen and Tailwind never checks that it exists, so any
1211
+ * NON-EMPTY name is accepted — including the shapes only an arbitrary modifier
1212
+ * can reach (`group/*`, `group/a/b`, `peer//x`), which is why this splits at
1213
+ * the FIRST slash rather than the last one `isValid` uses. The empty name is
1214
+ * the one genuinely dead spelling: `group-hover/` compiles to nothing.
1215
+ */
1216
+ isMarkerClass(className) {
1217
+ const bare = this.stripProjectPrefix(className);
1218
+ const slash = bare.indexOf("/");
1219
+ if (slash <= 0 || slash === bare.length - 1) return false;
1220
+ const base = bare.slice(0, slash);
1221
+ return this.validitySet.has(base) && !this.componentSet.has(base) && this.getCssDeclarations(base).length === 0;
1222
+ }
1142
1223
  /** Variant names the design system reports, for suggesting a typo's neighbour. */
1143
1224
  variantNames() {
1144
1225
  return [...this.variantOrderMap.keys()];
@@ -1174,13 +1255,10 @@ var DesignSystemCache = class DesignSystemCache {
1174
1255
  if (slashIdx > 0) {
1175
1256
  const base = bare.slice(0, slashIdx);
1176
1257
  if (this.validitySet.has(base)) return true;
1177
- if (/^(.+)-(\d+\.?\d*)$/.test(base)) {
1178
- const dashIdx = base.lastIndexOf("-");
1179
- if (dashIdx > 0 && this.getKnownPrefixes().has(base.slice(0, dashIdx))) return true;
1180
- }
1258
+ const numericBase = DYNAMIC_NUMERIC_RE.exec(base);
1259
+ if (numericBase && this.getKnownPrefixes().has(numericBase[1])) return true;
1181
1260
  }
1182
- const numericMatch = /^(.+)-(\d+\.?\d*)$/.exec(bare);
1183
- if (numericMatch && this.getKnownPrefixes().has(numericMatch[1])) return true;
1261
+ if (this.dynamicValuePrefix(bare) !== null) return true;
1184
1262
  if (hasArbitraryValue(className)) return true;
1185
1263
  if (bare.includes("(") && bare.includes(")")) return true;
1186
1264
  return false;
@@ -1248,9 +1326,8 @@ var DesignSystemCache = class DesignSystemCache {
1248
1326
  }
1249
1327
  }
1250
1328
  if (baseOrder === void 0) {
1251
- const stripped = splitImportant(utility).bare;
1252
- const numericMatch = /^(.+)-(\d+\.?\d*)$/.exec(stripped);
1253
- if (numericMatch && this.getKnownPrefixes().has(numericMatch[1])) baseOrder = this.findOrderByPrefix(numericMatch[1] + "-");
1329
+ const prefix = this.dynamicValuePrefix(splitImportant(utility).bare);
1330
+ if (prefix) baseOrder = this.findOrderByPrefix(prefix + "-");
1254
1331
  }
1255
1332
  if (baseOrder === void 0) return null;
1256
1333
  if (!hasVariant) return baseOrder;
@@ -1860,31 +1937,68 @@ function collectCssSources(cssPath, baseDir) {
1860
1937
  return files;
1861
1938
  }
1862
1939
 
1940
+ // Class names the project writes in its own CSS, read from the SELECTORS only.
1941
+ //
1942
+ // This used to scan whole files with two regexes, which harvested identifiers
1943
+ // from places that are not selectors at all: the URLs in Tailwind's own preflight
1944
+ // comments (\`developer.mozilla.org\` → \`mozilla\`, \`org\`; \`bugs.chromium.org\`;
1945
+ // \`-webkit-\`) and the decimals in declaration values (\`padding: 0.5rem\` →
1946
+ // \`5rem\`). Everything here reaches \`validitySet\`, so every project accepted
1947
+ // \`com\`, \`org\`, \`css\` and \`5rem\` as valid Tailwind classes.
1948
+ //
1949
+ // A selector is the text between the last \`{\`, \`}\` or \`;\` and the next \`{\`, so
1950
+ // scanning only what precedes a \`{\` skips declaration bodies by construction —
1951
+ // a declaration ends in \`;\` or \`}\` and never reaches one. Comments and strings
1952
+ // are stepped over. Requiring a CSS identifier start (never a digit) is the
1953
+ // second line of defence, for a decimal inside an at-rule prelude
1954
+ // (\`@media (min-width: 40.5rem)\`).
1863
1955
  function extractComponentClasses(cssPath, baseDir) {
1864
1956
  const files = collectCssSources(cssPath, baseDir);
1865
- const result = [];
1957
+ const result = new Set();
1958
+ const classRe = /\\.(-?[a-zA-Z_][\\w-]*)/g;
1866
1959
  for (const content of files) {
1867
- // Scan both @layer components AND @layer utilities
1868
- const layerRe = /@layer\\s+(?:components|utilities)\\s*\\{/g;
1869
- let lm;
1870
- while ((lm = layerRe.exec(content)) !== null) {
1871
- let depth = 1, i = lm.index + lm[0].length;
1872
- while (i < content.length && depth > 0) {
1873
- if (content[i] === '{') depth++;
1874
- if (content[i] === '}') depth--;
1960
+ let prelude = '';
1961
+ for (let i = 0; i < content.length; i++) {
1962
+ const c = content[i];
1963
+ if (c === '/' && content[i + 1] === '*') {
1964
+ const end = content.indexOf('*/', i + 2);
1965
+ i = end === -1 ? content.length : end + 1;
1966
+ continue;
1967
+ }
1968
+ if (c === '"' || c === "'") {
1969
+ const quote = c;
1875
1970
  i++;
1971
+ while (i < content.length && content[i] !== quote) {
1972
+ if (content[i] === '\\\\') i++;
1973
+ i++;
1974
+ }
1975
+ continue;
1876
1976
  }
1877
- const block = content.slice(lm.index + lm[0].length, i - 1);
1878
- const selRe = /\\.([\\w-]+)/g;
1879
- let sm;
1880
- while ((sm = selRe.exec(block)) !== null) result.push(sm[1]);
1977
+ if (c === '{') {
1978
+ classRe.lastIndex = 0;
1979
+ let m;
1980
+ while ((m = classRe.exec(prelude)) !== null) result.add(m[1]);
1981
+ prelude = '';
1982
+ continue;
1983
+ }
1984
+ if (c === '}' || c === ';') {
1985
+ // A statement at-rule carries a selector even though it has no block:
1986
+ // \`@custom-variant sidebar-open (&:where(.sidebar-open *));\` makes that
1987
+ // class load-bearing exactly the way \`group\`/\`peer\` are, so it has to
1988
+ // stay valid. Plain declarations never start with \`@\`, so this readmits
1989
+ // the selector without readmitting \`padding: 0.5rem\`.
1990
+ if (c === ';' && prelude.trimStart().charCodeAt(0) === 64) {
1991
+ classRe.lastIndex = 0;
1992
+ let m;
1993
+ while ((m = classRe.exec(prelude)) !== null) result.add(m[1]);
1994
+ }
1995
+ prelude = '';
1996
+ continue;
1997
+ }
1998
+ prelude += c;
1881
1999
  }
1882
- // Scan all class selectors anywhere in the file (.class-name)
1883
- const classSelRe = /\\.([a-zA-Z_][\\w-]*)/g;
1884
- let cs;
1885
- while ((cs = classSelRe.exec(content)) !== null) result.push(cs[1]);
1886
2000
  }
1887
- return [...new Set(result)];
2001
+ return [...result];
1888
2002
  }
1889
2003
 
1890
2004
  ${DECL_EXTRACTOR_SOURCE}
@@ -2289,11 +2403,13 @@ async function main() {
2289
2403
  }
2290
2404
 
2291
2405
  // Component classes from @layer components
2292
- const componentClasses = extractComponentClasses(cssPath, base);
2406
+ const componentSet = new Set(extractComponentClasses(cssPath, base));
2293
2407
 
2294
2408
  // Extract class names from attribute selectors [class~="..."] in CSS output.
2295
2409
  // Plugins like @tailwindcss/typography use these for modifier classes (e.g. "not-prose")
2296
2410
  // that don't generate their own CSS but are referenced in other classes' selectors.
2411
+ // Interned in a Set: typography references \`not-prose\` from ~230 selectors, and
2412
+ // pushing one entry per occurrence only inflated the cache artifact.
2297
2413
  const attrClassRe = /\\[class~="([^"]+)"\\]/g;
2298
2414
  for (let i = 0; i < cssResults.length; i++) {
2299
2415
  if (cssResults[i]) {
@@ -2301,10 +2417,11 @@ async function main() {
2301
2417
  attrClassRe.lastIndex = 0;
2302
2418
  while ((acm = attrClassRe.exec(cssResults[i])) !== null) {
2303
2419
  // Typography-style plugins emit \`[class~="tw:not-prose"]\` under a prefix.
2304
- componentClasses.push(unpfx(acm[1]));
2420
+ componentSet.add(unpfx(acm[1]));
2305
2421
  }
2306
2422
  }
2307
2423
  }
2424
+ const componentClasses = [...componentSet];
2308
2425
 
2309
2426
  // Arbitrary equivalents: map arbitrary forms to named equivalents.
2310
2427
  // Enumerate every dash split point so multi-segment utilities (e.g.
@@ -3609,6 +3726,7 @@ const noUnknownClasses = defineRule({
3609
3726
  if (shouldIgnore(cls)) continue;
3610
3727
  const bare = strippedUtility(cls).bare;
3611
3728
  if (cache.isKnownClass(bare)) continue;
3729
+ if (cache.isMarkerClass(bare)) continue;
3612
3730
  if (!toVerify) toVerify = [];
3613
3731
  toVerify.push(bare);
3614
3732
  }
@@ -3619,7 +3737,12 @@ const noUnknownClasses = defineRule({
3619
3737
  const { variant, bare, position } = strippedUtility(cls);
3620
3738
  if (validity === "valid" && !variant && cache.isKnownClass(bare)) continue;
3621
3739
  if (cache.deprecatedReplacement(bare)) continue;
3622
- if (validity === "missing-prefix") {
3740
+ const compiles = cache.isKnownClass(bare) ? true : verified?.get(bare);
3741
+ const prefixWritten = !cache.prefix || variant.startsWith(`${cache.prefix}:`);
3742
+ let effectiveValidity = validity;
3743
+ if (validity === "unknown" && compiles === true) effectiveValidity = prefixWritten ? "valid" : "missing-prefix";
3744
+ else if (validity === "missing-prefix" && compiles === false) effectiveValidity = "unknown";
3745
+ if (effectiveValidity === "missing-prefix") {
3623
3746
  const fixed = `${cache.prefix}:${cls}`;
3624
3747
  reportWithSuggestion(loc, classes, cls, fixed, "missingPrefix", {
3625
3748
  className: cls,
@@ -3628,8 +3751,17 @@ const noUnknownClasses = defineRule({
3628
3751
  }, split);
3629
3752
  continue;
3630
3753
  }
3631
- const compiles = cache.isKnownClass(bare) ? true : verified?.get(bare);
3632
- if (validity === "unknown" || compiles === false) {
3754
+ if (cache.isMarkerClass(bare)) {
3755
+ if (prefixWritten) continue;
3756
+ const fixed = `${cache.prefix}:${cls}`;
3757
+ reportWithSuggestion(loc, classes, cls, fixed, "missingPrefix", {
3758
+ className: cls,
3759
+ prefix: cache.prefix,
3760
+ suggestion: fixed
3761
+ }, split);
3762
+ continue;
3763
+ }
3764
+ if (effectiveValidity === "unknown" || compiles === false) {
3633
3765
  const suggestionBare = findBestSuggestion(bare, cache.validClasses);
3634
3766
  const suggestion = suggestionBare ? variant + reattachImportant(suggestionBare, position) : null;
3635
3767
  if (suggestion) reportWithSuggestion(loc, classes, cls, suggestion, "unknownWithSuggestion", {
package/dist/index.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- //#region ../../node_modules/.pnpm/@oxlint+plugins@1.74.0/node_modules/@oxlint/plugins/index.d.ts
1
+ //#region ../../node_modules/.pnpm/@oxlint+plugins@1.77.0/node_modules/@oxlint/plugins/index.d.ts
2
2
  //#endregion
3
3
  //#region src-js/plugins/tokens.d.ts
4
4
  /**
@@ -485,7 +485,7 @@ interface Program extends Span {
485
485
  tokens: TokenType[];
486
486
  parent: null;
487
487
  }
488
- type Expression = BooleanLiteral | NullLiteral | NumericLiteral | BigIntLiteral | RegExpLiteral | StringLiteral | TemplateLiteral | IdentifierReference | MetaProperty | Super | ArrayExpression | ArrowFunctionExpression | AssignmentExpression | AwaitExpression | BinaryExpression | CallExpression | ChainExpression | Class | ConditionalExpression | Function$1 | ImportExpression | LogicalExpression | NewExpression | ObjectExpression | ParenthesizedExpression | SequenceExpression | TaggedTemplateExpression | ThisExpression | UnaryExpression | UpdateExpression | YieldExpression | PrivateInExpression | JSXElement | JSXFragment | TSAsExpression | TSSatisfiesExpression | TSTypeAssertion | TSNonNullExpression | TSInstantiationExpression | V8IntrinsicExpression | MemberExpression;
488
+ type Expression = BooleanLiteral | NullLiteral | NumericLiteral | BigIntLiteral | RegExpLiteral | StringLiteral | TemplateLiteral | IdentifierReference | Super | ArrayExpression | ArrowFunctionExpression | AssignmentExpression | AwaitExpression | BinaryExpression | CallExpression | ChainExpression | Class | ConditionalExpression | Function$1 | ImportExpression | LogicalExpression | NewExpression | ObjectExpression | ParenthesizedExpression | SequenceExpression | TaggedTemplateExpression | ThisExpression | UnaryExpression | UpdateExpression | YieldExpression | PrivateInExpression | MetaProperty | JSXElement | JSXFragment | TSAsExpression | TSSatisfiesExpression | TSTypeAssertion | TSNonNullExpression | TSInstantiationExpression | V8IntrinsicExpression | MemberExpression;
489
489
  interface IdentifierName extends Span {
490
490
  type: "Identifier";
491
491
  decorators?: [];
@@ -2179,7 +2179,7 @@ interface Directive {
2179
2179
  type: DirectiveType;
2180
2180
  node: CommentType;
2181
2181
  value: string;
2182
- justification?: string;
2182
+ justification: string;
2183
2183
  }
2184
2184
  declare function getDisableDirectives(): {
2185
2185
  problems: Problem[];
package/dist/index.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- //#region ../../node_modules/.pnpm/@oxlint+plugins@1.74.0/node_modules/@oxlint/plugins/index.d.ts
1
+ //#region ../../node_modules/.pnpm/@oxlint+plugins@1.77.0/node_modules/@oxlint/plugins/index.d.ts
2
2
  //#endregion
3
3
  //#region src-js/plugins/tokens.d.ts
4
4
  /**
@@ -485,7 +485,7 @@ interface Program extends Span {
485
485
  tokens: TokenType[];
486
486
  parent: null;
487
487
  }
488
- type Expression = BooleanLiteral | NullLiteral | NumericLiteral | BigIntLiteral | RegExpLiteral | StringLiteral | TemplateLiteral | IdentifierReference | MetaProperty | Super | ArrayExpression | ArrowFunctionExpression | AssignmentExpression | AwaitExpression | BinaryExpression | CallExpression | ChainExpression | Class | ConditionalExpression | Function$1 | ImportExpression | LogicalExpression | NewExpression | ObjectExpression | ParenthesizedExpression | SequenceExpression | TaggedTemplateExpression | ThisExpression | UnaryExpression | UpdateExpression | YieldExpression | PrivateInExpression | JSXElement | JSXFragment | TSAsExpression | TSSatisfiesExpression | TSTypeAssertion | TSNonNullExpression | TSInstantiationExpression | V8IntrinsicExpression | MemberExpression;
488
+ type Expression = BooleanLiteral | NullLiteral | NumericLiteral | BigIntLiteral | RegExpLiteral | StringLiteral | TemplateLiteral | IdentifierReference | Super | ArrayExpression | ArrowFunctionExpression | AssignmentExpression | AwaitExpression | BinaryExpression | CallExpression | ChainExpression | Class | ConditionalExpression | Function$1 | ImportExpression | LogicalExpression | NewExpression | ObjectExpression | ParenthesizedExpression | SequenceExpression | TaggedTemplateExpression | ThisExpression | UnaryExpression | UpdateExpression | YieldExpression | PrivateInExpression | MetaProperty | JSXElement | JSXFragment | TSAsExpression | TSSatisfiesExpression | TSTypeAssertion | TSNonNullExpression | TSInstantiationExpression | V8IntrinsicExpression | MemberExpression;
489
489
  interface IdentifierName extends Span {
490
490
  type: "Identifier";
491
491
  decorators?: [];
@@ -2179,7 +2179,7 @@ interface Directive {
2179
2179
  type: DirectiveType;
2180
2180
  node: CommentType;
2181
2181
  value: string;
2182
- justification?: string;
2182
+ justification: string;
2183
2183
  }
2184
2184
  declare function getDisableDirectives(): {
2185
2185
  problems: Problem[];
package/dist/index.mjs CHANGED
@@ -7,7 +7,7 @@ import { tmpdir, userInfo } from "node:os";
7
7
  //#region \0rolldown/runtime.js
8
8
  var __require = /* #__PURE__ */ (() => createRequire(import.meta.url))();
9
9
  //#endregion
10
- //#region ../../node_modules/.pnpm/@oxlint+plugins@1.74.0/node_modules/@oxlint/plugins/index.js
10
+ //#region ../../node_modules/.pnpm/@oxlint+plugins@1.77.0/node_modules/@oxlint/plugins/index.js
11
11
  /**
12
12
  * Define a plugin.
13
13
  *
@@ -964,6 +964,14 @@ function roundRemValue(className) {
964
964
  //#region src/design-system/cache.ts
965
965
  const EMPTY_DECLARATIONS = [];
966
966
  const EMPTY_TOKEN_VALUES = [];
967
+ /** Off-scale numeric value: `w-45`, `min-h-17.5`, `gap-13`. */
968
+ const DYNAMIC_NUMERIC_RE = /^(.+)-\d+\.?\d*$/;
969
+ /**
970
+ * Off-scale percentage: `from-33%`, `via-51%`, `mask-b-from-70%`. The integer is
971
+ * not an accident — Tailwind compiles `from-33%` and does NOT compile
972
+ * `from-33.5%`, so a decimal here would be tolerance with nothing behind it.
973
+ */
974
+ const DYNAMIC_PERCENT_RE = /^(.+)-\d+%$/;
967
975
  var DesignSystemCache = class DesignSystemCache {
968
976
  canonicalMap = /* @__PURE__ */ new Map();
969
977
  deprecatedMap = /* @__PURE__ */ new Map();
@@ -980,7 +988,7 @@ var DesignSystemCache = class DesignSystemCache {
980
988
  variantFactsMap = /* @__PURE__ */ new Map();
981
989
  arbitraryEquivMap = /* @__PURE__ */ new Map();
982
990
  _validClasses = [];
983
- _knownPrefixes = null;
991
+ _prefixSets = null;
984
992
  _maxOrder = 0n;
985
993
  _prefix = "";
986
994
  componentSet = /* @__PURE__ */ new Set();
@@ -1120,15 +1128,56 @@ var DesignSystemCache = class DesignSystemCache {
1120
1128
  if (!this._prefixOrderMap) this._prefixOrderMap = this.buildPrefixOrderMap();
1121
1129
  return this._prefixOrderMap.get(prefix);
1122
1130
  }
1123
- getKnownPrefixes() {
1124
- if (!this._knownPrefixes) {
1125
- this._knownPrefixes = /* @__PURE__ */ new Set();
1131
+ /**
1132
+ * The two prefix sets the off-scale heuristics need, derived in ONE pass over
1133
+ * the ~23 600 valid class names.
1134
+ *
1135
+ * `known` is every dash-bounded prefix. `percent` is the subset that has at
1136
+ * least one enumerated class ending in `%`, and it exists because Tailwind
1137
+ * enumerates only 21 of the 101 percentages it compiles (0, 5, …, 100): a
1138
+ * `from-33%` is as real as a `w-45`, and was reported as a typo of `from-35%`
1139
+ * — a quick-fix that silently moves the gradient stop.
1140
+ *
1141
+ * The narrower set is the point. Accepting `<any known prefix>-N%` would reach
1142
+ * the ~1 780 prefixes Tailwind has, when only 22 take a percentage, and the
1143
+ * directional rules guard their replacements with `isValid` alone (no design
1144
+ * system to refute them), so `ml-33%` → `ms-33%` would start being reported and
1145
+ * autofixed from one dead class to another. Derived rather than listed: it
1146
+ * self-extends when a plugin enumerates percentage classes and self-prunes when
1147
+ * Tailwind stops emitting them.
1148
+ */
1149
+ prefixSets() {
1150
+ if (!this._prefixSets) {
1151
+ const known = /* @__PURE__ */ new Set();
1152
+ const percent = /* @__PURE__ */ new Set();
1126
1153
  for (const cls of this._validClasses) {
1127
1154
  const dash = cls.lastIndexOf("-");
1128
- if (dash > 0) this._knownPrefixes.add(cls.slice(0, dash));
1155
+ if (dash <= 0) continue;
1156
+ const prefix = cls.slice(0, dash);
1157
+ known.add(prefix);
1158
+ if (cls.endsWith("%")) percent.add(prefix);
1129
1159
  }
1160
+ this._prefixSets = {
1161
+ known,
1162
+ percent
1163
+ };
1130
1164
  }
1131
- return this._knownPrefixes;
1165
+ return this._prefixSets;
1166
+ }
1167
+ getKnownPrefixes() {
1168
+ return this.prefixSets().known;
1169
+ }
1170
+ /**
1171
+ * The utility prefix of an off-scale dynamic value, or null when the shape
1172
+ * doesn't match or the prefix doesn't take that kind of value. Shared by
1173
+ * `isValid` and `getOrder` so the two can't drift on what "dynamic" means.
1174
+ */
1175
+ dynamicValuePrefix(bare) {
1176
+ const numeric = DYNAMIC_NUMERIC_RE.exec(bare);
1177
+ if (numeric) return this.getKnownPrefixes().has(numeric[1]) ? numeric[1] : null;
1178
+ const percent = DYNAMIC_PERCENT_RE.exec(bare);
1179
+ if (percent) return this.prefixSets().percent.has(percent[1]) ? percent[1] : null;
1180
+ return null;
1132
1181
  }
1133
1182
  /**
1134
1183
  * Is this class name in the precomputed set VERBATIM?
@@ -1143,6 +1192,38 @@ var DesignSystemCache = class DesignSystemCache {
1143
1192
  isKnownClass(className) {
1144
1193
  return this.validitySet.has(this.stripProjectPrefix(className));
1145
1194
  }
1195
+ /**
1196
+ * Is this a NAMED group/peer marker — `group/menu-item`, `peer/menu-button`?
1197
+ *
1198
+ * A marker binds a variant to one specific ancestor or sibling, and the
1199
+ * consumer's compiled selector hard-codes it as a class selector:
1200
+ * `group-hover/menu-item:underline` emits
1201
+ * `:is(:where(.group\/menu-item):hover *)`. A class selector matches whole
1202
+ * tokens, so bare `group` does not satisfy it — the named marker is required
1203
+ * markup. Tailwind emits no CSS for the marker itself, which is why
1204
+ * `no-unknown-classes` cannot ask "does it compile?" about one.
1205
+ *
1206
+ * Derived, not listed: the base must be a precomputed class that emits ZERO
1207
+ * declarations, which across every fixture resolves to exactly `group` and
1208
+ * `peer` (2 of ~23.6k). It self-prunes if Tailwind drops the variants,
1209
+ * self-extends if a new CSS-less marker appears, and excludes `@container/main`
1210
+ * for free — that one HAS declarations. The component set is subtracted
1211
+ * because a class referenced only through `[class~="…"]` (`not-prose`) also has
1212
+ * no declarations of its own, and `not-prose/x` is not Tailwind syntax.
1213
+ *
1214
+ * The name is user-chosen and Tailwind never checks that it exists, so any
1215
+ * NON-EMPTY name is accepted — including the shapes only an arbitrary modifier
1216
+ * can reach (`group/*`, `group/a/b`, `peer//x`), which is why this splits at
1217
+ * the FIRST slash rather than the last one `isValid` uses. The empty name is
1218
+ * the one genuinely dead spelling: `group-hover/` compiles to nothing.
1219
+ */
1220
+ isMarkerClass(className) {
1221
+ const bare = this.stripProjectPrefix(className);
1222
+ const slash = bare.indexOf("/");
1223
+ if (slash <= 0 || slash === bare.length - 1) return false;
1224
+ const base = bare.slice(0, slash);
1225
+ return this.validitySet.has(base) && !this.componentSet.has(base) && this.getCssDeclarations(base).length === 0;
1226
+ }
1146
1227
  /** Variant names the design system reports, for suggesting a typo's neighbour. */
1147
1228
  variantNames() {
1148
1229
  return [...this.variantOrderMap.keys()];
@@ -1178,13 +1259,10 @@ var DesignSystemCache = class DesignSystemCache {
1178
1259
  if (slashIdx > 0) {
1179
1260
  const base = bare.slice(0, slashIdx);
1180
1261
  if (this.validitySet.has(base)) return true;
1181
- if (/^(.+)-(\d+\.?\d*)$/.test(base)) {
1182
- const dashIdx = base.lastIndexOf("-");
1183
- if (dashIdx > 0 && this.getKnownPrefixes().has(base.slice(0, dashIdx))) return true;
1184
- }
1262
+ const numericBase = DYNAMIC_NUMERIC_RE.exec(base);
1263
+ if (numericBase && this.getKnownPrefixes().has(numericBase[1])) return true;
1185
1264
  }
1186
- const numericMatch = /^(.+)-(\d+\.?\d*)$/.exec(bare);
1187
- if (numericMatch && this.getKnownPrefixes().has(numericMatch[1])) return true;
1265
+ if (this.dynamicValuePrefix(bare) !== null) return true;
1188
1266
  if (hasArbitraryValue(className)) return true;
1189
1267
  if (bare.includes("(") && bare.includes(")")) return true;
1190
1268
  return false;
@@ -1252,9 +1330,8 @@ var DesignSystemCache = class DesignSystemCache {
1252
1330
  }
1253
1331
  }
1254
1332
  if (baseOrder === void 0) {
1255
- const stripped = splitImportant(utility).bare;
1256
- const numericMatch = /^(.+)-(\d+\.?\d*)$/.exec(stripped);
1257
- if (numericMatch && this.getKnownPrefixes().has(numericMatch[1])) baseOrder = this.findOrderByPrefix(numericMatch[1] + "-");
1333
+ const prefix = this.dynamicValuePrefix(splitImportant(utility).bare);
1334
+ if (prefix) baseOrder = this.findOrderByPrefix(prefix + "-");
1258
1335
  }
1259
1336
  if (baseOrder === void 0) return null;
1260
1337
  if (!hasVariant) return baseOrder;
@@ -1864,31 +1941,68 @@ function collectCssSources(cssPath, baseDir) {
1864
1941
  return files;
1865
1942
  }
1866
1943
 
1944
+ // Class names the project writes in its own CSS, read from the SELECTORS only.
1945
+ //
1946
+ // This used to scan whole files with two regexes, which harvested identifiers
1947
+ // from places that are not selectors at all: the URLs in Tailwind's own preflight
1948
+ // comments (\`developer.mozilla.org\` → \`mozilla\`, \`org\`; \`bugs.chromium.org\`;
1949
+ // \`-webkit-\`) and the decimals in declaration values (\`padding: 0.5rem\` →
1950
+ // \`5rem\`). Everything here reaches \`validitySet\`, so every project accepted
1951
+ // \`com\`, \`org\`, \`css\` and \`5rem\` as valid Tailwind classes.
1952
+ //
1953
+ // A selector is the text between the last \`{\`, \`}\` or \`;\` and the next \`{\`, so
1954
+ // scanning only what precedes a \`{\` skips declaration bodies by construction —
1955
+ // a declaration ends in \`;\` or \`}\` and never reaches one. Comments and strings
1956
+ // are stepped over. Requiring a CSS identifier start (never a digit) is the
1957
+ // second line of defence, for a decimal inside an at-rule prelude
1958
+ // (\`@media (min-width: 40.5rem)\`).
1867
1959
  function extractComponentClasses(cssPath, baseDir) {
1868
1960
  const files = collectCssSources(cssPath, baseDir);
1869
- const result = [];
1961
+ const result = new Set();
1962
+ const classRe = /\\.(-?[a-zA-Z_][\\w-]*)/g;
1870
1963
  for (const content of files) {
1871
- // Scan both @layer components AND @layer utilities
1872
- const layerRe = /@layer\\s+(?:components|utilities)\\s*\\{/g;
1873
- let lm;
1874
- while ((lm = layerRe.exec(content)) !== null) {
1875
- let depth = 1, i = lm.index + lm[0].length;
1876
- while (i < content.length && depth > 0) {
1877
- if (content[i] === '{') depth++;
1878
- if (content[i] === '}') depth--;
1964
+ let prelude = '';
1965
+ for (let i = 0; i < content.length; i++) {
1966
+ const c = content[i];
1967
+ if (c === '/' && content[i + 1] === '*') {
1968
+ const end = content.indexOf('*/', i + 2);
1969
+ i = end === -1 ? content.length : end + 1;
1970
+ continue;
1971
+ }
1972
+ if (c === '"' || c === "'") {
1973
+ const quote = c;
1879
1974
  i++;
1975
+ while (i < content.length && content[i] !== quote) {
1976
+ if (content[i] === '\\\\') i++;
1977
+ i++;
1978
+ }
1979
+ continue;
1880
1980
  }
1881
- const block = content.slice(lm.index + lm[0].length, i - 1);
1882
- const selRe = /\\.([\\w-]+)/g;
1883
- let sm;
1884
- while ((sm = selRe.exec(block)) !== null) result.push(sm[1]);
1981
+ if (c === '{') {
1982
+ classRe.lastIndex = 0;
1983
+ let m;
1984
+ while ((m = classRe.exec(prelude)) !== null) result.add(m[1]);
1985
+ prelude = '';
1986
+ continue;
1987
+ }
1988
+ if (c === '}' || c === ';') {
1989
+ // A statement at-rule carries a selector even though it has no block:
1990
+ // \`@custom-variant sidebar-open (&:where(.sidebar-open *));\` makes that
1991
+ // class load-bearing exactly the way \`group\`/\`peer\` are, so it has to
1992
+ // stay valid. Plain declarations never start with \`@\`, so this readmits
1993
+ // the selector without readmitting \`padding: 0.5rem\`.
1994
+ if (c === ';' && prelude.trimStart().charCodeAt(0) === 64) {
1995
+ classRe.lastIndex = 0;
1996
+ let m;
1997
+ while ((m = classRe.exec(prelude)) !== null) result.add(m[1]);
1998
+ }
1999
+ prelude = '';
2000
+ continue;
2001
+ }
2002
+ prelude += c;
1885
2003
  }
1886
- // Scan all class selectors anywhere in the file (.class-name)
1887
- const classSelRe = /\\.([a-zA-Z_][\\w-]*)/g;
1888
- let cs;
1889
- while ((cs = classSelRe.exec(content)) !== null) result.push(cs[1]);
1890
2004
  }
1891
- return [...new Set(result)];
2005
+ return [...result];
1892
2006
  }
1893
2007
 
1894
2008
  ${DECL_EXTRACTOR_SOURCE}
@@ -2293,11 +2407,13 @@ async function main() {
2293
2407
  }
2294
2408
 
2295
2409
  // Component classes from @layer components
2296
- const componentClasses = extractComponentClasses(cssPath, base);
2410
+ const componentSet = new Set(extractComponentClasses(cssPath, base));
2297
2411
 
2298
2412
  // Extract class names from attribute selectors [class~="..."] in CSS output.
2299
2413
  // Plugins like @tailwindcss/typography use these for modifier classes (e.g. "not-prose")
2300
2414
  // that don't generate their own CSS but are referenced in other classes' selectors.
2415
+ // Interned in a Set: typography references \`not-prose\` from ~230 selectors, and
2416
+ // pushing one entry per occurrence only inflated the cache artifact.
2301
2417
  const attrClassRe = /\\[class~="([^"]+)"\\]/g;
2302
2418
  for (let i = 0; i < cssResults.length; i++) {
2303
2419
  if (cssResults[i]) {
@@ -2305,10 +2421,11 @@ async function main() {
2305
2421
  attrClassRe.lastIndex = 0;
2306
2422
  while ((acm = attrClassRe.exec(cssResults[i])) !== null) {
2307
2423
  // Typography-style plugins emit \`[class~="tw:not-prose"]\` under a prefix.
2308
- componentClasses.push(unpfx(acm[1]));
2424
+ componentSet.add(unpfx(acm[1]));
2309
2425
  }
2310
2426
  }
2311
2427
  }
2428
+ const componentClasses = [...componentSet];
2312
2429
 
2313
2430
  // Arbitrary equivalents: map arbitrary forms to named equivalents.
2314
2431
  // Enumerate every dash split point so multi-segment utilities (e.g.
@@ -3613,6 +3730,7 @@ const noUnknownClasses = defineRule({
3613
3730
  if (shouldIgnore(cls)) continue;
3614
3731
  const bare = strippedUtility(cls).bare;
3615
3732
  if (cache.isKnownClass(bare)) continue;
3733
+ if (cache.isMarkerClass(bare)) continue;
3616
3734
  if (!toVerify) toVerify = [];
3617
3735
  toVerify.push(bare);
3618
3736
  }
@@ -3623,7 +3741,12 @@ const noUnknownClasses = defineRule({
3623
3741
  const { variant, bare, position } = strippedUtility(cls);
3624
3742
  if (validity === "valid" && !variant && cache.isKnownClass(bare)) continue;
3625
3743
  if (cache.deprecatedReplacement(bare)) continue;
3626
- if (validity === "missing-prefix") {
3744
+ const compiles = cache.isKnownClass(bare) ? true : verified?.get(bare);
3745
+ const prefixWritten = !cache.prefix || variant.startsWith(`${cache.prefix}:`);
3746
+ let effectiveValidity = validity;
3747
+ if (validity === "unknown" && compiles === true) effectiveValidity = prefixWritten ? "valid" : "missing-prefix";
3748
+ else if (validity === "missing-prefix" && compiles === false) effectiveValidity = "unknown";
3749
+ if (effectiveValidity === "missing-prefix") {
3627
3750
  const fixed = `${cache.prefix}:${cls}`;
3628
3751
  reportWithSuggestion(loc, classes, cls, fixed, "missingPrefix", {
3629
3752
  className: cls,
@@ -3632,8 +3755,17 @@ const noUnknownClasses = defineRule({
3632
3755
  }, split);
3633
3756
  continue;
3634
3757
  }
3635
- const compiles = cache.isKnownClass(bare) ? true : verified?.get(bare);
3636
- if (validity === "unknown" || compiles === false) {
3758
+ if (cache.isMarkerClass(bare)) {
3759
+ if (prefixWritten) continue;
3760
+ const fixed = `${cache.prefix}:${cls}`;
3761
+ reportWithSuggestion(loc, classes, cls, fixed, "missingPrefix", {
3762
+ className: cls,
3763
+ prefix: cache.prefix,
3764
+ suggestion: fixed
3765
+ }, split);
3766
+ continue;
3767
+ }
3768
+ if (effectiveValidity === "unknown" || compiles === false) {
3637
3769
  const suggestionBare = findBestSuggestion(bare, cache.validClasses);
3638
3770
  const suggestion = suggestionBare ? variant + reattachImportant(suggestionBare, position) : null;
3639
3771
  if (suggestion) reportWithSuggestion(loc, classes, cls, suggestion, "unknownWithSuggestion", {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "oxlint-tailwindcss",
3
- "version": "1.6.0",
3
+ "version": "1.7.1",
4
4
  "description": "Tailwind CSS linting rules for oxlint",
5
5
  "keywords": [
6
6
  "css",
@@ -57,10 +57,10 @@
57
57
  "devDependencies": {
58
58
  "@oxlint/plugins": "catalog:",
59
59
  "@tailwindcss/typography": "^0.5.20",
60
- "@types/node": "^26.1.1",
60
+ "@types/node": "^26.1.2",
61
61
  "oxlint": "catalog:",
62
62
  "tailwindcss-animate": "^1.0.7",
63
- "tsdown": "^0.22.12",
63
+ "tsdown": "^0.22.14",
64
64
  "tw-animate-css": "^1.4.0",
65
65
  "typescript": "^7.0.2",
66
66
  "vitest": "^4.1.10"