oxlint-tailwindcss 1.14.0 → 1.15.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/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.85.0/node_modules/@oxlint/plugins/index.js
10
+ //#region ../../node_modules/.pnpm/@oxlint+plugins@1.87.0/node_modules/@oxlint/plugins/index.js
11
11
  /**
12
12
  * Define a plugin.
13
13
  *
@@ -251,6 +251,124 @@ function settingsKey(settings) {
251
251
  return JSON.stringify(settings?.tailwindcss) ?? "";
252
252
  }
253
253
  //#endregion
254
+ //#region src/utils/css-properties.ts
255
+ /**
256
+ * CSS property names (standard, SVG and `-ms-`), from csstype's `*PropertiesHyphen`
257
+ * interfaces, minus the 15 that are also Tailwind classes (`flex`, `grid`, `border`,
258
+ * `container`, `transition`, …). A test holds that no name here is a class.
259
+ *
260
+ * An object key with one of these names is a style declaration, never a class:
261
+ * Solid, Vue, Qwik and Lit's `styleMap` take kebab-case keys, which the default
262
+ * `^styles?$` variable pattern reaches (`const style = { 'background-color': c }`).
263
+ * `-webkit-` / `-moz-` keys are matched by prefix instead; `-ms-` only by name,
264
+ * since `-ms-4` is a negative margin.
265
+ */
266
+ const CSS_PROPERTY_NAMES = new Set(`
267
+ -ms-accelerator -ms-block-progression -ms-content-zoom-chaining -ms-content-zoom-limit
268
+ -ms-content-zoom-limit-max -ms-content-zoom-limit-min -ms-content-zoom-snap
269
+ -ms-content-zoom-snap-points -ms-content-zoom-snap-type -ms-content-zooming -ms-filter -ms-flex
270
+ -ms-flex-direction -ms-flex-positive -ms-flow-from -ms-flow-into -ms-grid-columns -ms-grid-rows
271
+ -ms-high-contrast-adjust -ms-hyphenate-limit-chars -ms-hyphenate-limit-lines
272
+ -ms-hyphenate-limit-zone -ms-hyphens -ms-ime-align -ms-line-break -ms-order -ms-overflow-style
273
+ -ms-overflow-x -ms-overflow-y -ms-scroll-chaining -ms-scroll-limit -ms-scroll-limit-x-max
274
+ -ms-scroll-limit-x-min -ms-scroll-limit-y-max -ms-scroll-limit-y-min -ms-scroll-rails
275
+ -ms-scroll-snap-points-x -ms-scroll-snap-points-y -ms-scroll-snap-type -ms-scroll-snap-x
276
+ -ms-scroll-snap-y -ms-scroll-translation -ms-scrollbar-arrow-color -ms-scrollbar-base-color
277
+ -ms-scrollbar-darkshadow-color -ms-scrollbar-face-color -ms-scrollbar-highlight-color
278
+ -ms-scrollbar-shadow-color -ms-scrollbar-track-color -ms-text-autospace
279
+ -ms-text-combine-horizontal -ms-text-overflow -ms-touch-action -ms-touch-select -ms-transform
280
+ -ms-transform-origin -ms-transition -ms-transition-delay -ms-transition-duration
281
+ -ms-transition-property -ms-transition-timing-function -ms-user-select -ms-word-break
282
+ -ms-wrap-flow -ms-wrap-margin -ms-wrap-through -ms-writing-mode accent-color align-content
283
+ align-items align-self align-tracks alignment-baseline all anchor-name anchor-scope animation
284
+ animation-composition animation-delay animation-direction animation-duration
285
+ animation-fill-mode animation-iteration-count animation-name animation-play-state
286
+ animation-range animation-range-end animation-range-start animation-timeline
287
+ animation-timing-function appearance aspect-ratio backdrop-filter backface-visibility
288
+ background background-attachment background-blend-mode background-clip background-color
289
+ background-image background-origin background-position background-position-x
290
+ background-position-y background-repeat background-size baseline-shift block-size border-block
291
+ border-block-color border-block-end border-block-end-color border-block-end-style
292
+ border-block-end-width border-block-start border-block-start-color border-block-start-style
293
+ border-block-start-width border-block-style border-block-width border-bottom
294
+ border-bottom-color border-bottom-left-radius border-bottom-right-radius border-bottom-style
295
+ border-bottom-width border-color border-end-end-radius border-end-start-radius border-image
296
+ border-image-outset border-image-repeat border-image-slice border-image-source
297
+ border-image-width border-inline border-inline-color border-inline-end border-inline-end-color
298
+ border-inline-end-style border-inline-end-width border-inline-start border-inline-start-color
299
+ border-inline-start-style border-inline-start-width border-inline-style border-inline-width
300
+ border-left border-left-color border-left-style border-left-width border-radius border-right
301
+ border-right-color border-right-style border-right-width border-spacing border-start-end-radius
302
+ border-start-start-radius border-style border-top border-top-color border-top-left-radius
303
+ border-top-right-radius border-top-style border-top-width border-width bottom
304
+ box-decoration-break box-shadow box-sizing break-after break-before break-inside caption-side
305
+ caret caret-color caret-shape clear clip clip-path clip-rule color color-adjust
306
+ color-interpolation color-interpolation-filters color-rendering color-scheme column-count
307
+ column-fill column-gap column-rule column-rule-color column-rule-style column-rule-width
308
+ column-span column-width columns contain contain-intrinsic-block-size contain-intrinsic-height
309
+ contain-intrinsic-inline-size contain-intrinsic-size contain-intrinsic-width container-name
310
+ container-type content content-visibility counter-increment counter-reset counter-set cursor cx
311
+ cy d direction display dominant-baseline empty-cells field-sizing fill fill-opacity fill-rule
312
+ filter flex-basis flex-direction flex-flow float flood-color flood-opacity font font-family
313
+ font-feature-settings font-kerning font-language-override font-optical-sizing font-palette
314
+ font-size font-size-adjust font-smooth font-stretch font-style font-synthesis
315
+ font-synthesis-position font-synthesis-small-caps font-synthesis-style font-synthesis-weight
316
+ font-variant font-variant-alternates font-variant-caps font-variant-east-asian
317
+ font-variant-emoji font-variant-ligatures font-variant-numeric font-variant-position
318
+ font-variation-settings font-weight font-width forced-color-adjust gap
319
+ glyph-orientation-vertical grid-area grid-auto-columns grid-auto-flow grid-auto-rows
320
+ grid-column grid-column-end grid-column-start grid-row grid-row-end grid-row-start
321
+ grid-template grid-template-areas grid-template-columns grid-template-rows hanging-punctuation
322
+ height hyphenate-character hyphenate-limit-chars hyphens image-orientation image-rendering
323
+ image-resolution initial-letter initial-letter-align inline-size inset inset-block
324
+ inset-block-end inset-block-start inset-inline inset-inline-end inset-inline-start
325
+ interpolate-size isolation justify-content justify-items justify-self justify-tracks left
326
+ letter-spacing lighting-color line-break line-clamp line-height line-height-step list-style
327
+ list-style-image list-style-position list-style-type margin margin-block margin-block-end
328
+ margin-block-start margin-bottom margin-inline margin-inline-end margin-inline-start
329
+ margin-left margin-right margin-top margin-trim marker marker-end marker-mid marker-start mask
330
+ mask-border mask-border-mode mask-border-outset mask-border-repeat mask-border-slice
331
+ mask-border-source mask-border-width mask-clip mask-composite mask-image mask-mode mask-origin
332
+ mask-position mask-size mask-type masonry-auto-flow math-depth math-shift math-style
333
+ max-block-size max-height max-inline-size max-lines max-width min-block-size min-height
334
+ min-inline-size min-width mix-blend-mode motion motion-distance motion-path motion-rotation
335
+ object-fit object-position object-view-box offset offset-anchor offset-distance offset-path
336
+ offset-position offset-rotate offset-rotation opacity order orphans outline-color
337
+ outline-offset outline-style outline-width overflow overflow-anchor overflow-block
338
+ overflow-clip-box overflow-clip-margin overflow-inline overflow-wrap overflow-x overflow-y
339
+ overlay overscroll-behavior overscroll-behavior-block overscroll-behavior-inline
340
+ overscroll-behavior-x overscroll-behavior-y padding padding-block padding-block-end
341
+ padding-block-start padding-bottom padding-inline padding-inline-end padding-inline-start
342
+ padding-left padding-right padding-top page paint-order perspective perspective-origin
343
+ place-content place-items place-self pointer-events position position-anchor position-area
344
+ position-try position-try-fallbacks position-try-order position-visibility print-color-adjust
345
+ quotes r right rotate row-gap ruby-align ruby-merge ruby-overhang ruby-position rx ry scale
346
+ scroll-behavior scroll-initial-target scroll-margin scroll-margin-block scroll-margin-block-end
347
+ scroll-margin-block-start scroll-margin-bottom scroll-margin-inline scroll-margin-inline-end
348
+ scroll-margin-inline-start scroll-margin-left scroll-margin-right scroll-margin-top
349
+ scroll-padding scroll-padding-block scroll-padding-block-end scroll-padding-block-start
350
+ scroll-padding-bottom scroll-padding-inline scroll-padding-inline-end
351
+ scroll-padding-inline-start scroll-padding-left scroll-padding-right scroll-padding-top
352
+ scroll-snap-align scroll-snap-margin scroll-snap-margin-bottom scroll-snap-margin-left
353
+ scroll-snap-margin-right scroll-snap-margin-top scroll-snap-stop scroll-snap-type
354
+ scroll-timeline scroll-timeline-axis scroll-timeline-name scrollbar-color scrollbar-gutter
355
+ scrollbar-width shape-image-threshold shape-margin shape-outside shape-rendering speak-as
356
+ stop-color stop-opacity stroke stroke-color stroke-dasharray stroke-dashoffset stroke-linecap
357
+ stroke-linejoin stroke-miterlimit stroke-opacity stroke-width tab-size table-layout text-align
358
+ text-align-last text-anchor text-autospace text-box text-box-edge text-box-trim
359
+ text-combine-upright text-decoration text-decoration-color text-decoration-line
360
+ text-decoration-skip text-decoration-skip-ink text-decoration-style text-decoration-thickness
361
+ text-emphasis text-emphasis-color text-emphasis-position text-emphasis-style text-indent
362
+ text-orientation text-overflow text-rendering text-shadow text-size-adjust text-spacing-trim
363
+ text-transform text-underline-offset text-underline-position text-wrap-mode text-wrap-style
364
+ timeline-scope top touch-action transform-box transform-origin transform-style
365
+ transition-behavior transition-delay transition-duration transition-property
366
+ transition-timing-function translate unicode-bidi user-select vector-effect vertical-align
367
+ view-timeline view-timeline-axis view-timeline-inset view-timeline-name view-transition-class
368
+ view-transition-name visibility white-space white-space-collapse widows width will-change
369
+ word-break word-spacing word-wrap writing-mode x y z-index zoom
370
+ `.trim().split(/\s+/));
371
+ //#endregion
254
372
  //#region src/utils/levenshtein.ts
255
373
  let bufA = /* @__PURE__ */ new Int32Array(64);
256
374
  let bufB = /* @__PURE__ */ new Int32Array(64);
@@ -906,7 +1024,7 @@ function extractFromExpression(node, out = []) {
906
1024
  return out;
907
1025
  }
908
1026
  if (node.type === "ObjectExpression") {
909
- for (const prop of node.properties) if (prop.type === "Property" && prop.key.type === "Literal" && typeof prop.key.value === "string") out.push({
1027
+ for (const prop of node.properties) if (prop.type === "Property" && prop.key.type === "Literal" && typeof prop.key.value === "string" && !isStyleDeclaration(prop.key.value, prop.value)) out.push({
910
1028
  value: prop.key.value,
911
1029
  node: prop.key,
912
1030
  range: [prop.key.range[0] + 1, prop.key.range[1] - 1]
@@ -915,6 +1033,22 @@ function extractFromExpression(node, out = []) {
915
1033
  }
916
1034
  return out;
917
1035
  }
1036
+ const CUSTOM_PROPERTY = /^--\S+$/;
1037
+ const VENDOR_PROPERTY = /^-(?:webkit|moz)-[a-z-]+$/;
1038
+ /**
1039
+ * Whether an object entry is a style declaration rather than a conditional
1040
+ * class. The default `^styles?$` variable pattern reaches style objects of
1041
+ * every framework: React's `CSSProperties` (custom properties are quoted),
1042
+ * Solid / Vue / Qwik / Lit's kebab-case keys, Angular's `'width.px': 100`.
1043
+ *
1044
+ * - The key is a custom property, a vendor-prefixed or a CSS property name.
1045
+ * - Or the value is a string, number or template literal: in a class map the
1046
+ * value is a condition, and a constant one never is (`{ flex: '1 1 0%' }`).
1047
+ */
1048
+ function isStyleDeclaration(key, value) {
1049
+ if (CUSTOM_PROPERTY.test(key) || VENDOR_PROPERTY.test(key) || CSS_PROPERTY_NAMES.has(key)) return true;
1050
+ return value.type === "TemplateLiteral" || value.type === "Literal" && (typeof value.value === "string" || typeof value.value === "number");
1051
+ }
918
1052
  function appendFromTemplateLiteral(node, out) {
919
1053
  for (let i = 0; i < node.quasis.length; i++) {
920
1054
  const quasi = node.quasis[i];
@@ -1255,6 +1389,99 @@ const noUnnecessaryWhitespace = defineRule({
1255
1389
  }
1256
1390
  });
1257
1391
  //#endregion
1392
+ //#region src/utils/report.ts
1393
+ /**
1394
+ * Shared reporters: `reportClassReplacements` for the "first-as-fix,
1395
+ * rest-as-suggestion" pattern, `reportClassSuggestion` for a suggestion alone.
1396
+ *
1397
+ * Nine rules (enforce-canonical, enforce-logical, enforce-physical,
1398
+ * enforce-consistent-variable-syntax, enforce-consistent-important-position,
1399
+ * enforce-negative-arbitrary-values, no-deprecated-classes,
1400
+ * no-unnecessary-arbitrary-value, prefer-theme-tokens) all emit
1401
+ * replacements via the same shape:
1402
+ *
1403
+ * 1. Collect `{ cls, replacement }` entries from a class string.
1404
+ * 2. Rebuild the full class string with replacements applied.
1405
+ * 3. Emit ONE diagnostic with the autofix attached.
1406
+ * 4. Emit one MORE diagnostic per remaining offender, each carrying
1407
+ * the same autofix as a `suggest`.
1408
+ *
1409
+ * oxlint's fixer is single-shot per AST node, so multiple offenders in the
1410
+ * same class string can only get one mechanical fix; the rest stay as
1411
+ * suggestions the IDE can offer interactively.
1412
+ */
1413
+ /**
1414
+ * Emit autofix + suggestion diagnostics for a list of class replacements.
1415
+ *
1416
+ * If `offending` is empty, no-op. The fixer's `replaceTextRange` is shared
1417
+ * across all diagnostics — the first one is the primary fix, the rest carry
1418
+ * the same fix as a suggestion (oxlint can only apply one autofix per node).
1419
+ */
1420
+ function reportClassReplacements(context, loc, split, classes, offending, options) {
1421
+ if (offending.length === 0) return;
1422
+ const replacements = new Map(offending.map(({ cls, replacement }) => [cls, replacement]));
1423
+ const fixedValue = rebuildClassString(split, classes.map((c) => replacements.get(c) ?? c));
1424
+ const replacementKey = options.replacementKey ?? "replacement";
1425
+ const suggestMessageId = options.suggestMessageId ?? "suggestReplace";
1426
+ const applyFix = (fixer) => fixer.replaceTextRange(loc.range, preserveSpaces(loc, fixedValue));
1427
+ const report = context.report;
1428
+ for (let i = 0; i < offending.length; i++) {
1429
+ const { cls, replacement } = offending[i];
1430
+ const messageId = offending[i].messageId ?? options.messageId;
1431
+ const primaryData = {
1432
+ className: cls,
1433
+ [replacementKey]: replacement
1434
+ };
1435
+ if (i === 0) report({
1436
+ node: loc.node,
1437
+ messageId,
1438
+ data: primaryData,
1439
+ fix: applyFix
1440
+ });
1441
+ else report({
1442
+ node: loc.node,
1443
+ messageId,
1444
+ data: primaryData,
1445
+ suggest: [{
1446
+ messageId: suggestMessageId,
1447
+ data: {
1448
+ className: cls,
1449
+ replacement
1450
+ },
1451
+ fix: applyFix
1452
+ }]
1453
+ });
1454
+ }
1455
+ }
1456
+ /**
1457
+ * Report ONE class with a quick-fix suggestion and no autofix: for rewrites the
1458
+ * rule can name but must not apply on its own (`prefer-scale-token`'s numeric
1459
+ * equivalence, a typo's closest class, a canonical form that is not the same
1460
+ * CSS).
1461
+ *
1462
+ * The suggestion replaces only `cls`, never the other offenders of the string,
1463
+ * and it is rebuilt through the splitter, so the `\n` + indent that
1464
+ * `enforce-consistent-line-wrapping` introduces survives it. It never reaches
1465
+ * `reportClassReplacements`' shared autofix.
1466
+ */
1467
+ function reportClassSuggestion(context, loc, split, classes, { cls, replacement }, options) {
1468
+ const fixedValue = rebuildClassString(split, classes.map((c) => c === cls ? replacement : c));
1469
+ const report = context.report;
1470
+ report({
1471
+ node: loc.node,
1472
+ messageId: options.messageId,
1473
+ data: options.data,
1474
+ suggest: [{
1475
+ messageId: options.suggestMessageId ?? "suggestReplace",
1476
+ data: {
1477
+ className: cls,
1478
+ replacement
1479
+ },
1480
+ fix: (fixer) => fixer.replaceTextRange(loc.range, preserveSpaces(loc, fixedValue))
1481
+ }]
1482
+ });
1483
+ }
1484
+ //#endregion
1258
1485
  //#region src/utils/class-parser.ts
1259
1486
  /**
1260
1487
  * Extracts variants from a class string, respecting bracket depth.
@@ -4514,41 +4741,140 @@ var DesignSystemWorker = class {
4514
4741
  * after the first few files any given class has been seen, and every
4515
4742
  * subsequent lookup is O(1).
4516
4743
  */
4517
- const isReason = (x) => x === "variant" || x === "selector" || x === "value";
4518
- /** A persisted `[canonical, safe, reason?]` entry, or null when it isn't one. */
4744
+ const isReason = (x) => x === "variant" || x === "selector" || x === "value" || x === "variable";
4745
+ const isVariableList = (x) => Array.isArray(x) && x.length > 0 && x.every((v) => typeof v === "string" && v.startsWith("--"));
4746
+ /**
4747
+ * A persisted `[canonical, safe, reason?, variables?]` entry, or null when it
4748
+ * isn't one. The variables come with `'variable'` and only with it: a
4749
+ * `'variable'` entry without them would render a message naming nothing.
4750
+ */
4519
4751
  function fromPersisted(entry) {
4520
4752
  if (!Array.isArray(entry) || typeof entry[0] !== "string" || typeof entry[1] !== "boolean") return null;
4521
- if (entry.length > 2 && !isReason(entry[2])) return null;
4522
- return entry.length > 2 ? {
4753
+ if (entry.length === 2) return {
4754
+ canonical: entry[0],
4755
+ safe: entry[1]
4756
+ };
4757
+ if (!isReason(entry[2])) return null;
4758
+ if (entry[2] !== "variable") return entry.length === 3 ? {
4523
4759
  canonical: entry[0],
4524
4760
  safe: entry[1],
4525
4761
  reason: entry[2]
4526
- } : {
4762
+ } : null;
4763
+ if (entry.length !== 4 || !isVariableList(entry[3])) return null;
4764
+ return {
4527
4765
  canonical: entry[0],
4528
- safe: entry[1]
4766
+ safe: entry[1],
4767
+ reason: entry[2],
4768
+ variables: entry[3]
4529
4769
  };
4530
4770
  }
4531
- const toPersisted = (r) => r.reason ? [
4532
- r.canonical,
4533
- r.safe,
4534
- r.reason
4535
- ] : [r.canonical, r.safe];
4771
+ function toPersisted(r) {
4772
+ if (r.reason === "variable") return [
4773
+ r.canonical,
4774
+ r.safe,
4775
+ r.reason,
4776
+ r.variables
4777
+ ];
4778
+ return r.reason ? [
4779
+ r.canonical,
4780
+ r.safe,
4781
+ r.reason
4782
+ ] : [r.canonical, r.safe];
4783
+ }
4536
4784
  const WORKER_SCRIPT$2 = makeWorkerScript(`async (ds, request, env) => {
4537
4785
  const { classes, rem } = request;
4538
4786
  const options = rem ? { rem } : undefined;
4539
- const OWN_CLASS = /("(?:\\\\.|[^"\\\\])*"|'(?:\\\\.|[^'\\\\])*')|(^|[{};])(\\s*)\\.(?:\\\\[0-9a-fA-F]{1,6}\\s?|\\\\[^0-9a-fA-F\\s]|[\\w-])+/g;
4540
- const declsOf = (d, cls) => {
4787
+ const escapeClass = (s) => {
4788
+ if (s === '-') return '\\\\-';
4789
+ let out = '';
4790
+ for (let i = 0; i < s.length; i++) {
4791
+ const c = s.charCodeAt(i);
4792
+ if (c === 0) out += '\\uFFFD';
4793
+ else if ((c >= 1 && c <= 31) || c === 127 || (c >= 48 && c <= 57 && (i === 0 || (i === 1 && s[0] === '-')))) {
4794
+ out += '\\\\' + c.toString(16) + ' ';
4795
+ } else if (c >= 128 || c === 45 || c === 95 || (c >= 48 && c <= 57) || (c >= 65 && c <= 90) || (c >= 97 && c <= 122)) {
4796
+ out += s[i];
4797
+ } else {
4798
+ out += '\\\\' + s[i];
4799
+ }
4800
+ }
4801
+ return out;
4802
+ };
4803
+ const NAME_CHAR = /[\\w\\\\-]|[^\\x00-\\x7f]/;
4804
+ const rawOf = (d, cls) => {
4541
4805
  let out;
4542
4806
  try { out = d.candidatesToCss([cls]); } catch (e) { return null; }
4543
- if (!out || !out[0]) return null;
4544
- return out[0]
4545
- .replace(OWN_CLASS, (m, str, start, ws) => (str !== undefined ? str : start + ws + '.__c'))
4546
- .replace(/\\s+/g, ' ')
4547
- .trim();
4807
+ return out && out[0] ? out[0] : null;
4808
+ };
4809
+ const own = (css, cls) => {
4810
+ const token = '.' + escapeClass(cls);
4811
+ let out = '';
4812
+ let i = 0;
4813
+ while (i < css.length) {
4814
+ const ch = css[i];
4815
+ if (ch === '"' || ch === "'") {
4816
+ let j = i + 1;
4817
+ while (j < css.length && css[j] !== ch) j += css[j] === '\\\\' ? 2 : 1;
4818
+ out += css.slice(i, j + 1);
4819
+ i = j + 1;
4820
+ } else if (css.startsWith(token, i) && css[i - 1] !== '\\\\' && !NAME_CHAR.test(css[i + token.length] || ' ')) {
4821
+ out += '.__c';
4822
+ i += token.length;
4823
+ } else {
4824
+ out += ch;
4825
+ i++;
4826
+ }
4827
+ }
4828
+ return out.replace(/\\s+/g, ' ').trim();
4548
4829
  };
4549
4830
  // Declarations only, selectors and at-rule preludes dropped: equal for two
4550
4831
  // rules that set the same things on different selectors.
4551
4832
  const declarationsOf = (css) => css.replace(/[^{};]+\\{/g, '').replace(/\\}/g, '').replace(/\\s+/g, ' ').trim();
4833
+ // A mirror (#217) is a --tw-* declaration that repeats, verbatim, the value of
4834
+ // a sibling real property in the same block: "--tw-font-weight: var(--x)" next
4835
+ // to "font-weight: var(--x)". Tailwind drops exactly these (and their
4836
+ // @property rules) when it signs a class to canonicalize it, which is why it
4837
+ // proposes "[font-weight:var(--x)]" -> "font-(--x)". Other utilities read
4838
+ // those variables (a text-* size reads --tw-font-weight), so the two forms are
4839
+ // not the same CSS. candidatesToCss prints one declaration per line, so this
4840
+ // walks lines: a value holding a ";" (content: ';') stays whole.
4841
+ const stripMirrors = (css) => {
4842
+ const lines = css.split('\\n');
4843
+ const removed = new Set();
4844
+ const drop = new Set();
4845
+ const blocks = [];
4846
+ for (let i = 0; i < lines.length; i++) {
4847
+ const t = lines[i].trim();
4848
+ if (t.endsWith('{')) { blocks.push([]); continue; }
4849
+ if (t === '}') {
4850
+ const decls = blocks.pop() || [];
4851
+ for (const d of decls) {
4852
+ if (!d.prop.startsWith('--tw-')) continue;
4853
+ if (decls.some((o) => !o.prop.startsWith('--') && o.value === d.value)) {
4854
+ drop.add(d.line);
4855
+ removed.add(d.prop);
4856
+ }
4857
+ }
4858
+ continue;
4859
+ }
4860
+ const colon = t.indexOf(':');
4861
+ if (blocks.length > 0 && colon > 0 && t.endsWith(';')) {
4862
+ blocks[blocks.length - 1].push({ line: i, prop: t.slice(0, colon).trim(), value: t.slice(colon + 1, -1).trim() });
4863
+ }
4864
+ }
4865
+ if (removed.size === 0) return { css, removed };
4866
+ const kept = [];
4867
+ for (let i = 0; i < lines.length; i++) {
4868
+ if (drop.has(i)) continue;
4869
+ const t = lines[i].trim();
4870
+ if (t.startsWith('@property ') && t.endsWith('{') && removed.has(t.slice(10, -1).trim())) {
4871
+ while (i < lines.length && lines[i].trim() !== '}') i++;
4872
+ continue;
4873
+ }
4874
+ kept.push(lines[i]);
4875
+ }
4876
+ return { css: kept.join('\\n'), removed };
4877
+ };
4552
4878
  const results = [];
4553
4879
  for (const cls of classes) {
4554
4880
  // A malformed/mid-typing arbitrary value (e.g. \`px-[calc(var(--a)+)]\`) can
@@ -4565,19 +4891,37 @@ const WORKER_SCRIPT$2 = makeWorkerScript(`async (ds, request, env) => {
4565
4891
  }
4566
4892
  const canonical = r[0] ?? cls;
4567
4893
  if (canonical === cls) { results.push({ canonical: cls, safe: true }); continue; }
4568
- const a = declsOf(ds, cls);
4569
- const b = declsOf(ds, canonical);
4894
+ const rawA = rawOf(ds, cls);
4895
+ const rawB = rawOf(ds, canonical);
4896
+ const a = rawA === null ? null : own(rawA, cls);
4897
+ const b = rawB === null ? null : own(rawB, canonical);
4570
4898
  if (a !== null && b !== null && a === b) { results.push({ canonical, safe: true }); continue; }
4571
4899
  if (a === null || b === null) { results.push({ canonical, safe: false }); continue; }
4572
- if (declarationsOf(a) !== declarationsOf(b)) { results.push({ canonical, safe: false, reason: 'value' }); continue; }
4900
+ const ma = stripMirrors(rawA);
4901
+ const mb = stripMirrors(rawB);
4902
+ const sa = own(ma.css, cls);
4903
+ const sb = own(mb.css, canonical);
4904
+ if (sa === sb) {
4905
+ // The same CSS once the mirrors are gone. It is 'variable' only when the
4906
+ // canonical form ADDS mirrors and drops none; any other way to get here
4907
+ // differs in something else.
4908
+ const added = [...mb.removed].filter((v) => !ma.removed.has(v)).sort();
4909
+ const dropped = [...ma.removed].some((v) => !mb.removed.has(v));
4910
+ results.push(added.length > 0 && !dropped
4911
+ ? { canonical, safe: false, reason: 'variable', variables: added }
4912
+ : { canonical, safe: false, reason: 'value' });
4913
+ continue;
4914
+ }
4915
+ if (declarationsOf(sa) !== declarationsOf(sb)) { results.push({ canonical, safe: false, reason: 'value' }); continue; }
4573
4916
  // Only the selector differs. Whether the PROJECT made it differ is what
4574
4917
  // stock Tailwind answers: the same two classes, compiled without the
4575
4918
  // project's CSS. Equal there means a project-defined variant.
4576
4919
  let stock = null;
4577
4920
  try { stock = await env.loadStock(); } catch (e) {}
4578
- const sa = stock && declsOf(stock, cls);
4579
- const sb = stock && declsOf(stock, canonical);
4580
- results.push({ canonical, safe: false, reason: sa && sb && sa === sb ? 'variant' : 'selector' });
4921
+ const xa = stock && rawOf(stock, cls);
4922
+ const xb = stock && rawOf(stock, canonical);
4923
+ const same = xa && xb && own(stripMirrors(xa).css, cls) === own(stripMirrors(xb).css, canonical);
4924
+ results.push({ canonical, safe: false, reason: same ? 'variant' : 'selector' });
4581
4925
  }
4582
4926
  return results;
4583
4927
  }`, "", `(ds, warm) => {
@@ -4801,7 +5145,12 @@ function canonicalizeClassesSync(cssPath, classes, rem) {
4801
5145
  canonical: roundRemValue(raw.canonical),
4802
5146
  safe: raw.safe
4803
5147
  };
4804
- if (raw.reason) value.reason = raw.reason;
5148
+ if (raw.reason === "variable") {
5149
+ if (isVariableList(raw.variables)) {
5150
+ value.reason = raw.reason;
5151
+ value.variables = raw.variables;
5152
+ } else value.reason = "value";
5153
+ } else if (raw.reason) value.reason = raw.reason;
4805
5154
  canonCache.set(cachePrefix + cls, value);
4806
5155
  out[missingIdx[j]] = value;
4807
5156
  }
@@ -4905,10 +5254,19 @@ function resolveByGlobMapping(mappings, filePath, baseDir) {
4905
5254
  }
4906
5255
  /**
4907
5256
  * oxlint discovers nested configuration by walking up from each linted file
4908
- * looking for files with these names. We mirror that walk to find the config
4909
- * directory a relative `entryPoint` should be anchored to.
4910
- */
4911
- const OXLINT_CONFIG_NAMES = [".oxlintrc.json"];
5257
+ * looking for files with these names (oxlint 1.87: JSON, JSONC, and the JS
5258
+ * configs it loads through Node). We mirror that walk to find the config
5259
+ * directory a relative `entryPoint` should be anchored to — which is also
5260
+ * where an `oxlint.config.ts` passes it through `oxlint-tailwindcss/config`.
5261
+ * Not `vite.config.*`: under Vite+ a package's own Vite config needn't hold
5262
+ * any lint config, and nested configs aren't discovered there anyway.
5263
+ */
5264
+ const OXLINT_CONFIG_NAMES = [
5265
+ ".oxlintrc.json",
5266
+ ".oxlintrc.jsonc",
5267
+ "oxlint.config.ts",
5268
+ "oxlint.config.mts"
5269
+ ];
4912
5270
  /** Memoizes the nearest-config walk per starting directory (cleared in tests). */
4913
5271
  const nearestConfigDirCache = /* @__PURE__ */ new Map();
4914
5272
  /**
@@ -4944,8 +5302,10 @@ function nearestConfigDir(filePath) {
4944
5302
  * absolute path.
4945
5303
  *
4946
5304
  * Absolute paths are returned normalized and untouched. A **relative** path is
4947
- * anchored to the directory of the nearest enclosing `.oxlintrc.json` (the
4948
- * config oxlint applies to the file), with the CWD as a single fallback:
5305
+ * anchored to the directory of the nearest enclosing oxlint config
5306
+ * (`.oxlintrc.json`, `.oxlintrc.jsonc`, `oxlint.config.ts` or
5307
+ * `oxlint.config.mts` — the config oxlint applies to the file), with the CWD
5308
+ * as a single fallback:
4949
5309
  *
4950
5310
  * 1. nearest config dir — if its candidate file exists, use it;
4951
5311
  * 2. CWD — if its candidate file exists, use it;
@@ -5007,7 +5367,7 @@ function getLoadedDesignSystem(cssPath, settings, engineInfo) {
5007
5367
  try {
5008
5368
  mtime = statSync(resolvedPath).mtimeMs;
5009
5369
  } catch (cause) {
5010
- throw new DesignSystemLoadError(`Could not stat CSS entry point: ${resolvedPath}`, "Check that the file exists and is readable. A relative `entryPoint` is resolved against the nearest `.oxlintrc.json` directory, falling back to the oxlint working directory.", { cause: cause instanceof Error ? cause : void 0 });
5370
+ throw new DesignSystemLoadError(`Could not stat CSS entry point: ${resolvedPath}`, "Check that the file exists and is readable. A relative `entryPoint` is resolved against the directory of the nearest oxlint config (`.oxlintrc.json`, `.oxlintrc.jsonc`, `oxlint.config.ts` or `oxlint.config.mts`), falling back to the oxlint working directory.", { cause: cause instanceof Error ? cause : void 0 });
5011
5371
  }
5012
5372
  const cached = dsCache.get(resolvedPath);
5013
5373
  if (cached && cached.mtime === mtime) return {
@@ -5330,21 +5690,12 @@ const noUnknownClasses = defineRule({
5330
5690
  }
5331
5691
  /** Replace one class in the location and report, with a quick-fix suggestion. */
5332
5692
  function reportWithSuggestion(loc, classes, cls, replacement, messageId, data, split) {
5333
- const fixedValue = rebuildClassString(split, classes.map((c) => c === cls ? replacement : c));
5334
- context.report({
5335
- node: loc.node,
5693
+ reportClassSuggestion(context, loc, split, classes, {
5694
+ cls,
5695
+ replacement
5696
+ }, {
5336
5697
  messageId,
5337
- data,
5338
- suggest: [{
5339
- messageId: "suggestReplace",
5340
- data: {
5341
- className: cls,
5342
- replacement
5343
- },
5344
- fix(fixer) {
5345
- return fixer.replaceTextRange(loc.range, preserveSpaces(loc, fixedValue));
5346
- }
5347
- }]
5698
+ data
5348
5699
  });
5349
5700
  }
5350
5701
  function check(locations) {
@@ -5931,69 +6282,6 @@ const noConflictingClasses = defineRule({
5931
6282
  }
5932
6283
  });
5933
6284
  //#endregion
5934
- //#region src/utils/report.ts
5935
- /**
5936
- * Shared reporter for the "first-as-fix, rest-as-suggestion" pattern.
5937
- *
5938
- * Nine rules (enforce-canonical, enforce-logical, enforce-physical,
5939
- * enforce-consistent-variable-syntax, enforce-consistent-important-position,
5940
- * enforce-negative-arbitrary-values, no-deprecated-classes,
5941
- * no-unnecessary-arbitrary-value, prefer-theme-tokens) all emit
5942
- * replacements via the same shape:
5943
- *
5944
- * 1. Collect `{ cls, replacement }` entries from a class string.
5945
- * 2. Rebuild the full class string with replacements applied.
5946
- * 3. Emit ONE diagnostic with the autofix attached.
5947
- * 4. Emit one MORE diagnostic per remaining offender, each carrying
5948
- * the same autofix as a `suggest`.
5949
- *
5950
- * oxlint's fixer is single-shot per AST node, so multiple offenders in the
5951
- * same class string can only get one mechanical fix; the rest stay as
5952
- * suggestions the IDE can offer interactively.
5953
- */
5954
- /**
5955
- * Emit autofix + suggestion diagnostics for a list of class replacements.
5956
- *
5957
- * If `offending` is empty, no-op. The fixer's `replaceTextRange` is shared
5958
- * across all diagnostics — the first one is the primary fix, the rest carry
5959
- * the same fix as a suggestion (oxlint can only apply one autofix per node).
5960
- */
5961
- function reportClassReplacements(context, loc, split, classes, offending, options) {
5962
- if (offending.length === 0) return;
5963
- const replacements = new Map(offending.map(({ cls, replacement }) => [cls, replacement]));
5964
- const fixedValue = rebuildClassString(split, classes.map((c) => replacements.get(c) ?? c));
5965
- const replacementKey = options.replacementKey ?? "replacement";
5966
- const suggestMessageId = options.suggestMessageId ?? "suggestReplace";
5967
- const applyFix = (fixer) => fixer.replaceTextRange(loc.range, preserveSpaces(loc, fixedValue));
5968
- const report = context.report;
5969
- for (let i = 0; i < offending.length; i++) {
5970
- const { cls, replacement } = offending[i];
5971
- const primaryData = {
5972
- className: cls,
5973
- [replacementKey]: replacement
5974
- };
5975
- if (i === 0) report({
5976
- node: loc.node,
5977
- messageId: options.messageId,
5978
- data: primaryData,
5979
- fix: applyFix
5980
- });
5981
- else report({
5982
- node: loc.node,
5983
- messageId: options.messageId,
5984
- data: primaryData,
5985
- suggest: [{
5986
- messageId: suggestMessageId,
5987
- data: {
5988
- className: cls,
5989
- replacement
5990
- },
5991
- fix: applyFix
5992
- }]
5993
- });
5994
- }
5995
- }
5996
- //#endregion
5997
6285
  //#region src/utils/replacement.ts
5998
6286
  /**
5999
6287
  * Returns a predicate that answers "would this replacement produce CSS?".
@@ -6147,6 +6435,7 @@ const enforceCanonical = defineRule({
6147
6435
  ...SETTINGS_MESSAGE,
6148
6436
  nonCanonical: "\"{{className}}\" can be written as \"{{canonical}}\". Use the canonical form.",
6149
6437
  nonEquivalentVariant: "\"{{className}}\" is not the same CSS as its canonical form \"{{canonical}}\" in this project: \"{{variant}}:\" is defined differently from \"{{written}}:\" (a custom variant in your CSS), so the two match different elements. It is left as written; switch to \"{{variant}}:\" only if that is what you mean.",
6438
+ nonEquivalentVariable: "\"{{className}}\" is not the same CSS as its canonical form \"{{canonical}}\": \"{{canonical}}\" also sets {{variables}}, which other utilities read, so next to them the two can render differently. It is left as written; switch to \"{{canonical}}\" if that is what you mean.",
6150
6439
  suggestReplace: "Replace \"{{className}}\" with \"{{replacement}}\".",
6151
6440
  ...DS_UNAVAILABLE_MESSAGE
6152
6441
  }
@@ -6165,6 +6454,7 @@ const enforceCanonical = defineRule({
6165
6454
  const classes = split.classes;
6166
6455
  const canonicals = Array.from({ length: classes.length });
6167
6456
  const nonEquivalent = [];
6457
+ const addsVariables = [];
6168
6458
  const arbitraryIdx = [];
6169
6459
  const arbitrary = [];
6170
6460
  for (let i = 0; i < classes.length; i++) {
@@ -6184,12 +6474,17 @@ const enforceCanonical = defineRule({
6184
6474
  if (!dynamic) return;
6185
6475
  const reportNonEquivalent = getReportNonEquivalent();
6186
6476
  for (let k = 0; k < arbitrary.length; k++) {
6187
- const { canonical, safe, reason } = dynamic[k];
6477
+ const { canonical, safe, reason, variables } = dynamic[k];
6188
6478
  const idx = arbitraryIdx[k];
6189
6479
  if (!safe && reason === "variant" && reportNonEquivalent) nonEquivalent.push({
6190
6480
  cls: arbitrary[k],
6191
6481
  canonical
6192
6482
  });
6483
+ if (!safe && reason === "variable" && variables && reportNonEquivalent) addsVariables.push({
6484
+ cls: arbitrary[k],
6485
+ canonical: preserveImportantPosition(arbitrary[k], canonical),
6486
+ variables
6487
+ });
6193
6488
  if (!safe) {
6194
6489
  canonicals[idx] = arbitrary[k];
6195
6490
  continue;
@@ -6218,6 +6513,17 @@ const enforceCanonical = defineRule({
6218
6513
  }
6219
6514
  });
6220
6515
  }
6516
+ for (const { cls, canonical, variables } of addsVariables) reportClassSuggestion(context, loc, split, classes, {
6517
+ cls,
6518
+ replacement: canonical
6519
+ }, {
6520
+ messageId: "nonEquivalentVariable",
6521
+ data: {
6522
+ className: cls,
6523
+ canonical,
6524
+ variables: variables.join(", ")
6525
+ }
6526
+ });
6221
6527
  }
6222
6528
  }
6223
6529
  return createExtractorVisitors(context, check);
@@ -6358,12 +6664,39 @@ const enforceSortOrder = defineRule({
6358
6664
  }
6359
6665
  });
6360
6666
  //#endregion
6667
+ //#region src/utils/declared-values.ts
6668
+ /** A plain number or fraction: always the shared numeric/`--spacing` scale. */
6669
+ const NUMERIC_VALUE_RE = /^\d+(?:\.\d+)?(?:\/\d+(?:\.\d+)?)?$/;
6670
+ /** The value is a literal the user wrote, injected verbatim into every part. */
6671
+ function isWrittenValue(value) {
6672
+ return value.startsWith("[") || value.startsWith("(");
6673
+ }
6674
+ /**
6675
+ * Values the class declares on its own box, unconditionally. `null` when the
6676
+ * class produces nothing — which for a named token means it does not exist.
6677
+ */
6678
+ function declaredValues(cache, cls) {
6679
+ const values = /* @__PURE__ */ new Set();
6680
+ for (const decl of cache.getCssDeclarations(cls)) {
6681
+ if (decl.conditional) continue;
6682
+ values.add(decl.value);
6683
+ }
6684
+ return values.size > 0 ? values : null;
6685
+ }
6686
+ function sameValues(a, b) {
6687
+ if (a.size !== b.size) return false;
6688
+ for (const value of a) if (!b.has(value)) return false;
6689
+ return true;
6690
+ }
6691
+ //#endregion
6361
6692
  //#region src/rules/enforce-shorthand.ts
6362
6693
  /**
6363
6694
  * The `m`/`p` shape, shared by `margin`, `padding`, `scroll-margin` and
6364
- * `scroll-padding`: four sides, each axis, and the logical inline pair (`ms`+`me`
6365
- * IS `margin-inline`, so that one is property-identical rather than merely
6366
- * equivalent).
6695
+ * `scroll-padding`: four sides, each axis, and the logical pairs (`ms`+`me` IS
6696
+ * `margin-inline`, `mbs`+`mbe` IS `margin-block`, so those are
6697
+ * property-identical rather than merely equivalent). The logical ones are what
6698
+ * `enforce-logical` writes, so `mt-2 mb-2` ends as `my-2` whichever of the two
6699
+ * rules fixes it first.
6367
6700
  */
6368
6701
  function boxFamilies(p) {
6369
6702
  return [
@@ -6376,10 +6709,23 @@ function boxFamilies(p) {
6376
6709
  ],
6377
6710
  to: p
6378
6711
  },
6712
+ {
6713
+ parts: [
6714
+ `${p}s`,
6715
+ `${p}e`,
6716
+ `${p}bs`,
6717
+ `${p}be`
6718
+ ],
6719
+ to: p
6720
+ },
6379
6721
  {
6380
6722
  parts: [`${p}t`, `${p}b`],
6381
6723
  to: `${p}y`
6382
6724
  },
6725
+ {
6726
+ parts: [`${p}bs`, `${p}be`],
6727
+ to: `${p}y`
6728
+ },
6383
6729
  {
6384
6730
  parts: [`${p}l`, `${p}r`],
6385
6731
  to: `${p}x`
@@ -6467,10 +6813,23 @@ const SHORTHAND_FAMILIES = [
6467
6813
  ],
6468
6814
  to: "border"
6469
6815
  },
6816
+ {
6817
+ parts: [
6818
+ "border-s",
6819
+ "border-e",
6820
+ "border-bs",
6821
+ "border-be"
6822
+ ],
6823
+ to: "border"
6824
+ },
6470
6825
  {
6471
6826
  parts: ["border-t", "border-b"],
6472
6827
  to: "border-y"
6473
6828
  },
6829
+ {
6830
+ parts: ["border-bs", "border-be"],
6831
+ to: "border-y"
6832
+ },
6474
6833
  {
6475
6834
  parts: ["border-l", "border-r"],
6476
6835
  to: "border-x"
@@ -6492,10 +6851,23 @@ const SHORTHAND_FAMILIES = [
6492
6851
  ],
6493
6852
  to: "inset"
6494
6853
  },
6854
+ {
6855
+ parts: [
6856
+ "inset-s",
6857
+ "inset-e",
6858
+ "inset-bs",
6859
+ "inset-be"
6860
+ ],
6861
+ to: "inset"
6862
+ },
6495
6863
  {
6496
6864
  parts: ["top", "bottom"],
6497
6865
  to: "inset-y"
6498
6866
  },
6867
+ {
6868
+ parts: ["inset-bs", "inset-be"],
6869
+ to: "inset-y"
6870
+ },
6499
6871
  {
6500
6872
  parts: ["left", "right"],
6501
6873
  to: "inset-x"
@@ -6504,6 +6876,10 @@ const SHORTHAND_FAMILIES = [
6504
6876
  parts: ["start", "end"],
6505
6877
  to: "inset-x"
6506
6878
  },
6879
+ {
6880
+ parts: ["inset-s", "inset-e"],
6881
+ to: "inset-x"
6882
+ },
6507
6883
  {
6508
6884
  parts: ["inset-x", "inset-y"],
6509
6885
  to: "inset"
@@ -6544,8 +6920,6 @@ const VALUE_RE = (() => {
6544
6920
  const prefixes = [...new Set(SHORTHAND_FAMILIES.flatMap((f) => f.parts))].sort((a, b) => b.length - a.length);
6545
6921
  return new RegExp(`^(${prefixes.join("|")})-(.+)$`);
6546
6922
  })();
6547
- /** A plain number or fraction: always the shared numeric/`--spacing` scale. */
6548
- const NUMERIC_VALUE_RE = /^\d+(?:\.\d+)?(?:\/\d+(?:\.\d+)?)?$/;
6549
6923
  /**
6550
6924
  * Core keywords whose per-axis forms are known to agree, for when no design
6551
6925
  * system is available to check. Deliberately excludes `screen` (`w-screen` is
@@ -6566,27 +6940,6 @@ const AXIS_SAFE_KEYWORDS = /* @__PURE__ */ new Set([
6566
6940
  "svw",
6567
6941
  "svh"
6568
6942
  ]);
6569
- /** The value is a literal the user wrote, injected verbatim into every part. */
6570
- function isWrittenValue(value) {
6571
- return value.startsWith("[") || value.startsWith("(");
6572
- }
6573
- /**
6574
- * Values the class declares on its own box, unconditionally. `null` when the
6575
- * class produces nothing — which for a named token means it does not exist.
6576
- */
6577
- function declaredValues(cache, cls) {
6578
- const values = /* @__PURE__ */ new Set();
6579
- for (const decl of cache.getCssDeclarations(cls)) {
6580
- if (decl.conditional) continue;
6581
- values.add(decl.value);
6582
- }
6583
- return values.size > 0 ? values : null;
6584
- }
6585
- function sameValues(a, b) {
6586
- if (a.size !== b.size) return false;
6587
- for (const value of a) if (!b.has(value)) return false;
6588
- return true;
6589
- }
6590
6943
  /**
6591
6944
  * Would collapsing this family at this value keep the CSS identical?
6592
6945
  *
@@ -6721,10 +7074,14 @@ const LOGICAL_PHYSICAL_SCHEMA = {
6721
7074
  "both"
6722
7075
  ]
6723
7076
  },
7077
+ sizing: { type: "boolean" },
6724
7078
  entryPoint: { type: "string" }
6725
7079
  },
6726
7080
  additionalProperties: false
6727
7081
  };
7082
+ /** Viewport units of the other axis: a width in heights, a height in widths. */
7083
+ const HEIGHT_UNITS = /^[dls]vh$/;
7084
+ const WIDTH_UNITS = /^[dls]vw$/;
6728
7085
  const PHYSICAL_TO_LOGICAL_MAPPINGS = [
6729
7086
  {
6730
7087
  from: "ml",
@@ -6748,13 +7105,17 @@ const PHYSICAL_TO_LOGICAL_MAPPINGS = [
6748
7105
  },
6749
7106
  {
6750
7107
  from: "left",
6751
- to: "start",
6752
- axis: "inline"
7108
+ to: "inset-s",
7109
+ axis: "inline",
7110
+ since: true,
7111
+ fallback: "start"
6753
7112
  },
6754
7113
  {
6755
7114
  from: "right",
6756
- to: "end",
6757
- axis: "inline"
7115
+ to: "inset-e",
7116
+ axis: "inline",
7117
+ since: true,
7118
+ fallback: "end"
6758
7119
  },
6759
7120
  {
6760
7121
  from: "border-l",
@@ -6851,82 +7212,294 @@ const PHYSICAL_TO_LOGICAL_MAPPINGS = [
6851
7212
  to: "text-end",
6852
7213
  axis: "inline",
6853
7214
  exact: true
7215
+ },
7216
+ {
7217
+ from: "mt",
7218
+ to: "mbs",
7219
+ axis: "block",
7220
+ since: true
7221
+ },
7222
+ {
7223
+ from: "mb",
7224
+ to: "mbe",
7225
+ axis: "block",
7226
+ since: true
7227
+ },
7228
+ {
7229
+ from: "pt",
7230
+ to: "pbs",
7231
+ axis: "block",
7232
+ since: true
7233
+ },
7234
+ {
7235
+ from: "pb",
7236
+ to: "pbe",
7237
+ axis: "block",
7238
+ since: true
7239
+ },
7240
+ {
7241
+ from: "top",
7242
+ to: "inset-bs",
7243
+ axis: "block",
7244
+ since: true
7245
+ },
7246
+ {
7247
+ from: "bottom",
7248
+ to: "inset-be",
7249
+ axis: "block",
7250
+ since: true
7251
+ },
7252
+ {
7253
+ from: "border-t",
7254
+ to: "border-bs",
7255
+ axis: "block",
7256
+ since: true
7257
+ },
7258
+ {
7259
+ from: "border-b",
7260
+ to: "border-be",
7261
+ axis: "block",
7262
+ since: true
7263
+ },
7264
+ {
7265
+ from: "scroll-mt",
7266
+ to: "scroll-mbs",
7267
+ axis: "block",
7268
+ since: true
7269
+ },
7270
+ {
7271
+ from: "scroll-mb",
7272
+ to: "scroll-mbe",
7273
+ axis: "block",
7274
+ since: true
7275
+ },
7276
+ {
7277
+ from: "scroll-pt",
7278
+ to: "scroll-pbs",
7279
+ axis: "block",
7280
+ since: true
7281
+ },
7282
+ {
7283
+ from: "scroll-pb",
7284
+ to: "scroll-pbe",
7285
+ axis: "block",
7286
+ since: true
7287
+ },
7288
+ {
7289
+ from: "w",
7290
+ to: "inline",
7291
+ axis: "inline",
7292
+ since: true,
7293
+ sizing: true,
7294
+ skipValues: HEIGHT_UNITS
7295
+ },
7296
+ {
7297
+ from: "min-w",
7298
+ to: "min-inline",
7299
+ axis: "inline",
7300
+ since: true,
7301
+ sizing: true,
7302
+ skipValues: HEIGHT_UNITS
7303
+ },
7304
+ {
7305
+ from: "max-w",
7306
+ to: "max-inline",
7307
+ axis: "inline",
7308
+ since: true,
7309
+ sizing: true,
7310
+ skipValues: /^(?:[dls]vh|prose|screen-.+)$/
7311
+ },
7312
+ {
7313
+ from: "h",
7314
+ to: "block",
7315
+ axis: "block",
7316
+ since: true,
7317
+ sizing: true,
7318
+ skipValues: WIDTH_UNITS
7319
+ },
7320
+ {
7321
+ from: "min-h",
7322
+ to: "min-block",
7323
+ axis: "block",
7324
+ since: true,
7325
+ sizing: true,
7326
+ skipValues: WIDTH_UNITS
7327
+ },
7328
+ {
7329
+ from: "max-h",
7330
+ to: "max-block",
7331
+ axis: "block",
7332
+ since: true,
7333
+ sizing: true,
7334
+ skipValues: WIDTH_UNITS
7335
+ },
7336
+ {
7337
+ from: "size",
7338
+ to: ["inline", "block"],
7339
+ axis: "both",
7340
+ since: true,
7341
+ sizing: true,
7342
+ skipValues: /^[dls]v[hw]$/
6854
7343
  }
6855
7344
  ];
6856
7345
  /**
6857
- * Extra sources for enforce-physical ONLY.
6858
- *
6859
- * `enforce-logical` rewrites `left-2` to `start-2`, the spelling Tailwind's own
6860
- * docs use. `enforce-canonical`, asking the design system, then rewrites that to
6861
- * `inset-s-2` — same CSS, canonical name. So a codebase that ran both ends up with
6862
- * `inset-s-*`, and enforce-physical had no way back: its table only knew `start`.
6863
- *
6864
- * Kept out of the main table so inverting it doesn't change what enforce-logical
6865
- * suggests (both spellings map to the same physical class, but only one of them
6866
- * can be the recommendation).
6867
- */
6868
- const LOGICAL_INSET_ALIASES = [{
6869
- from: "inset-s",
6870
- to: "left",
6871
- axis: "inline"
6872
- }, {
6873
- from: "inset-e",
6874
- to: "right",
6875
- axis: "inline"
6876
- }];
6877
- /** Invert a directional table. enforce-physical consumes this. */
7346
+ * `inline` and `block` are display utilities too: `inline-flex` must never read
7347
+ * as an inline size, nor `block` as a block size.
7348
+ */
7349
+ const DISPLAY_CLASSES = /* @__PURE__ */ new Set([
7350
+ "inline",
7351
+ "block",
7352
+ "inline-block",
7353
+ "inline-flex",
7354
+ "inline-grid",
7355
+ "inline-table"
7356
+ ]);
7357
+ /**
7358
+ * Invert a directional table. enforce-physical consumes this. A two-axis entry
7359
+ * has no single inverse (`inline-4 block-4` convert one by one), and an entry
7360
+ * with a `fallback` inverts both spellings: `inset-s-2` and `start-2` are both
7361
+ * `left-2`.
7362
+ */
6878
7363
  function invertAxisMappings(mappings) {
6879
- return mappings.map((m) => ({
6880
- ...m,
6881
- from: m.to,
6882
- to: m.from
6883
- }));
7364
+ return mappings.flatMap((m) => {
7365
+ if (typeof m.to !== "string") return [];
7366
+ const back = {
7367
+ from: m.to,
7368
+ to: m.from,
7369
+ axis: m.axis
7370
+ };
7371
+ if (m.exact) back.exact = m.exact;
7372
+ if (m.sizing) back.sizing = m.sizing;
7373
+ return m.fallback ? [back, {
7374
+ ...back,
7375
+ from: m.fallback
7376
+ }] : [back];
7377
+ });
7378
+ }
7379
+ /** Does the project's Tailwind have this utility? See `AxisMapping.since`. */
7380
+ function hasUtility(cache, root) {
7381
+ return cache.isKnownClass(`${root}-0`);
7382
+ }
7383
+ /**
7384
+ * The same value under the new prefixes? Numbers, fractions and written values
7385
+ * read the same scale or nothing at all; a named token is settled by the CSS.
7386
+ */
7387
+ function sameSizing(cache, value, source, targets) {
7388
+ if (NUMERIC_VALUE_RE.test(value) || isWrittenValue(value)) return true;
7389
+ const expected = declaredValues(cache, source);
7390
+ if (!expected) return false;
7391
+ const actual = /* @__PURE__ */ new Set();
7392
+ for (const target of targets) {
7393
+ const values = declaredValues(cache, target);
7394
+ if (!values) return false;
7395
+ for (const v of values) actual.add(v);
7396
+ }
7397
+ return sameValues(expected, actual);
7398
+ }
7399
+ /**
7400
+ * One class through a directional table: what it should be written as, or null
7401
+ * when the table has nothing for it or the replacement can't be trusted. Pure,
7402
+ * so the Tailwind 4.1 case (no 4.2 utilities) is testable with a hand-built
7403
+ * design system.
7404
+ */
7405
+ function convertDirectional(cls, mappings, options, cache) {
7406
+ if (matchesAny(cls, options.allowlist)) return null;
7407
+ const { utility, variant } = splitUtilityAndVariant(cls);
7408
+ const { bare: bareUtility, position } = splitImportant(utility);
7409
+ const negative = bareUtility.startsWith("-");
7410
+ const core = negative ? bareUtility.slice(1) : bareUtility;
7411
+ const isUsable = makeReplacementGuard(cache);
7412
+ for (const mapping of mappings) {
7413
+ const { from, to, axis, exact, sizing } = mapping;
7414
+ if (options.direction !== "both" && options.direction !== axis) continue;
7415
+ if (sizing && !options.sizing) continue;
7416
+ if (!(core === from || !exact && core.startsWith(`${from}-`))) continue;
7417
+ if (sizing && (core === from || DISPLAY_CLASSES.has(core))) continue;
7418
+ const suffix = core.slice(from.length);
7419
+ const value = suffix.slice(1);
7420
+ if (mapping.skipValues?.test(value)) return null;
7421
+ const prefixes = typeof to === "string" ? [to] : [...to];
7422
+ const build = (prefix) => `${variant}${reattachImportant(`${negative ? "-" : ""}${prefix}${suffix}`, position)}`;
7423
+ const halves = prefixes.map(build);
7424
+ const replacement = halves.join(" ");
7425
+ if (!mapping.since) return isUsable(replacement) ? {
7426
+ replacement,
7427
+ suggestOnly: false,
7428
+ mapping
7429
+ } : null;
7430
+ if (!cache) return mapping.fallback ? {
7431
+ replacement: build(mapping.fallback),
7432
+ suggestOnly: false,
7433
+ mapping
7434
+ } : {
7435
+ replacement,
7436
+ suggestOnly: true,
7437
+ mapping
7438
+ };
7439
+ if (prefixes.every((prefix) => hasUtility(cache, prefix)) && halves.every(isUsable) && (!sizing || sameSizing(cache, value, `${from}${suffix}`, prefixes.map((p) => `${p}${suffix}`)))) return {
7440
+ replacement,
7441
+ suggestOnly: false,
7442
+ mapping
7443
+ };
7444
+ if (mapping.fallback && isUsable(build(mapping.fallback))) return {
7445
+ replacement: build(mapping.fallback),
7446
+ suggestOnly: false,
7447
+ mapping
7448
+ };
7449
+ return null;
7450
+ }
7451
+ return null;
6884
7452
  }
6885
7453
  /**
6886
7454
  * Build the `check` callback for a directional-rewrite rule. Both
6887
7455
  * enforce-logical and enforce-physical instantiate this with their own
6888
- * mapping table and messageId; the rule's `createOnce` wires it through
7456
+ * mapping table and messageIds; the rule's `createOnce` wires it through
6889
7457
  * `createExtractorVisitors`.
6890
7458
  *
6891
- * Owns: option compilation (allowlist + direction), per-class conversion
6892
- * (linear scan of the mapping table respecting `!`-prefix/suffix), and
6893
- * the `reportClassReplacements` dispatch.
7459
+ * Owns: option compilation (allowlist + direction + sizing), the per-class
7460
+ * conversion (`convertDirectional`), and the report: autofixes through
7461
+ * `reportClassReplacements`, suggestion-only conversions through
7462
+ * `reportClassSuggestion`, so a suggestion never rides along in the autofix.
6894
7463
  */
6895
7464
  function createDirectionalMapper(context, opts) {
6896
- const getState = createLazyOptions(context, (o) => ({
7465
+ const getOptions = createLazyOptions(context, (o) => ({
6897
7466
  allowlist: compileRegexList(o?.allowlist),
6898
- direction: o?.direction ?? "both"
7467
+ direction: o?.direction ?? "both",
7468
+ sizing: o?.sizing === true
6899
7469
  }));
6900
7470
  const getDS = createLazyLoader(context);
6901
- function convertClass(cls) {
6902
- const { allowlist, direction } = getState();
6903
- if (matchesAny(cls, allowlist)) return null;
6904
- const { utility, variant } = splitUtilityAndVariant(cls);
6905
- const { bare: bareUtility, position } = splitImportant(utility);
6906
- const negative = bareUtility.startsWith("-");
6907
- const core = negative ? bareUtility.slice(1) : bareUtility;
6908
- for (const { from, to, axis, exact } of opts.mappings) {
6909
- if (direction !== "both" && direction !== axis) continue;
6910
- if (!(core === from || !exact && core.startsWith(`${from}-`))) continue;
6911
- const suffix = core.slice(from.length);
6912
- return `${variant}${reattachImportant(`${negative ? "-" : ""}${to}${suffix}`, position)}`;
6913
- }
6914
- return null;
6915
- }
7471
+ const messageIdFor = ({ axis, sizing }) => opts.writingModeMessageId && (axis !== "inline" || sizing) ? opts.writingModeMessageId : opts.messageId;
6916
7472
  function check(locations) {
6917
7473
  const ds = softGetDS(getDS);
6918
- const isUsable = makeReplacementGuard(ds ? ds.cache : null);
7474
+ const cache = ds ? ds.cache : null;
7475
+ const options = getOptions();
6919
7476
  for (const loc of locations) {
6920
7477
  const split = splitClassesWithSeparators(loc.value);
6921
- const offending = split.classes.flatMap((cls) => {
6922
- const converted = convertClass(cls);
6923
- if (!converted || !isUsable(converted)) return [];
6924
- return [{
7478
+ const fixes = [];
7479
+ const suggestions = [];
7480
+ for (const cls of split.classes) {
7481
+ const conversion = convertDirectional(cls, opts.mappings, options, cache);
7482
+ if (!conversion) continue;
7483
+ const messageId = messageIdFor(conversion.mapping);
7484
+ const entry = {
6925
7485
  cls,
6926
- replacement: converted
6927
- }];
7486
+ replacement: conversion.replacement,
7487
+ messageId
7488
+ };
7489
+ if (conversion.suggestOnly) suggestions.push(entry);
7490
+ else fixes.push(entry);
7491
+ }
7492
+ reportClassReplacements(context, loc, split, split.classes, fixes, { messageId: opts.messageId });
7493
+ for (const { cls, replacement, messageId } of suggestions) reportClassSuggestion(context, loc, split, split.classes, {
7494
+ cls,
7495
+ replacement
7496
+ }, {
7497
+ messageId,
7498
+ data: {
7499
+ className: cls,
7500
+ replacement
7501
+ }
6928
7502
  });
6929
- reportClassReplacements(context, loc, split, split.classes, offending, { messageId: opts.messageId });
6930
7503
  }
6931
7504
  }
6932
7505
  return { check };
@@ -6945,24 +7518,28 @@ const enforceLogical = defineRule({
6945
7518
  hasSuggestions: true,
6946
7519
  defaultOptions: [{
6947
7520
  allowlist: [],
6948
- direction: "both"
7521
+ direction: "both",
7522
+ sizing: false
6949
7523
  }],
6950
7524
  messages: {
6951
7525
  ...SETTINGS_MESSAGE,
6952
7526
  useLogical: "\"{{className}}\" uses a physical property. Use \"{{replacement}}\" for LTR/RTL support.",
7527
+ useLogicalWritingMode: "\"{{className}}\" uses a physical property. Use \"{{replacement}}\" so it follows the writing mode.",
6953
7528
  suggestReplace: "Replace \"{{className}}\" with \"{{replacement}}\"."
6954
7529
  }
6955
7530
  },
6956
7531
  createOnce(context) {
6957
7532
  const { check } = createDirectionalMapper(context, {
6958
7533
  mappings: PHYSICAL_TO_LOGICAL_MAPPINGS,
6959
- messageId: "useLogical"
7534
+ messageId: "useLogical",
7535
+ writingModeMessageId: "useLogicalWritingMode"
6960
7536
  });
6961
7537
  return createExtractorVisitors(context, check);
6962
7538
  }
6963
7539
  });
6964
7540
  //#endregion
6965
7541
  //#region src/rules/enforce-physical.ts
7542
+ const PHYSICAL_MAPPINGS = invertAxisMappings(PHYSICAL_TO_LOGICAL_MAPPINGS);
6966
7543
  const enforcePhysical = defineRule({
6967
7544
  meta: {
6968
7545
  type: "suggestion",
@@ -6977,7 +7554,8 @@ const enforcePhysical = defineRule({
6977
7554
  hasSuggestions: true,
6978
7555
  defaultOptions: [{
6979
7556
  allowlist: [],
6980
- direction: "both"
7557
+ direction: "both",
7558
+ sizing: false
6981
7559
  }],
6982
7560
  messages: {
6983
7561
  ...SETTINGS_MESSAGE,
@@ -6987,7 +7565,7 @@ const enforcePhysical = defineRule({
6987
7565
  },
6988
7566
  createOnce(context) {
6989
7567
  const { check } = createDirectionalMapper(context, {
6990
- mappings: [...invertAxisMappings(PHYSICAL_TO_LOGICAL_MAPPINGS), ...LOGICAL_INSET_ALIASES],
7568
+ mappings: PHYSICAL_MAPPINGS,
6991
7569
  messageId: "usePhysical"
6992
7570
  });
6993
7571
  return createExtractorVisitors(context, check);
@@ -8375,6 +8953,12 @@ const consistentVariantOrder = defineRule({
8375
8953
  //#region src/rules/enforce-consistent-line-wrapping.ts
8376
8954
  const DEFAULT_PRINT_WIDTH = 80;
8377
8955
  const DEFAULT_GROUP = "newLine";
8956
+ const DEFAULT_WRAP_STRINGS = "never";
8957
+ /** A JSX attribute's own string: `className="…"`, not `className={"…"}` (#216). */
8958
+ function isJsxAttributeString(loc) {
8959
+ const node = loc.node;
8960
+ return node.type === "Literal" && node.parent?.type === "JSXAttribute";
8961
+ }
8378
8962
  /** One indentation level added below the statement's base indent for wrapped lines. */
8379
8963
  const INDENT_UNIT = " ";
8380
8964
  /** Group `classes` into chunks of at most `n`, each chunk space-joined. */
@@ -8476,13 +9060,18 @@ const enforceConsistentLineWrapping = defineRule({
8476
9060
  "emptyLine",
8477
9061
  "never"
8478
9062
  ]
9063
+ },
9064
+ wrapStrings: {
9065
+ type: "string",
9066
+ enum: ["never", "jsx"]
8479
9067
  }
8480
9068
  },
8481
9069
  additionalProperties: false
8482
9070
  }],
8483
9071
  defaultOptions: [{
8484
9072
  printWidth: DEFAULT_PRINT_WIDTH,
8485
- group: DEFAULT_GROUP
9073
+ group: DEFAULT_GROUP,
9074
+ wrapStrings: DEFAULT_WRAP_STRINGS
8486
9075
  }],
8487
9076
  messages: {
8488
9077
  ...SETTINGS_MESSAGE,
@@ -8496,6 +9085,7 @@ const enforceConsistentLineWrapping = defineRule({
8496
9085
  const getClassesPerLine = createLazyOptions(context, (o) => o?.classesPerLine);
8497
9086
  const getWrapLines = createLazyOptions(context, (o) => o?.wrapLines);
8498
9087
  const getGroup = createLazyOptions(context, (o) => o?.group ?? DEFAULT_GROUP);
9088
+ const getWrapStrings = createLazyOptions(context, (o) => o?.wrapStrings ?? DEFAULT_WRAP_STRINGS);
8499
9089
  const getDS = createLazyLoader(context);
8500
9090
  /**
8501
9091
  * The statement's real base indentation — the leading whitespace of the
@@ -8515,6 +9105,19 @@ const enforceConsistentLineWrapping = defineRule({
8515
9105
  return "";
8516
9106
  }
8517
9107
  /**
9108
+ * The line ending a JSX string's fix writes. A JSX attribute keeps the
9109
+ * file's `\r\n` in its value (a template's is LF already), so a CRLF file
9110
+ * gets CRLF breaks: from the value when it has any, else from the line the
9111
+ * string ends on.
9112
+ */
9113
+ function lineEndingOf(loc) {
9114
+ if (loc.value.includes("\r\n")) return "\r\n";
9115
+ const text = safeSourceCode(context)?.text;
9116
+ if (typeof text !== "string") return "\n";
9117
+ const nl = text.indexOf("\n", loc.range[1]);
9118
+ return nl > 0 && text[nl - 1] === "\r" ? "\r\n" : "\n";
9119
+ }
9120
+ /**
8518
9121
  * Re-wrap a template literal's classes into the block convention,
8519
9122
  * non-destructively:
8520
9123
  * - single-line → convert to a `\n` + indent block (unless the quasi is
@@ -8599,7 +9202,16 @@ const enforceConsistentLineWrapping = defineRule({
8599
9202
  const wrapLines = getWrapLines();
8600
9203
  const group = getGroup();
8601
9204
  const prefix = wrapLines === "all" && group !== "never" && classesPerLine === void 0 ? softGetDS(getDS)?.cache.prefix ?? "" : "";
8602
- for (const loc of locations) {
9205
+ const wrapStrings = getWrapStrings();
9206
+ for (const written of locations) {
9207
+ const wrapsString = wrapStrings === "jsx" && isJsxAttributeString(written);
9208
+ const fixable = written.node.type === "TemplateElement" || wrapsString;
9209
+ const eol = wrapsString ? lineEndingOf(written) : "\n";
9210
+ const loc = eol === "\n" ? written : {
9211
+ ...written,
9212
+ value: written.value.replace(/\r\n/g, "\n")
9213
+ };
9214
+ const toSource = (value) => eol === "\n" ? value : value.replace(/\n/g, eol);
8603
9215
  let maxLine = 0;
8604
9216
  for (const line of loc.value.split("\n")) {
8605
9217
  if (line.length <= maxLine) continue;
@@ -8612,14 +9224,14 @@ const enforceConsistentLineWrapping = defineRule({
8612
9224
  };
8613
9225
  const isMultiline = loc.value.includes("\n");
8614
9226
  const glued = loc.preserveLeadingSpace === true && !/^\s/.test(loc.value) || loc.preserveTrailingSpace === true && !/\s$/.test(loc.value);
8615
- if (wrapLines !== void 0 && classesPerLine === void 0 && loc.node.type === "TemplateElement" && !glued && (maxLine > printWidth || wrapLines === "all" && isMultiline)) {
9227
+ if (wrapLines !== void 0 && classesPerLine === void 0 && fixable && !glued && (maxLine > printWidth || wrapLines === "all" && isMultiline)) {
8616
9228
  const fixedValue = wrapLines === "all" ? rewrapTemplateToWidth(loc, printWidth, group, prefix) : rewrapOverBudgetLinesToWidth(loc, printWidth);
8617
9229
  if (fixedValue !== loc.value) context.report({
8618
9230
  node: loc.node,
8619
9231
  messageId: maxLine > printWidth ? "tooLong" : "inconsistentWrapping",
8620
9232
  data,
8621
9233
  fix(fixer) {
8622
- return fixer.replaceTextRange(loc.range, fixedValue);
9234
+ return fixer.replaceTextRange(loc.range, toSource(fixedValue));
8623
9235
  }
8624
9236
  });
8625
9237
  } else if (maxLine > printWidth) context.report({
@@ -8639,14 +9251,14 @@ const enforceConsistentLineWrapping = defineRule({
8639
9251
  count: String(maxPerLine),
8640
9252
  max: String(classesPerLine)
8641
9253
  };
8642
- if (loc.node.type === "TemplateElement" && !glued) {
9254
+ if (fixable && !glued) {
8643
9255
  const fixedValue = rewrapTemplate(loc, lines, classesPerLine);
8644
9256
  context.report({
8645
9257
  node: loc.node,
8646
9258
  messageId: "tooManyPerLine",
8647
9259
  data,
8648
9260
  fix(fixer) {
8649
- return fixer.replaceTextRange(loc.range, preserveSpaces(loc, fixedValue));
9261
+ return fixer.replaceTextRange(loc.range, toSource(preserveSpaces(loc, fixedValue)));
8650
9262
  }
8651
9263
  });
8652
9264
  } else context.report({
@@ -8881,24 +9493,15 @@ const preferScaleToken = defineRule({
8881
9493
  const equivalent = equivalentOf(cache, bare);
8882
9494
  if (!equivalent) continue;
8883
9495
  const replacement = variant + reattachImportant(equivalent, position);
8884
- const fixedValue = rebuildClassString(split, split.classes.map((c) => c === cls ? replacement : c));
8885
- context.report({
8886
- node: loc.node,
9496
+ reportClassSuggestion(context, loc, split, split.classes, {
9497
+ cls,
9498
+ replacement
9499
+ }, {
8887
9500
  messageId: "preferToken",
8888
9501
  data: {
8889
9502
  className: cls,
8890
9503
  replacement
8891
- },
8892
- suggest: [{
8893
- messageId: "suggestReplace",
8894
- data: {
8895
- className: cls,
8896
- replacement
8897
- },
8898
- fix(fixer) {
8899
- return fixer.replaceTextRange(loc.range, preserveSpaces(loc, fixedValue));
8900
- }
8901
- }]
9504
+ }
8902
9505
  });
8903
9506
  }
8904
9507
  }
@@ -9983,7 +10586,7 @@ function componentSignatures(files, cache, entryPoint) {
9983
10586
  const signature = signatureOf(style.classes, cache, entryPoint);
9984
10587
  const keys = [...signature.keys()];
9985
10588
  if (signature.size < MIN_SHARED || !keys.some(isColorKey) || !keys.some(isSurfaceKey)) continue;
9986
- const id = JSON.stringify([...signature].sort());
10589
+ const id = JSON.stringify([...signature].sort(([a], [b]) => a < b ? -1 : 1));
9987
10590
  if (seen.has(id)) continue;
9988
10591
  seen.add(id);
9989
10592
  const file = relative(process.cwd(), path).split("\\").join("/");