oxlint-tailwindcss 1.10.1 → 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/dist/index.cjs CHANGED
@@ -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;
package/dist/index.mjs CHANGED
@@ -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;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "oxlint-tailwindcss",
3
- "version": "1.10.1",
3
+ "version": "1.10.2",
4
4
  "description": "Tailwind CSS linting rules for oxlint",
5
5
  "keywords": [
6
6
  "css",