oxlint-tailwindcss 1.17.1 → 1.17.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/config.d.cts +28 -0
- package/dist/config.d.mts +28 -0
- package/dist/index.cjs +51 -20
- package/dist/index.mjs +51 -20
- package/package.json +5 -5
package/dist/config.d.cts
CHANGED
|
@@ -1,3 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `oxlint-tailwindcss/config`: the plugin and its recommended rules as an
|
|
3
|
+
* oxlint config object, for `extends` in an `oxlint.config.ts` and in the
|
|
4
|
+
* shared configs that compose it (#218).
|
|
5
|
+
*
|
|
6
|
+
* import tailwindcss from 'oxlint-tailwindcss/config'
|
|
7
|
+
* export default defineConfig({
|
|
8
|
+
* extends: [tailwindcss()],
|
|
9
|
+
* settings: { tailwindcss: { entryPoint: 'src/styles.css' } },
|
|
10
|
+
* })
|
|
11
|
+
*
|
|
12
|
+
* A config that reaches oxlint through `extends` can't register its JS plugin
|
|
13
|
+
* by package name: oxlint resolves `"oxlint-tailwindcss"` from the project,
|
|
14
|
+
* where a shared config's own dependency isn't installed under pnpm, and it
|
|
15
|
+
* rejects a relative specifier there outright. This module knows where the
|
|
16
|
+
* plugin is — its sibling `index.mjs`, the file the bare name resolves to, so
|
|
17
|
+
* a project that also lists the name registers the same plugin — and hands
|
|
18
|
+
* oxlint that absolute path.
|
|
19
|
+
*
|
|
20
|
+
* It carries no settings, on purpose: oxlint never takes `settings` from an
|
|
21
|
+
* extended config (JSON or TS), so an `entryPoint` passed through here would be
|
|
22
|
+
* dropped in silence. The settings stay in the config that is linted with.
|
|
23
|
+
*
|
|
24
|
+
* It imports nothing at runtime from the plugin: the entry stays a few lines,
|
|
25
|
+
* the build keeps `dist/index.cjs` a single `module.exports = plugin`, and the
|
|
26
|
+
* recommended severities come from a static map a test holds equal to the
|
|
27
|
+
* rules' own metadata.
|
|
28
|
+
*/
|
|
1
29
|
interface ExtractorExclusions {
|
|
2
30
|
/** Default attribute names to exclude */
|
|
3
31
|
attributes?: string[];
|
package/dist/config.d.mts
CHANGED
|
@@ -1,3 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `oxlint-tailwindcss/config`: the plugin and its recommended rules as an
|
|
3
|
+
* oxlint config object, for `extends` in an `oxlint.config.ts` and in the
|
|
4
|
+
* shared configs that compose it (#218).
|
|
5
|
+
*
|
|
6
|
+
* import tailwindcss from 'oxlint-tailwindcss/config'
|
|
7
|
+
* export default defineConfig({
|
|
8
|
+
* extends: [tailwindcss()],
|
|
9
|
+
* settings: { tailwindcss: { entryPoint: 'src/styles.css' } },
|
|
10
|
+
* })
|
|
11
|
+
*
|
|
12
|
+
* A config that reaches oxlint through `extends` can't register its JS plugin
|
|
13
|
+
* by package name: oxlint resolves `"oxlint-tailwindcss"` from the project,
|
|
14
|
+
* where a shared config's own dependency isn't installed under pnpm, and it
|
|
15
|
+
* rejects a relative specifier there outright. This module knows where the
|
|
16
|
+
* plugin is — its sibling `index.mjs`, the file the bare name resolves to, so
|
|
17
|
+
* a project that also lists the name registers the same plugin — and hands
|
|
18
|
+
* oxlint that absolute path.
|
|
19
|
+
*
|
|
20
|
+
* It carries no settings, on purpose: oxlint never takes `settings` from an
|
|
21
|
+
* extended config (JSON or TS), so an `entryPoint` passed through here would be
|
|
22
|
+
* dropped in silence. The settings stay in the config that is linted with.
|
|
23
|
+
*
|
|
24
|
+
* It imports nothing at runtime from the plugin: the entry stays a few lines,
|
|
25
|
+
* the build keeps `dist/index.cjs` a single `module.exports = plugin`, and the
|
|
26
|
+
* recommended severities come from a static map a test holds equal to the
|
|
27
|
+
* rules' own metadata.
|
|
28
|
+
*/
|
|
1
29
|
interface ExtractorExclusions {
|
|
2
30
|
/** Default attribute names to exclude */
|
|
3
31
|
attributes?: string[];
|
package/dist/index.cjs
CHANGED
|
@@ -4,7 +4,7 @@ let node_crypto = require("node:crypto");
|
|
|
4
4
|
let node_fs = require("node:fs");
|
|
5
5
|
let node_path = require("node:path");
|
|
6
6
|
let node_os = require("node:os");
|
|
7
|
-
// ../../node_modules/.pnpm/@oxlint+plugins@1.
|
|
7
|
+
// ../../node_modules/.pnpm/@oxlint+plugins@1.93.0/node_modules/@oxlint/plugins/index.js
|
|
8
8
|
/**
|
|
9
9
|
* Define a plugin.
|
|
10
10
|
*
|
|
@@ -376,7 +376,7 @@ let bufC = /* @__PURE__ */ new Int32Array(64);
|
|
|
376
376
|
* value greater than `max`. Every cell is at most the one above it plus 1, so
|
|
377
377
|
* once a whole row is past `max`, every later row is too.
|
|
378
378
|
*/
|
|
379
|
-
function levenshtein(a, b, max =
|
|
379
|
+
function levenshtein(a, b, max = 1e400) {
|
|
380
380
|
if (a.length === 0) return b.length;
|
|
381
381
|
if (b.length === 0) return a.length;
|
|
382
382
|
const n = b.length;
|
|
@@ -1899,6 +1899,13 @@ const DYNAMIC_NUMERIC_RE = /^(.+)-\d+\.?\d*$/;
|
|
|
1899
1899
|
* `from-33.5%`, so a decimal here would be tolerance with nothing behind it.
|
|
1900
1900
|
*/
|
|
1901
1901
|
const DYNAMIC_PERCENT_RE = /^(.+)-\d+%$/;
|
|
1902
|
+
/** `--color-red-500` (or `--tw-color-red-500` under `prefix(tw)`) → `red-500`. */
|
|
1903
|
+
function colorNameOf(varName, prefix) {
|
|
1904
|
+
if (varName.startsWith("--color-")) return varName.slice(8);
|
|
1905
|
+
if (prefix === "") return null;
|
|
1906
|
+
const namespace = `--${prefix}-color-`;
|
|
1907
|
+
return varName.startsWith(namespace) ? varName.slice(namespace.length) : null;
|
|
1908
|
+
}
|
|
1902
1909
|
var DesignSystemCache = class DesignSystemCache {
|
|
1903
1910
|
canonicalMap = /* @__PURE__ */ new Map();
|
|
1904
1911
|
deprecatedMap = /* @__PURE__ */ new Map();
|
|
@@ -1954,7 +1961,7 @@ var DesignSystemCache = class DesignSystemCache {
|
|
|
1954
1961
|
}
|
|
1955
1962
|
for (const name of data.definedVars ?? []) cache.definedVarSet.add(name);
|
|
1956
1963
|
for (const name of data.paletteVars ?? []) cache.paletteVarSet.add(name);
|
|
1957
|
-
cache.projectColorNames = (data.projectColorVars ?? []).map((name) => name.
|
|
1964
|
+
cache.projectColorNames = (data.projectColorVars ?? []).map((name) => colorNameOf(name, data.prefix ?? "") ?? name).sort((a, b) => a.localeCompare(b));
|
|
1958
1965
|
if (data.themeRefs) for (const [name, refs] of Object.entries(data.themeRefs)) cache.themeRefs.set(name, refs);
|
|
1959
1966
|
for (const [prefix, entries] of Object.entries(data.tokenValues ?? {})) cache.tokenValuesMap.set(prefix, entries);
|
|
1960
1967
|
if (data.scale) cache.scaleFacts = {
|
|
@@ -2412,6 +2419,14 @@ var DesignSystemCache = class DesignSystemCache {
|
|
|
2412
2419
|
isPaletteVar(varName) {
|
|
2413
2420
|
return this.paletteVarSet.has(varName);
|
|
2414
2421
|
}
|
|
2422
|
+
/**
|
|
2423
|
+
* The color a theme color variable names (`--color-red-500` → `red-500`), or
|
|
2424
|
+
* `null` for any other variable. Under a project prefix the theme's colors are
|
|
2425
|
+
* `--tw-color-*` (#253), and both spellings are accepted.
|
|
2426
|
+
*/
|
|
2427
|
+
themeColorName(varName) {
|
|
2428
|
+
return colorNameOf(varName, this._prefix);
|
|
2429
|
+
}
|
|
2415
2430
|
/** The colors the project's theme declares, by name (`brand`, `primary`), sorted. */
|
|
2416
2431
|
projectColors() {
|
|
2417
2432
|
return this.projectColorNames;
|
|
@@ -3521,10 +3536,11 @@ async function main() {
|
|
|
3521
3536
|
//
|
|
3522
3537
|
// Functional variants (\`group-*\`, \`peer-*\`, \`data-*\`, \`nth-*\`) are skipped:
|
|
3523
3538
|
// probing them would need a value, and none of them retargets the selector.
|
|
3524
|
-
// Measured in Tailwind 4.3.
|
|
3525
|
-
//
|
|
3526
|
-
//
|
|
3527
|
-
//
|
|
3539
|
+
// Measured in Tailwind 4.3.5: \`group-hover\`/\`peer-checked\` compile to
|
|
3540
|
+
// \`:is(:where(.group):hover .x)\` (since tailwindlabs/tailwindcss#20513; 4.3.3
|
|
3541
|
+
// printed \`&:is(:where(.group):hover *)\`) — either way a condition on the
|
|
3542
|
+
// element itself — so two of them in either order produce equivalent selectors
|
|
3543
|
+
// and neither is a reordering barrier.
|
|
3528
3544
|
const variantFacts = {};
|
|
3529
3545
|
const probeNames = [];
|
|
3530
3546
|
for (let i = 0; i < variants.length; i++) {
|
|
@@ -3596,13 +3612,15 @@ async function main() {
|
|
|
3596
3612
|
// Tailwind's default palette (\`@theme default\`, theme option DEFAULT = 4)
|
|
3597
3613
|
// apart from the colors the project declares, for no-default-palette. A
|
|
3598
3614
|
// project that redefines a palette color owns it: its entry loses the flag.
|
|
3615
|
+
// Under a prefix the theme names them \`--tw-color-*\`, as the CSS reads them (#253).
|
|
3599
3616
|
const paletteVars = [];
|
|
3600
3617
|
const projectColorVars = [];
|
|
3618
|
+
const colorNamespace = prefix ? '--' + prefix + '-color-' : '--color-';
|
|
3601
3619
|
if (ds.theme && typeof ds.theme.entries === 'function') {
|
|
3602
3620
|
for (const [name, entry] of ds.theme.entries()) {
|
|
3603
3621
|
const value = entry && typeof entry.value === 'string' ? entry.value : '';
|
|
3604
3622
|
themeValues.set(name, value);
|
|
3605
|
-
if (name.startsWith(
|
|
3623
|
+
if (name.startsWith(colorNamespace)) {
|
|
3606
3624
|
if (entry && (entry.options & 4)) paletteVars.push(name);
|
|
3607
3625
|
else projectColorVars.push(name);
|
|
3608
3626
|
}
|
|
@@ -4587,7 +4605,10 @@ async function main() {
|
|
|
4587
4605
|
const handler = ${handlerExpr};
|
|
4588
4606
|
|
|
4589
4607
|
while (true) {
|
|
4590
|
-
|
|
4608
|
+
// Wait on the flag, not on the wake-up: the host's \`notify\` is a separate
|
|
4609
|
+
// step from its \`store\`, so a late one can land on this wait after the
|
|
4610
|
+
// request it announced was already served (#251).
|
|
4611
|
+
while (Atomics.load(control, 0) === 0) Atomics.wait(control, 0, 0);
|
|
4591
4612
|
const len = lengthView.getUint32(0);
|
|
4592
4613
|
const requestStr = Buffer.from(dataArea.slice(0, len)).toString('utf-8');
|
|
4593
4614
|
Atomics.store(control, 0, 0);
|
|
@@ -4777,7 +4798,16 @@ var DesignSystemWorker = class {
|
|
|
4777
4798
|
state.lengthView.setUint32(0, requestBytes.length);
|
|
4778
4799
|
Atomics.store(state.controlArray, 0, 1);
|
|
4779
4800
|
Atomics.notify(state.controlArray, 0);
|
|
4780
|
-
|
|
4801
|
+
const deadline = Date.now() + this.requestTimeoutMs;
|
|
4802
|
+
let timedOut = false;
|
|
4803
|
+
while (Atomics.load(state.controlArray, 1) === 0) {
|
|
4804
|
+
const left = deadline - Date.now();
|
|
4805
|
+
if (left <= 0 || Atomics.wait(state.controlArray, 1, 0, left) === "timed-out") {
|
|
4806
|
+
timedOut = Atomics.load(state.controlArray, 1) === 0;
|
|
4807
|
+
break;
|
|
4808
|
+
}
|
|
4809
|
+
}
|
|
4810
|
+
if (timedOut) throw this.failRequest(cssPath, new SortServiceError(`${this.opts.serviceName} worker request timed out after ${this.requestTimeoutMs}ms.`, "A slow machine or CI runner can cause this. If the class lists are valid, raise OXLINT_TAILWINDCSS_WORKER_REQUEST_TIMEOUT; otherwise please open an issue."));
|
|
4781
4811
|
const responseLen = state.lengthView.getUint32(0);
|
|
4782
4812
|
const responseStr = Buffer.from(state.dataArea.slice(0, responseLen)).toString("utf-8");
|
|
4783
4813
|
Atomics.store(state.controlArray, 1, 0);
|
|
@@ -5342,7 +5372,7 @@ function resolveByGlobMapping(mappings, filePath, baseDir) {
|
|
|
5342
5372
|
}
|
|
5343
5373
|
/**
|
|
5344
5374
|
* oxlint discovers nested configuration by walking up from each linted file
|
|
5345
|
-
* looking for files with these names (oxlint 1.
|
|
5375
|
+
* looking for files with these names (oxlint 1.93: JSON, JSONC, and the JS
|
|
5346
5376
|
* configs it loads through Node). We mirror that walk to find the config
|
|
5347
5377
|
* directory a relative `entryPoint` should be anchored to — which is also
|
|
5348
5378
|
* where an `oxlint.config.ts` passes it through `oxlint-tailwindcss/config`.
|
|
@@ -8284,16 +8314,16 @@ function withoutVarGroups(value) {
|
|
|
8284
8314
|
}
|
|
8285
8315
|
/**
|
|
8286
8316
|
* The colour property a class sets, read from the CSS it emits — a colour
|
|
8287
|
-
* property, a read of a `--color-*` theme variable
|
|
8288
|
-
* null when it sets none. Descendant and pseudo-element declarations count
|
|
8317
|
+
* property, a read of a `--color-*` theme variable (`--tw-color-*` under a
|
|
8318
|
+
* prefix, #253), or a colour literal — or null when it sets none. Descendant and pseudo-element declarations count
|
|
8289
8319
|
* (`divide-*`, `placeholder-*` colour other boxes); `@media`-conditional ones
|
|
8290
8320
|
* don't.
|
|
8291
8321
|
*/
|
|
8292
|
-
function colorPropertyOf(decls) {
|
|
8322
|
+
function colorPropertyOf(decls, cache) {
|
|
8293
8323
|
const own = decls.filter((d) => !d.conditional);
|
|
8294
8324
|
for (const d of own) if (COLOR_PROPERTY.test(d.prop)) return d.prop;
|
|
8295
8325
|
for (const d of own) {
|
|
8296
|
-
if (d.readsVars.some((v) =>
|
|
8326
|
+
if (d.readsVars.some((v) => cache.themeColorName(v) !== null)) return d.prop;
|
|
8297
8327
|
if (COLOR_LITERAL.test(withoutVarGroups(d.value))) return d.prop;
|
|
8298
8328
|
}
|
|
8299
8329
|
return null;
|
|
@@ -8411,8 +8441,8 @@ const noDarkWithoutLight = defineRule({
|
|
|
8411
8441
|
if (variant !== void 0) {
|
|
8412
8442
|
const decls = cache ? cache.getCssDeclarations(bare) : [];
|
|
8413
8443
|
let colorProperty;
|
|
8414
|
-
if (decls.length > 0) {
|
|
8415
|
-
const found = colorPropertyOf(decls);
|
|
8444
|
+
if (cache && decls.length > 0) {
|
|
8445
|
+
const found = colorPropertyOf(decls, cache);
|
|
8416
8446
|
if (found === null) continue;
|
|
8417
8447
|
colorProperty = found;
|
|
8418
8448
|
} else if (isNeverColorStatic(bare)) continue;
|
|
@@ -9966,7 +9996,8 @@ const noDynamicClasses = defineRule({
|
|
|
9966
9996
|
}
|
|
9967
9997
|
});
|
|
9968
9998
|
// src/rules/no-default-palette.ts
|
|
9969
|
-
|
|
9999
|
+
/** An arbitrary value reading a theme color: `var(--color-…)`, or `var(--tw-color-…)` under a prefix. */
|
|
10000
|
+
const COLOR_VAR_READ = /var\(--(?:[a-z0-9]+-)?color-/;
|
|
9970
10001
|
/** `white`, `gray-*` → a test on palette color names. */
|
|
9971
10002
|
function compileAllow(allow) {
|
|
9972
10003
|
const exact = new Set(allow.filter((a) => !a.endsWith("*")));
|
|
@@ -9978,11 +10009,11 @@ function paletteColorOf(cls, cache, entryPoint) {
|
|
|
9978
10009
|
const { bare } = splitImportant(splitUtilityAndVariant(cls).utility);
|
|
9979
10010
|
const base = bare.replace(/\/[^/\]]+$/, "");
|
|
9980
10011
|
let decls = cache.getCssDeclarations(base);
|
|
9981
|
-
if (decls.length === 0 &&
|
|
10012
|
+
if (decls.length === 0 && COLOR_VAR_READ.test(base)) {
|
|
9982
10013
|
resolveDeclarationsSync(entryPoint, cache, [base]);
|
|
9983
10014
|
decls = cache.getCssDeclarations(base);
|
|
9984
10015
|
}
|
|
9985
|
-
for (const decl of decls) for (const read of decl.readsVars) if (cache.isPaletteVar(read)) return
|
|
10016
|
+
for (const decl of decls) for (const read of decl.readsVars) if (cache.isPaletteVar(read)) return cache.themeColorName(read);
|
|
9986
10017
|
return null;
|
|
9987
10018
|
}
|
|
9988
10019
|
const noDefaultPalette = defineRule({
|
package/dist/index.mjs
CHANGED
|
@@ -6,7 +6,7 @@ import { dirname, extname, isAbsolute, join, relative, resolve } from "node:path
|
|
|
6
6
|
import { tmpdir, userInfo } from "node:os";
|
|
7
7
|
// \0rolldown/runtime.js
|
|
8
8
|
var __require = /* #__PURE__ */ (() => createRequire(import.meta.url))();
|
|
9
|
-
// ../../node_modules/.pnpm/@oxlint+plugins@1.
|
|
9
|
+
// ../../node_modules/.pnpm/@oxlint+plugins@1.93.0/node_modules/@oxlint/plugins/index.js
|
|
10
10
|
/**
|
|
11
11
|
* Define a plugin.
|
|
12
12
|
*
|
|
@@ -378,7 +378,7 @@ let bufC = /* @__PURE__ */ new Int32Array(64);
|
|
|
378
378
|
* value greater than `max`. Every cell is at most the one above it plus 1, so
|
|
379
379
|
* once a whole row is past `max`, every later row is too.
|
|
380
380
|
*/
|
|
381
|
-
function levenshtein(a, b, max =
|
|
381
|
+
function levenshtein(a, b, max = 1e400) {
|
|
382
382
|
if (a.length === 0) return b.length;
|
|
383
383
|
if (b.length === 0) return a.length;
|
|
384
384
|
const n = b.length;
|
|
@@ -1901,6 +1901,13 @@ const DYNAMIC_NUMERIC_RE = /^(.+)-\d+\.?\d*$/;
|
|
|
1901
1901
|
* `from-33.5%`, so a decimal here would be tolerance with nothing behind it.
|
|
1902
1902
|
*/
|
|
1903
1903
|
const DYNAMIC_PERCENT_RE = /^(.+)-\d+%$/;
|
|
1904
|
+
/** `--color-red-500` (or `--tw-color-red-500` under `prefix(tw)`) → `red-500`. */
|
|
1905
|
+
function colorNameOf(varName, prefix) {
|
|
1906
|
+
if (varName.startsWith("--color-")) return varName.slice(8);
|
|
1907
|
+
if (prefix === "") return null;
|
|
1908
|
+
const namespace = `--${prefix}-color-`;
|
|
1909
|
+
return varName.startsWith(namespace) ? varName.slice(namespace.length) : null;
|
|
1910
|
+
}
|
|
1904
1911
|
var DesignSystemCache = class DesignSystemCache {
|
|
1905
1912
|
canonicalMap = /* @__PURE__ */ new Map();
|
|
1906
1913
|
deprecatedMap = /* @__PURE__ */ new Map();
|
|
@@ -1956,7 +1963,7 @@ var DesignSystemCache = class DesignSystemCache {
|
|
|
1956
1963
|
}
|
|
1957
1964
|
for (const name of data.definedVars ?? []) cache.definedVarSet.add(name);
|
|
1958
1965
|
for (const name of data.paletteVars ?? []) cache.paletteVarSet.add(name);
|
|
1959
|
-
cache.projectColorNames = (data.projectColorVars ?? []).map((name) => name.
|
|
1966
|
+
cache.projectColorNames = (data.projectColorVars ?? []).map((name) => colorNameOf(name, data.prefix ?? "") ?? name).sort((a, b) => a.localeCompare(b));
|
|
1960
1967
|
if (data.themeRefs) for (const [name, refs] of Object.entries(data.themeRefs)) cache.themeRefs.set(name, refs);
|
|
1961
1968
|
for (const [prefix, entries] of Object.entries(data.tokenValues ?? {})) cache.tokenValuesMap.set(prefix, entries);
|
|
1962
1969
|
if (data.scale) cache.scaleFacts = {
|
|
@@ -2414,6 +2421,14 @@ var DesignSystemCache = class DesignSystemCache {
|
|
|
2414
2421
|
isPaletteVar(varName) {
|
|
2415
2422
|
return this.paletteVarSet.has(varName);
|
|
2416
2423
|
}
|
|
2424
|
+
/**
|
|
2425
|
+
* The color a theme color variable names (`--color-red-500` → `red-500`), or
|
|
2426
|
+
* `null` for any other variable. Under a project prefix the theme's colors are
|
|
2427
|
+
* `--tw-color-*` (#253), and both spellings are accepted.
|
|
2428
|
+
*/
|
|
2429
|
+
themeColorName(varName) {
|
|
2430
|
+
return colorNameOf(varName, this._prefix);
|
|
2431
|
+
}
|
|
2417
2432
|
/** The colors the project's theme declares, by name (`brand`, `primary`), sorted. */
|
|
2418
2433
|
projectColors() {
|
|
2419
2434
|
return this.projectColorNames;
|
|
@@ -3523,10 +3538,11 @@ async function main() {
|
|
|
3523
3538
|
//
|
|
3524
3539
|
// Functional variants (\`group-*\`, \`peer-*\`, \`data-*\`, \`nth-*\`) are skipped:
|
|
3525
3540
|
// probing them would need a value, and none of them retargets the selector.
|
|
3526
|
-
// Measured in Tailwind 4.3.
|
|
3527
|
-
//
|
|
3528
|
-
//
|
|
3529
|
-
//
|
|
3541
|
+
// Measured in Tailwind 4.3.5: \`group-hover\`/\`peer-checked\` compile to
|
|
3542
|
+
// \`:is(:where(.group):hover .x)\` (since tailwindlabs/tailwindcss#20513; 4.3.3
|
|
3543
|
+
// printed \`&:is(:where(.group):hover *)\`) — either way a condition on the
|
|
3544
|
+
// element itself — so two of them in either order produce equivalent selectors
|
|
3545
|
+
// and neither is a reordering barrier.
|
|
3530
3546
|
const variantFacts = {};
|
|
3531
3547
|
const probeNames = [];
|
|
3532
3548
|
for (let i = 0; i < variants.length; i++) {
|
|
@@ -3598,13 +3614,15 @@ async function main() {
|
|
|
3598
3614
|
// Tailwind's default palette (\`@theme default\`, theme option DEFAULT = 4)
|
|
3599
3615
|
// apart from the colors the project declares, for no-default-palette. A
|
|
3600
3616
|
// project that redefines a palette color owns it: its entry loses the flag.
|
|
3617
|
+
// Under a prefix the theme names them \`--tw-color-*\`, as the CSS reads them (#253).
|
|
3601
3618
|
const paletteVars = [];
|
|
3602
3619
|
const projectColorVars = [];
|
|
3620
|
+
const colorNamespace = prefix ? '--' + prefix + '-color-' : '--color-';
|
|
3603
3621
|
if (ds.theme && typeof ds.theme.entries === 'function') {
|
|
3604
3622
|
for (const [name, entry] of ds.theme.entries()) {
|
|
3605
3623
|
const value = entry && typeof entry.value === 'string' ? entry.value : '';
|
|
3606
3624
|
themeValues.set(name, value);
|
|
3607
|
-
if (name.startsWith(
|
|
3625
|
+
if (name.startsWith(colorNamespace)) {
|
|
3608
3626
|
if (entry && (entry.options & 4)) paletteVars.push(name);
|
|
3609
3627
|
else projectColorVars.push(name);
|
|
3610
3628
|
}
|
|
@@ -4589,7 +4607,10 @@ async function main() {
|
|
|
4589
4607
|
const handler = ${handlerExpr};
|
|
4590
4608
|
|
|
4591
4609
|
while (true) {
|
|
4592
|
-
|
|
4610
|
+
// Wait on the flag, not on the wake-up: the host's \`notify\` is a separate
|
|
4611
|
+
// step from its \`store\`, so a late one can land on this wait after the
|
|
4612
|
+
// request it announced was already served (#251).
|
|
4613
|
+
while (Atomics.load(control, 0) === 0) Atomics.wait(control, 0, 0);
|
|
4593
4614
|
const len = lengthView.getUint32(0);
|
|
4594
4615
|
const requestStr = Buffer.from(dataArea.slice(0, len)).toString('utf-8');
|
|
4595
4616
|
Atomics.store(control, 0, 0);
|
|
@@ -4779,7 +4800,16 @@ var DesignSystemWorker = class {
|
|
|
4779
4800
|
state.lengthView.setUint32(0, requestBytes.length);
|
|
4780
4801
|
Atomics.store(state.controlArray, 0, 1);
|
|
4781
4802
|
Atomics.notify(state.controlArray, 0);
|
|
4782
|
-
|
|
4803
|
+
const deadline = Date.now() + this.requestTimeoutMs;
|
|
4804
|
+
let timedOut = false;
|
|
4805
|
+
while (Atomics.load(state.controlArray, 1) === 0) {
|
|
4806
|
+
const left = deadline - Date.now();
|
|
4807
|
+
if (left <= 0 || Atomics.wait(state.controlArray, 1, 0, left) === "timed-out") {
|
|
4808
|
+
timedOut = Atomics.load(state.controlArray, 1) === 0;
|
|
4809
|
+
break;
|
|
4810
|
+
}
|
|
4811
|
+
}
|
|
4812
|
+
if (timedOut) throw this.failRequest(cssPath, new SortServiceError(`${this.opts.serviceName} worker request timed out after ${this.requestTimeoutMs}ms.`, "A slow machine or CI runner can cause this. If the class lists are valid, raise OXLINT_TAILWINDCSS_WORKER_REQUEST_TIMEOUT; otherwise please open an issue."));
|
|
4783
4813
|
const responseLen = state.lengthView.getUint32(0);
|
|
4784
4814
|
const responseStr = Buffer.from(state.dataArea.slice(0, responseLen)).toString("utf-8");
|
|
4785
4815
|
Atomics.store(state.controlArray, 1, 0);
|
|
@@ -5344,7 +5374,7 @@ function resolveByGlobMapping(mappings, filePath, baseDir) {
|
|
|
5344
5374
|
}
|
|
5345
5375
|
/**
|
|
5346
5376
|
* oxlint discovers nested configuration by walking up from each linted file
|
|
5347
|
-
* looking for files with these names (oxlint 1.
|
|
5377
|
+
* looking for files with these names (oxlint 1.93: JSON, JSONC, and the JS
|
|
5348
5378
|
* configs it loads through Node). We mirror that walk to find the config
|
|
5349
5379
|
* directory a relative `entryPoint` should be anchored to — which is also
|
|
5350
5380
|
* where an `oxlint.config.ts` passes it through `oxlint-tailwindcss/config`.
|
|
@@ -8286,16 +8316,16 @@ function withoutVarGroups(value) {
|
|
|
8286
8316
|
}
|
|
8287
8317
|
/**
|
|
8288
8318
|
* The colour property a class sets, read from the CSS it emits — a colour
|
|
8289
|
-
* property, a read of a `--color-*` theme variable
|
|
8290
|
-
* null when it sets none. Descendant and pseudo-element declarations count
|
|
8319
|
+
* property, a read of a `--color-*` theme variable (`--tw-color-*` under a
|
|
8320
|
+
* prefix, #253), or a colour literal — or null when it sets none. Descendant and pseudo-element declarations count
|
|
8291
8321
|
* (`divide-*`, `placeholder-*` colour other boxes); `@media`-conditional ones
|
|
8292
8322
|
* don't.
|
|
8293
8323
|
*/
|
|
8294
|
-
function colorPropertyOf(decls) {
|
|
8324
|
+
function colorPropertyOf(decls, cache) {
|
|
8295
8325
|
const own = decls.filter((d) => !d.conditional);
|
|
8296
8326
|
for (const d of own) if (COLOR_PROPERTY.test(d.prop)) return d.prop;
|
|
8297
8327
|
for (const d of own) {
|
|
8298
|
-
if (d.readsVars.some((v) =>
|
|
8328
|
+
if (d.readsVars.some((v) => cache.themeColorName(v) !== null)) return d.prop;
|
|
8299
8329
|
if (COLOR_LITERAL.test(withoutVarGroups(d.value))) return d.prop;
|
|
8300
8330
|
}
|
|
8301
8331
|
return null;
|
|
@@ -8413,8 +8443,8 @@ const noDarkWithoutLight = defineRule({
|
|
|
8413
8443
|
if (variant !== void 0) {
|
|
8414
8444
|
const decls = cache ? cache.getCssDeclarations(bare) : [];
|
|
8415
8445
|
let colorProperty;
|
|
8416
|
-
if (decls.length > 0) {
|
|
8417
|
-
const found = colorPropertyOf(decls);
|
|
8446
|
+
if (cache && decls.length > 0) {
|
|
8447
|
+
const found = colorPropertyOf(decls, cache);
|
|
8418
8448
|
if (found === null) continue;
|
|
8419
8449
|
colorProperty = found;
|
|
8420
8450
|
} else if (isNeverColorStatic(bare)) continue;
|
|
@@ -9968,7 +9998,8 @@ const noDynamicClasses = defineRule({
|
|
|
9968
9998
|
}
|
|
9969
9999
|
});
|
|
9970
10000
|
// src/rules/no-default-palette.ts
|
|
9971
|
-
|
|
10001
|
+
/** An arbitrary value reading a theme color: `var(--color-…)`, or `var(--tw-color-…)` under a prefix. */
|
|
10002
|
+
const COLOR_VAR_READ = /var\(--(?:[a-z0-9]+-)?color-/;
|
|
9972
10003
|
/** `white`, `gray-*` → a test on palette color names. */
|
|
9973
10004
|
function compileAllow(allow) {
|
|
9974
10005
|
const exact = new Set(allow.filter((a) => !a.endsWith("*")));
|
|
@@ -9980,11 +10011,11 @@ function paletteColorOf(cls, cache, entryPoint) {
|
|
|
9980
10011
|
const { bare } = splitImportant(splitUtilityAndVariant(cls).utility);
|
|
9981
10012
|
const base = bare.replace(/\/[^/\]]+$/, "");
|
|
9982
10013
|
let decls = cache.getCssDeclarations(base);
|
|
9983
|
-
if (decls.length === 0 &&
|
|
10014
|
+
if (decls.length === 0 && COLOR_VAR_READ.test(base)) {
|
|
9984
10015
|
resolveDeclarationsSync(entryPoint, cache, [base]);
|
|
9985
10016
|
decls = cache.getCssDeclarations(base);
|
|
9986
10017
|
}
|
|
9987
|
-
for (const decl of decls) for (const read of decl.readsVars) if (cache.isPaletteVar(read)) return
|
|
10018
|
+
for (const decl of decls) for (const read of decl.readsVars) if (cache.isPaletteVar(read)) return cache.themeColorName(read);
|
|
9988
10019
|
return null;
|
|
9989
10020
|
}
|
|
9990
10021
|
const noDefaultPalette = defineRule({
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "oxlint-tailwindcss",
|
|
3
|
-
"version": "1.17.
|
|
3
|
+
"version": "1.17.2",
|
|
4
4
|
"description": "Tailwind CSS v4 lint rules for oxlint that read your design system: unknown, conflicting and deprecated classes, theme colors, class order — with autofixes.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"classnames",
|
|
@@ -66,8 +66,8 @@
|
|
|
66
66
|
"prepublishOnly": "pnpm run build"
|
|
67
67
|
},
|
|
68
68
|
"dependencies": {
|
|
69
|
-
"@tailwindcss/node": "^4.3.
|
|
70
|
-
"tailwindcss": "^4.3.
|
|
69
|
+
"@tailwindcss/node": "^4.3.5",
|
|
70
|
+
"tailwindcss": "^4.3.5"
|
|
71
71
|
},
|
|
72
72
|
"devDependencies": {
|
|
73
73
|
"@oxlint/plugins": "catalog:",
|
|
@@ -75,10 +75,10 @@
|
|
|
75
75
|
"@types/node": "^26.6.6",
|
|
76
76
|
"oxlint": "catalog:",
|
|
77
77
|
"tailwindcss-animate": "^1.0.7",
|
|
78
|
-
"tsdown": "^0.23.
|
|
78
|
+
"tsdown": "^0.23.7",
|
|
79
79
|
"tw-animate-css": "^1.4.0",
|
|
80
80
|
"typescript": "^7.0.2",
|
|
81
|
-
"vitest": "^5.0
|
|
81
|
+
"vitest": "^5.1.0"
|
|
82
82
|
},
|
|
83
83
|
"engines": {
|
|
84
84
|
"node": "^20.19.0 || >=22.12.0"
|