oxlint-tailwindcss 1.10.0 → 1.10.2

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
@@ -1,6 +1,6 @@
1
1
  # oxlint-tailwindcss
2
2
 
3
- 23 Tailwind CSS linting rules for [oxlint](https://oxc.rs/docs/guide/usage/linter). Built for
3
+ 24 Tailwind CSS linting rules for [oxlint](https://oxc.rs/docs/guide/usage/linter). Built for
4
4
  Tailwind CSS v4 with deterministic config, typo suggestions, and autofixes.
5
5
 
6
6
  > **v1.0.0** — Upgrading from v0.x? See the
@@ -30,7 +30,7 @@ Read the story behind this plugin:
30
30
  - **Typo suggestions** — `itms-center` → "Did you mean `items-center`?"
31
31
  - **Conflict detection** — Shows exactly which CSS properties conflict and which class wins.
32
32
  - **Lightweight** — Only 2 runtime dependencies: `@tailwindcss/node` and `tailwindcss`.
33
- - **23 rules** — Correctness, style, complexity, and restriction rules with autofixes where
33
+ - **24 rules** — Correctness, style, complexity, and restriction rules with autofixes where
34
34
  possible.
35
35
  - **Variable detection** — Lints variables matching `/^classNames?$/`, `/^classes$/`, `/^styles?$/`
36
36
  (e.g. `className`, `classNames`, `classes`, `styles`) automatically.
@@ -247,7 +247,7 @@ entries are appended to the built-in defaults:
247
247
  }
248
248
  ```
249
249
 
250
- This applies to all 23 rules at once. For example, adding `"classNames"` to `attributes` makes every
250
+ This applies to all 24 rules at once. For example, adding `"classNames"` to `attributes` makes every
251
251
  rule lint `<Input classNames={{ root: "..." }} />`.
252
252
 
253
253
  To **remove** specific items from the built-in defaults, use `exclude`:
@@ -528,18 +528,22 @@ class the component merges in), so they are skipped to avoid false positives.
528
528
 
529
529
  Enforces canonical Tailwind CSS class names. Uses `canonicalizeCandidates()` from the Tailwind CSS
530
530
  engine dynamically — the same API that powers Tailwind CSS IntelliSense's `suggestCanonicalClasses`.
531
+ It only rewrites when the canonical form emits **byte-identical CSS** (a value-preserving rename or
532
+ syntax normalization), so `--fix` never changes how your design renders.
531
533
 
532
534
  ```tsx
533
535
  // ❌ Bad → ✅ Fixed
534
- "-m-0" → "m-0"
535
- "-mt-0" → "mt-0"
536
- "p-[2px]" → "p-0.5"
537
- "max-w-[400px]" → "max-w-100"
538
- "text-[var(--color-text)]/90" → "text-(--color-text)/90"
539
- "[--w-padding:theme(spacing.1)]" → "[--w-padding:--spacing(1)]"
536
+ "-m-0" → "m-0"
537
+ "-mt-0" → "mt-0"
538
+ "flex-grow-[2]" → "grow-2"
539
+ "text-[var(--color-text)]/90" → "text-(--color-text)/90"
540
540
  ```
541
541
 
542
- The px→named conversion (e.g. `p-[2px]` → `p-0.5`) depends on `rootFontSize` (default: 16).
542
+ It does **not** rewrite an arbitrary length into a spacing-scale step (`pl-[15px]` → `pl-3.75`),
543
+ even though IntelliSense suggests it: `pl-3.75` compiles to `calc(var(--spacing) * 3.75)`, which is
544
+ not byte-identical to `15px`, so the two can diverge under a `:root` override or a different root
545
+ font size. Those value-changing suggestions live in [`prefer-scale-token`](#prefer-scale-token),
546
+ report-only.
543
547
 
544
548
  **Requires design system.** **Autofix:** Replaces with canonical form.
545
549
 
@@ -935,6 +939,35 @@ CSS in those setups. (When the theme exposes the variable directly with no wrapp
935
939
 
936
940
  ---
937
941
 
942
+ #### `prefer-scale-token`
943
+
944
+ Reports a hardcoded value that is **numerically equal** to a spacing-scale step or a named theme
945
+ token, and suggests the token. This is the rule that matches Tailwind CSS IntelliSense's
946
+ `suggestCanonicalClasses` suggestion for arbitrary lengths (e.g. `pl-[15px]` → `pl-3.75`) — the
947
+ conversion `enforce-canonical` deliberately leaves alone because the CSS isn't byte-identical (see
948
+ [#78](https://github.com/sergioazoc/oxlint-tailwindcss/issues/78)).
949
+
950
+ **Report-only, on purpose.** There is no autofix: the token resolves through `var(--spacing)`, so a
951
+ `:root` override or a different root font size can make the two diverge. It only ever suggests, so
952
+ `oxlint --fix` skips it while `oxlint --fix-suggestions` applies it in bulk.
953
+
954
+ ```tsx
955
+ // ⚠️ Suggested (not auto-fixed)
956
+ "p-[10px]" → "p-2.5"
957
+ "rounded-[0.5rem]" → "rounded-lg"
958
+ ```
959
+
960
+ By default it reports values on the granularity Tailwind's own scale enumerates (multiples of
961
+ `0.5`). To match IntelliSense exactly — including dynamic steps like `pl-3.75` — set a finer `step`:
962
+
963
+ ```jsonc
964
+ { "tailwindcss/prefer-scale-token": ["warn", { "step": 0.25 }] }
965
+ ```
966
+
967
+ **Off by default.** **Requires design system.** **No autofix — suggestions only.**
968
+
969
+ ---
970
+
938
971
  ## Edge cases
939
972
 
940
973
  The class parser correctly handles:
@@ -952,9 +985,10 @@ The class parser correctly handles:
952
985
  - **`enforce-canonical`**: Named classes are canonicalized via the precomputed map (covers
953
986
  everything in `getClassList()` plus a curated list of legacy v3 spellings like `break-words`,
954
987
  `flex-grow`, `start-N`, `bg-gradient-to-*`, `bg-left-top` → `bg-top-left`). Arbitrary/CSS-var
955
- forms (`p-[2px]`, `bg-(--c)`) are canonicalized dynamically via the worker. Some valid v4 classes
956
- that don't appear in `getClassList()` and have no canonical rewrite (e.g. `border-1` is valid as a
957
- dynamic numeric value but isn't enumerated) are left untouched.
988
+ forms (`bg-(--c)`, `text-[var(--x)]`) are canonicalized dynamically via the worker when the result
989
+ is byte-identical; a value-changing form like `p-[2px]` → `p-0.5` is left to `prefer-scale-token`.
990
+ Some valid v4 classes that don't appear in `getClassList()` and have no canonical rewrite (e.g.
991
+ `border-1` is valid as a dynamic numeric value but isn't enumerated) are left untouched.
958
992
  - **`no-conflicting-classes`**: compares the emitted declarations (property, value, the custom
959
993
  properties each value reads, and which box it applies to), so compositions are derived rather than
960
994
  enumerated. Two exceptions cannot be derived and stay declared in the source: `prose` variants and
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.78.0/node_modules/@oxlint/plugins/index.js
6
+ //#region ../../node_modules/.pnpm/@oxlint+plugins@1.80.0/node_modules/@oxlint/plugins/index.js
7
7
  /**
8
8
  * Define a plugin.
9
9
  *
@@ -3871,7 +3871,7 @@ var DesignSystemWorker = class {
3871
3871
  Atomics.notify(state.controlArray, 0);
3872
3872
  if (Atomics.wait(state.controlArray, 1, 0, REQUEST_TIMEOUT) === "timed-out") {
3873
3873
  this.dropWorker(cssPath);
3874
- throw this.remember(cssPath, new SortServiceError(`${this.opts.serviceName} worker request timed out after ${REQUEST_TIMEOUT}ms.`, "This is unexpected for typical class lists; please open an issue if it persists."));
3874
+ throw new SortServiceError(`${this.opts.serviceName} worker request timed out after ${REQUEST_TIMEOUT}ms.`, "This is unexpected for typical class lists; please open an issue if it persists.");
3875
3875
  }
3876
3876
  const responseLen = state.lengthView.getUint32(0);
3877
3877
  const responseStr = Buffer.from(state.dataArea.slice(0, responseLen)).toString("utf-8");
@@ -3881,11 +3881,11 @@ var DesignSystemWorker = class {
3881
3881
  parsed = JSON.parse(responseStr);
3882
3882
  } catch (cause) {
3883
3883
  this.dropWorker(cssPath);
3884
- throw this.remember(cssPath, new SortServiceError(`${this.opts.serviceName} worker returned non-JSON response.`, "This is a bug; please open an issue.", { cause: cause instanceof Error ? cause : void 0 }));
3884
+ throw new SortServiceError(`${this.opts.serviceName} worker returned non-JSON response.`, "This is a bug; please open an issue.", { cause: cause instanceof Error ? cause : void 0 });
3885
3885
  }
3886
3886
  if (parsed === null) {
3887
3887
  this.dropWorker(cssPath);
3888
- throw this.remember(cssPath, new SortServiceError(`${this.opts.serviceName} worker returned null — the request body was rejected or its response did not fit the buffer.`, "This is a bug; please open an issue with the input that triggered it."));
3888
+ throw new SortServiceError(`${this.opts.serviceName} worker returned null — the request body was rejected or its response did not fit the buffer.`, "This is a bug; please open an issue with the input that triggered it.");
3889
3889
  }
3890
3890
  return parsed;
3891
3891
  }
@@ -3909,8 +3909,6 @@ var DesignSystemWorker = class {
3909
3909
  } catch {}
3910
3910
  }
3911
3911
  };
3912
- //#endregion
3913
- //#region src/design-system/declaration-service.ts
3914
3912
  const declWorker = new DesignSystemWorker({
3915
3913
  workerScript: makeWorkerScript(`(ds, request) => {
3916
3914
  const decls = {};
@@ -3924,14 +3922,28 @@ const declWorker = new DesignSystemWorker({
3924
3922
  // so every user-written value went silently uncompared.
3925
3923
  const prefix = (ds.theme && ds.theme.prefix) || '';
3926
3924
  const pfx = (c) => (prefix && !c.startsWith(prefix + ':')) ? prefix + ':' + c : c;
3927
- const css = ds.candidatesToCss(request.classes.map(pfx));
3925
+ // Resolve one class at a time rather than a single batch call: a malformed/
3926
+ // mid-typing arbitrary value can make ds.candidatesToCss throw on some engine
3927
+ // versions (#130), and a batched throw blanked the whole request AND masked
3928
+ // real typos (a valid sibling like \`bg-red-5000\` went unflagged), then became
3929
+ // the worker's 'null' sentinel → a process-sticky fatal error. Per-class,
3930
+ // distinguish a THROW (incanonicalizable input → OMIT, so no-unknown-classes
3931
+ // stays lenient instead of flagging a transient false "unknown class") from a
3932
+ // FALSY result (compiles to nothing → invalid).
3928
3933
  for (let i = 0; i < request.classes.length; i++) {
3929
- if (!css[i]) { invalid.push(request.classes[i]); continue; }
3930
3934
  const cls = request.classes[i];
3935
+ let one;
3936
+ try {
3937
+ const out = ds.candidatesToCss([pfx(cls)]);
3938
+ one = out && out[0];
3939
+ } catch (e) {
3940
+ continue; // omit: neither decls nor invalid
3941
+ }
3942
+ if (!one) { invalid.push(cls); continue; }
3931
3943
  const list = [];
3932
3944
  // The selector carries the prefix, so the scope classifier needs the
3933
3945
  // prefixed name even though the result is keyed by the bare one.
3934
- walkDeclarations(css[i], pfx(cls), (scope, prop, value) => {
3946
+ walkDeclarations(one, pfx(cls), (scope, prop, value) => {
3935
3947
  list.push([scope, prop, value]);
3936
3948
  if (!(value in values)) {
3937
3949
  const reads = scanVarReads(value);
@@ -4840,23 +4852,6 @@ const noDeprecatedClasses = defineRule({
4840
4852
  return createExtractorVisitors(context, check);
4841
4853
  }
4842
4854
  });
4843
- //#endregion
4844
- //#region src/design-system/canonicalize-service.ts
4845
- /**
4846
- * Persistent canonicalize service backed by `DesignSystemWorker`.
4847
- *
4848
- * Calls `ds.canonicalizeCandidates([cls], { rem })` one class at a time
4849
- * (the design system deduplicates its input, so batching changes the
4850
- * result shape — see sync-loader.ts). The shared protocol lives in
4851
- * `./ds-worker.ts`.
4852
- *
4853
- * ## Per-class cache (process-wide)
4854
- *
4855
- * Results are cached by `${cssPath}\0${rem}\0${class}`. The worker is
4856
- * invoked only for cache misses. In practice the cache converges quickly —
4857
- * after the first few files any given class has been seen, and every
4858
- * subsequent lookup is O(1).
4859
- */
4860
4855
  const WORKER_SCRIPT = makeWorkerScript(`(ds, request) => {
4861
4856
  const { classes, rem } = request;
4862
4857
  const options = rem ? { rem } : undefined;
@@ -4871,7 +4866,17 @@ const WORKER_SCRIPT = makeWorkerScript(`(ds, request) => {
4871
4866
  return css.slice(open + 1, close).replace(/\\s+/g, ' ').trim();
4872
4867
  };
4873
4868
  return classes.map((cls) => {
4874
- const r = ds.canonicalizeCandidates([cls], options);
4869
+ // A malformed/mid-typing arbitrary value (e.g. \`px-[calc(var(--a)+)]\`) can
4870
+ // make the Tailwind parser throw on some engine versions (#130). Treat it
4871
+ // as an incanonicalizable no-op — same posture declsOf already takes for
4872
+ // candidatesToCss — instead of letting the throw become the worker's 'null'
4873
+ // sentinel, which the host used to turn into a process-sticky fatal error.
4874
+ let r;
4875
+ try {
4876
+ r = ds.canonicalizeCandidates([cls], options);
4877
+ } catch (e) {
4878
+ return { canonical: cls, safe: true };
4879
+ }
4875
4880
  const canonical = r[0] ?? cls;
4876
4881
  if (canonical === cls) return { canonical: cls, safe: true };
4877
4882
  const a = declsOf(cls);
@@ -5187,18 +5192,19 @@ const enforceCanonical = defineRule({
5187
5192
  return createExtractorVisitors(context, check);
5188
5193
  }
5189
5194
  });
5190
- //#endregion
5191
- //#region src/design-system/sort-service.ts
5192
- /**
5193
- * Persistent sort service backed by `DesignSystemWorker`.
5194
- *
5195
- * Calls `ds.getClassOrder(classes)` and returns the class names in the
5196
- * Tailwind-canonical order. The shared protocol (SharedArrayBuffer,
5197
- * Atomics.wait, fail-loud, sticky lastError) lives in `./ds-worker.ts`.
5198
- */
5199
5195
  const sortWorker = new DesignSystemWorker({
5200
5196
  workerScript: makeWorkerScript(`(ds, classes) => {
5201
- const ordered = ds.getClassOrder(classes);
5197
+ // A malformed/mid-typing arbitrary value can make ds.getClassOrder throw on
5198
+ // some engine versions (#130). Degrade to the input order (no reordering):
5199
+ // the rule reads an unchanged order as "already sorted" and emits nothing,
5200
+ // instead of the throw becoming the worker's 'null' sentinel → a
5201
+ // process-sticky fatal error that disabled the rule until restart.
5202
+ let ordered;
5203
+ try {
5204
+ ordered = ds.getClassOrder(classes);
5205
+ } catch (e) {
5206
+ return classes;
5207
+ }
5202
5208
  return [...ordered]
5203
5209
  .sort((a, b) => {
5204
5210
  if (a[1] === null && b[1] === null) return 0;
@@ -7097,10 +7103,10 @@ const preferThemeTokens = defineRule({
7097
7103
  const { bare: bareUtility, position } = splitImportant(utility);
7098
7104
  const match = detectRawVariable(bareUtility);
7099
7105
  if (!match) return [];
7100
- const candidate = `${match.prefix}-${match.varName}${match.modifier}`;
7101
- if (!cache.isValid(candidate)) return [];
7102
- const target = `--${match.varName}`;
7103
7106
  const baseCandidate = `${match.prefix}-${match.varName}`;
7107
+ if (!cache.isValid(baseCandidate)) return [];
7108
+ const candidate = `${baseCandidate}${match.modifier}`;
7109
+ const target = `--${match.varName}`;
7104
7110
  if (!cache.getCssDeclarations(baseCandidate).some((decl) => [...decl.readsVars, ...decl.readsFallbackVars].some((read) => cache.themeVarResolvesTo(read, target))) && cache.definesVar(target)) return [];
7105
7111
  const namedEquivalent = cache.getNamedEquivalent(bareUtility);
7106
7112
  if (namedEquivalent && namedEquivalent === `${match.prefix}-${match.varName}`) return [];
package/dist/index.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- //#region ../../node_modules/.pnpm/@oxlint+plugins@1.78.0/node_modules/@oxlint/plugins/index.d.ts
1
+ //#region ../../node_modules/.pnpm/@oxlint+plugins@1.80.0/node_modules/@oxlint/plugins/index.d.ts
2
2
  //#endregion
3
3
  //#region src-js/plugins/tokens.d.ts
4
4
  /**
@@ -969,7 +969,7 @@ type FunctionType = "FunctionDeclaration" | "FunctionExpression" | "TSDeclareFun
969
969
  interface FormalParameterRest extends Span {
970
970
  type: "RestElement";
971
971
  argument: BindingPattern;
972
- decorators?: [];
972
+ decorators?: Array<Decorator>;
973
973
  optional?: boolean;
974
974
  typeAnnotation?: TSTypeAnnotation | null;
975
975
  value?: null;
package/dist/index.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- //#region ../../node_modules/.pnpm/@oxlint+plugins@1.78.0/node_modules/@oxlint/plugins/index.d.ts
1
+ //#region ../../node_modules/.pnpm/@oxlint+plugins@1.80.0/node_modules/@oxlint/plugins/index.d.ts
2
2
  //#endregion
3
3
  //#region src-js/plugins/tokens.d.ts
4
4
  /**
@@ -969,7 +969,7 @@ type FunctionType = "FunctionDeclaration" | "FunctionExpression" | "TSDeclareFun
969
969
  interface FormalParameterRest extends Span {
970
970
  type: "RestElement";
971
971
  argument: BindingPattern;
972
- decorators?: [];
972
+ decorators?: Array<Decorator>;
973
973
  optional?: boolean;
974
974
  typeAnnotation?: TSTypeAnnotation | null;
975
975
  value?: null;
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.78.0/node_modules/@oxlint/plugins/index.js
10
+ //#region ../../node_modules/.pnpm/@oxlint+plugins@1.80.0/node_modules/@oxlint/plugins/index.js
11
11
  /**
12
12
  * Define a plugin.
13
13
  *
@@ -3875,7 +3875,7 @@ var DesignSystemWorker = class {
3875
3875
  Atomics.notify(state.controlArray, 0);
3876
3876
  if (Atomics.wait(state.controlArray, 1, 0, REQUEST_TIMEOUT) === "timed-out") {
3877
3877
  this.dropWorker(cssPath);
3878
- throw this.remember(cssPath, new SortServiceError(`${this.opts.serviceName} worker request timed out after ${REQUEST_TIMEOUT}ms.`, "This is unexpected for typical class lists; please open an issue if it persists."));
3878
+ throw new SortServiceError(`${this.opts.serviceName} worker request timed out after ${REQUEST_TIMEOUT}ms.`, "This is unexpected for typical class lists; please open an issue if it persists.");
3879
3879
  }
3880
3880
  const responseLen = state.lengthView.getUint32(0);
3881
3881
  const responseStr = Buffer.from(state.dataArea.slice(0, responseLen)).toString("utf-8");
@@ -3885,11 +3885,11 @@ var DesignSystemWorker = class {
3885
3885
  parsed = JSON.parse(responseStr);
3886
3886
  } catch (cause) {
3887
3887
  this.dropWorker(cssPath);
3888
- throw this.remember(cssPath, new SortServiceError(`${this.opts.serviceName} worker returned non-JSON response.`, "This is a bug; please open an issue.", { cause: cause instanceof Error ? cause : void 0 }));
3888
+ throw new SortServiceError(`${this.opts.serviceName} worker returned non-JSON response.`, "This is a bug; please open an issue.", { cause: cause instanceof Error ? cause : void 0 });
3889
3889
  }
3890
3890
  if (parsed === null) {
3891
3891
  this.dropWorker(cssPath);
3892
- throw this.remember(cssPath, new SortServiceError(`${this.opts.serviceName} worker returned null — the request body was rejected or its response did not fit the buffer.`, "This is a bug; please open an issue with the input that triggered it."));
3892
+ throw new SortServiceError(`${this.opts.serviceName} worker returned null — the request body was rejected or its response did not fit the buffer.`, "This is a bug; please open an issue with the input that triggered it.");
3893
3893
  }
3894
3894
  return parsed;
3895
3895
  }
@@ -3913,8 +3913,6 @@ var DesignSystemWorker = class {
3913
3913
  } catch {}
3914
3914
  }
3915
3915
  };
3916
- //#endregion
3917
- //#region src/design-system/declaration-service.ts
3918
3916
  const declWorker = new DesignSystemWorker({
3919
3917
  workerScript: makeWorkerScript(`(ds, request) => {
3920
3918
  const decls = {};
@@ -3928,14 +3926,28 @@ const declWorker = new DesignSystemWorker({
3928
3926
  // so every user-written value went silently uncompared.
3929
3927
  const prefix = (ds.theme && ds.theme.prefix) || '';
3930
3928
  const pfx = (c) => (prefix && !c.startsWith(prefix + ':')) ? prefix + ':' + c : c;
3931
- const css = ds.candidatesToCss(request.classes.map(pfx));
3929
+ // Resolve one class at a time rather than a single batch call: a malformed/
3930
+ // mid-typing arbitrary value can make ds.candidatesToCss throw on some engine
3931
+ // versions (#130), and a batched throw blanked the whole request AND masked
3932
+ // real typos (a valid sibling like \`bg-red-5000\` went unflagged), then became
3933
+ // the worker's 'null' sentinel → a process-sticky fatal error. Per-class,
3934
+ // distinguish a THROW (incanonicalizable input → OMIT, so no-unknown-classes
3935
+ // stays lenient instead of flagging a transient false "unknown class") from a
3936
+ // FALSY result (compiles to nothing → invalid).
3932
3937
  for (let i = 0; i < request.classes.length; i++) {
3933
- if (!css[i]) { invalid.push(request.classes[i]); continue; }
3934
3938
  const cls = request.classes[i];
3939
+ let one;
3940
+ try {
3941
+ const out = ds.candidatesToCss([pfx(cls)]);
3942
+ one = out && out[0];
3943
+ } catch (e) {
3944
+ continue; // omit: neither decls nor invalid
3945
+ }
3946
+ if (!one) { invalid.push(cls); continue; }
3935
3947
  const list = [];
3936
3948
  // The selector carries the prefix, so the scope classifier needs the
3937
3949
  // prefixed name even though the result is keyed by the bare one.
3938
- walkDeclarations(css[i], pfx(cls), (scope, prop, value) => {
3950
+ walkDeclarations(one, pfx(cls), (scope, prop, value) => {
3939
3951
  list.push([scope, prop, value]);
3940
3952
  if (!(value in values)) {
3941
3953
  const reads = scanVarReads(value);
@@ -4844,23 +4856,6 @@ const noDeprecatedClasses = defineRule({
4844
4856
  return createExtractorVisitors(context, check);
4845
4857
  }
4846
4858
  });
4847
- //#endregion
4848
- //#region src/design-system/canonicalize-service.ts
4849
- /**
4850
- * Persistent canonicalize service backed by `DesignSystemWorker`.
4851
- *
4852
- * Calls `ds.canonicalizeCandidates([cls], { rem })` one class at a time
4853
- * (the design system deduplicates its input, so batching changes the
4854
- * result shape — see sync-loader.ts). The shared protocol lives in
4855
- * `./ds-worker.ts`.
4856
- *
4857
- * ## Per-class cache (process-wide)
4858
- *
4859
- * Results are cached by `${cssPath}\0${rem}\0${class}`. The worker is
4860
- * invoked only for cache misses. In practice the cache converges quickly —
4861
- * after the first few files any given class has been seen, and every
4862
- * subsequent lookup is O(1).
4863
- */
4864
4859
  const WORKER_SCRIPT = makeWorkerScript(`(ds, request) => {
4865
4860
  const { classes, rem } = request;
4866
4861
  const options = rem ? { rem } : undefined;
@@ -4875,7 +4870,17 @@ const WORKER_SCRIPT = makeWorkerScript(`(ds, request) => {
4875
4870
  return css.slice(open + 1, close).replace(/\\s+/g, ' ').trim();
4876
4871
  };
4877
4872
  return classes.map((cls) => {
4878
- const r = ds.canonicalizeCandidates([cls], options);
4873
+ // A malformed/mid-typing arbitrary value (e.g. \`px-[calc(var(--a)+)]\`) can
4874
+ // make the Tailwind parser throw on some engine versions (#130). Treat it
4875
+ // as an incanonicalizable no-op — same posture declsOf already takes for
4876
+ // candidatesToCss — instead of letting the throw become the worker's 'null'
4877
+ // sentinel, which the host used to turn into a process-sticky fatal error.
4878
+ let r;
4879
+ try {
4880
+ r = ds.canonicalizeCandidates([cls], options);
4881
+ } catch (e) {
4882
+ return { canonical: cls, safe: true };
4883
+ }
4879
4884
  const canonical = r[0] ?? cls;
4880
4885
  if (canonical === cls) return { canonical: cls, safe: true };
4881
4886
  const a = declsOf(cls);
@@ -5191,18 +5196,19 @@ const enforceCanonical = defineRule({
5191
5196
  return createExtractorVisitors(context, check);
5192
5197
  }
5193
5198
  });
5194
- //#endregion
5195
- //#region src/design-system/sort-service.ts
5196
- /**
5197
- * Persistent sort service backed by `DesignSystemWorker`.
5198
- *
5199
- * Calls `ds.getClassOrder(classes)` and returns the class names in the
5200
- * Tailwind-canonical order. The shared protocol (SharedArrayBuffer,
5201
- * Atomics.wait, fail-loud, sticky lastError) lives in `./ds-worker.ts`.
5202
- */
5203
5199
  const sortWorker = new DesignSystemWorker({
5204
5200
  workerScript: makeWorkerScript(`(ds, classes) => {
5205
- const ordered = ds.getClassOrder(classes);
5201
+ // A malformed/mid-typing arbitrary value can make ds.getClassOrder throw on
5202
+ // some engine versions (#130). Degrade to the input order (no reordering):
5203
+ // the rule reads an unchanged order as "already sorted" and emits nothing,
5204
+ // instead of the throw becoming the worker's 'null' sentinel → a
5205
+ // process-sticky fatal error that disabled the rule until restart.
5206
+ let ordered;
5207
+ try {
5208
+ ordered = ds.getClassOrder(classes);
5209
+ } catch (e) {
5210
+ return classes;
5211
+ }
5206
5212
  return [...ordered]
5207
5213
  .sort((a, b) => {
5208
5214
  if (a[1] === null && b[1] === null) return 0;
@@ -7101,10 +7107,10 @@ const preferThemeTokens = defineRule({
7101
7107
  const { bare: bareUtility, position } = splitImportant(utility);
7102
7108
  const match = detectRawVariable(bareUtility);
7103
7109
  if (!match) return [];
7104
- const candidate = `${match.prefix}-${match.varName}${match.modifier}`;
7105
- if (!cache.isValid(candidate)) return [];
7106
- const target = `--${match.varName}`;
7107
7110
  const baseCandidate = `${match.prefix}-${match.varName}`;
7111
+ if (!cache.isValid(baseCandidate)) return [];
7112
+ const candidate = `${baseCandidate}${match.modifier}`;
7113
+ const target = `--${match.varName}`;
7108
7114
  if (!cache.getCssDeclarations(baseCandidate).some((decl) => [...decl.readsVars, ...decl.readsFallbackVars].some((read) => cache.themeVarResolvesTo(read, target))) && cache.definesVar(target)) return [];
7109
7115
  const namedEquivalent = cache.getNamedEquivalent(bareUtility);
7110
7116
  if (namedEquivalent && namedEquivalent === `${match.prefix}-${match.varName}`) return [];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "oxlint-tailwindcss",
3
- "version": "1.10.0",
3
+ "version": "1.10.2",
4
4
  "description": "Tailwind CSS linting rules for oxlint",
5
5
  "keywords": [
6
6
  "css",