oxlint-tailwindcss 1.17.0 → 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 +131 -42
- package/dist/index.mjs +133 -44
- package/package.json +6 -6
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
|
}
|
|
@@ -3807,7 +3825,60 @@ function computeContentHash(content, engineVersion) {
|
|
|
3807
3825
|
}
|
|
3808
3826
|
const IMPORT_RE = /@import\s+(?:url\(\s*)?['"]([^'"]+)['"]/g;
|
|
3809
3827
|
const PLUGIN_RE = /@(?:plugin|config)\s+['"]([^'"]+)['"]/g;
|
|
3828
|
+
const JS_IMPORT_RE = /\b(?:from|import|require)\s*\(?\s*['"]([^'"\r\n]+)['"]/g;
|
|
3829
|
+
const JS_FIRST = [
|
|
3830
|
+
"",
|
|
3831
|
+
".js",
|
|
3832
|
+
".cjs",
|
|
3833
|
+
".mjs",
|
|
3834
|
+
".ts",
|
|
3835
|
+
".cts",
|
|
3836
|
+
".mts",
|
|
3837
|
+
".jsx",
|
|
3838
|
+
".tsx"
|
|
3839
|
+
];
|
|
3840
|
+
const TS_FIRST = [
|
|
3841
|
+
"",
|
|
3842
|
+
".ts",
|
|
3843
|
+
".cts",
|
|
3844
|
+
".mts",
|
|
3845
|
+
".tsx",
|
|
3846
|
+
".js",
|
|
3847
|
+
".cjs",
|
|
3848
|
+
".mjs",
|
|
3849
|
+
".jsx"
|
|
3850
|
+
];
|
|
3851
|
+
const TS_TWINS = {
|
|
3852
|
+
".js": [".ts", ".tsx"],
|
|
3853
|
+
".jsx": [".tsx"],
|
|
3854
|
+
".mjs": [".mts"],
|
|
3855
|
+
".cjs": [".cts"]
|
|
3856
|
+
};
|
|
3810
3857
|
const isPathSpecifier = (spec) => spec.startsWith(".") || spec.startsWith("/") || /^[a-zA-Z]:[\\/]/.test(spec);
|
|
3858
|
+
const isFile = (path) => {
|
|
3859
|
+
try {
|
|
3860
|
+
return (0, node_fs.statSync)(path).isFile();
|
|
3861
|
+
} catch {
|
|
3862
|
+
return false;
|
|
3863
|
+
}
|
|
3864
|
+
};
|
|
3865
|
+
/** The file a relative import from `importer` loads, found as Tailwind does, or `null`. */
|
|
3866
|
+
function resolveLocalModule(importer, spec) {
|
|
3867
|
+
const base = (0, node_path.resolve)((0, node_path.dirname)(importer), spec);
|
|
3868
|
+
const exts = [
|
|
3869
|
+
".js",
|
|
3870
|
+
".cjs",
|
|
3871
|
+
".mjs"
|
|
3872
|
+
].includes((0, node_path.extname)(importer)) ? JS_FIRST : TS_FIRST;
|
|
3873
|
+
for (const ext of exts) if (isFile(base + ext)) return base + ext;
|
|
3874
|
+
for (const ext of exts) if (isFile((0, node_path.join)(base, `index${ext}`))) return (0, node_path.join)(base, `index${ext}`);
|
|
3875
|
+
const ext = (0, node_path.extname)(base);
|
|
3876
|
+
for (const twin of TS_TWINS[ext] ?? []) {
|
|
3877
|
+
const path = base.slice(0, -ext.length) + twin;
|
|
3878
|
+
if (isFile(path)) return path;
|
|
3879
|
+
}
|
|
3880
|
+
return null;
|
|
3881
|
+
}
|
|
3811
3882
|
/** The package a bare specifier names: `@scope/name/sub` → `@scope/name`, `name/sub` → `name`. */
|
|
3812
3883
|
function packageNameOf(spec) {
|
|
3813
3884
|
const parts = spec.split("/");
|
|
@@ -3840,11 +3911,13 @@ function packageVersionFrom(fromDir, name) {
|
|
|
3840
3911
|
* depth (DS-A2: editing `@import "./theme.css"` served a stale design
|
|
3841
3912
|
* system until the entry was touched);
|
|
3842
3913
|
* - local `@plugin` / `@config` files (`@plugin "./my-plugin.js"`), read as
|
|
3843
|
-
* text
|
|
3914
|
+
* text, and every local module they import, recursively — the files
|
|
3915
|
+
* Tailwind's own watch mode rebuilds on (#245: a plugin re-exported from
|
|
3916
|
+
* `./impl.js` kept serving the old design system after `impl.js` changed);
|
|
3844
3917
|
* - the installed version of every PACKAGE the CSS imports or loads as a
|
|
3845
|
-
* plugin (`tw-animate-css`, `@tailwindcss/typography`)
|
|
3846
|
-
* folded into the hash says nothing about
|
|
3847
|
-
* keep serving the old class list (H19).
|
|
3918
|
+
* plugin (`tw-animate-css`, `@tailwindcss/typography`), or a local plugin
|
|
3919
|
+
* imports: the engine version folded into the hash says nothing about
|
|
3920
|
+
* them, so upgrading one used to keep serving the old class list (H19).
|
|
3848
3921
|
*
|
|
3849
3922
|
* Best-effort: an unreadable file contributes nothing and an unresolvable
|
|
3850
3923
|
* package contributes `name@?` — neither can be what the build loads either.
|
|
@@ -3862,23 +3935,27 @@ function hashableContent(entryPath, entryContent) {
|
|
|
3862
3935
|
return null;
|
|
3863
3936
|
}
|
|
3864
3937
|
};
|
|
3938
|
+
const collect = (re, content) => Array.from(content.matchAll(re), (m) => m[1].split("?")[0]);
|
|
3939
|
+
const addPackage = (fromDir, spec) => {
|
|
3940
|
+
const name = packageNameOf(spec);
|
|
3941
|
+
if (name) packages.add(packageVersionFrom(fromDir, name));
|
|
3942
|
+
};
|
|
3943
|
+
const visitJs = (path) => {
|
|
3944
|
+
const content = readOnce(path);
|
|
3945
|
+
if (content === null) return;
|
|
3946
|
+
parts.push(`js:${content}`);
|
|
3947
|
+
if ((0, node_path.extname)(path) === ".json") return;
|
|
3948
|
+
for (const spec of collect(JS_IMPORT_RE, content)) if (isPathSpecifier(spec)) {
|
|
3949
|
+
const target = resolveLocalModule(path, spec);
|
|
3950
|
+
if (target !== null) visitJs(target);
|
|
3951
|
+
} else if (!spec.startsWith("#") && !(0, node_module.isBuiltin)(spec)) addPackage((0, node_path.dirname)(path), spec);
|
|
3952
|
+
};
|
|
3865
3953
|
const visit = (cssPath, content, depth) => {
|
|
3866
3954
|
if (depth <= 0) return;
|
|
3867
3955
|
const baseDir = (0, node_path.dirname)(cssPath);
|
|
3868
|
-
const
|
|
3869
|
-
const out = [];
|
|
3870
|
-
re.lastIndex = 0;
|
|
3871
|
-
let m;
|
|
3872
|
-
while ((m = re.exec(content)) !== null) out.push(m[1].split("?")[0]);
|
|
3873
|
-
return out;
|
|
3874
|
-
};
|
|
3875
|
-
const addPackage = (spec) => {
|
|
3876
|
-
const name = packageNameOf(spec);
|
|
3877
|
-
if (name) packages.add(packageVersionFrom(baseDir, name));
|
|
3878
|
-
};
|
|
3879
|
-
for (const spec of collect(IMPORT_RE)) {
|
|
3956
|
+
for (const spec of collect(IMPORT_RE, content)) {
|
|
3880
3957
|
if (!isPathSpecifier(spec)) {
|
|
3881
|
-
addPackage(spec);
|
|
3958
|
+
addPackage(baseDir, spec);
|
|
3882
3959
|
continue;
|
|
3883
3960
|
}
|
|
3884
3961
|
const importPath = (0, node_path.resolve)(baseDir, spec);
|
|
@@ -3887,19 +3964,18 @@ function hashableContent(entryPath, entryContent) {
|
|
|
3887
3964
|
parts.push(importContent);
|
|
3888
3965
|
visit(importPath, importContent, depth - 1);
|
|
3889
3966
|
}
|
|
3890
|
-
for (const spec of collect(PLUGIN_RE)) {
|
|
3967
|
+
for (const spec of collect(PLUGIN_RE, content)) {
|
|
3891
3968
|
if (!isPathSpecifier(spec)) {
|
|
3892
|
-
addPackage(spec);
|
|
3969
|
+
addPackage(baseDir, spec);
|
|
3893
3970
|
continue;
|
|
3894
3971
|
}
|
|
3895
3972
|
let pluginPath;
|
|
3896
3973
|
try {
|
|
3897
3974
|
pluginPath = (0, node_module.createRequire)((0, node_path.join)(baseDir, "noop.js")).resolve(spec);
|
|
3898
3975
|
} catch {
|
|
3899
|
-
|
|
3976
|
+
pluginPath = resolveLocalModule(cssPath, spec);
|
|
3900
3977
|
}
|
|
3901
|
-
|
|
3902
|
-
if (pluginContent !== null) parts.push(`js:${pluginContent}`);
|
|
3978
|
+
if (pluginPath !== null) visitJs(pluginPath);
|
|
3903
3979
|
}
|
|
3904
3980
|
};
|
|
3905
3981
|
visit((0, node_path.resolve)(entryPath), entryContent, 4);
|
|
@@ -4529,7 +4605,10 @@ async function main() {
|
|
|
4529
4605
|
const handler = ${handlerExpr};
|
|
4530
4606
|
|
|
4531
4607
|
while (true) {
|
|
4532
|
-
|
|
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);
|
|
4533
4612
|
const len = lengthView.getUint32(0);
|
|
4534
4613
|
const requestStr = Buffer.from(dataArea.slice(0, len)).toString('utf-8');
|
|
4535
4614
|
Atomics.store(control, 0, 0);
|
|
@@ -4719,7 +4798,16 @@ var DesignSystemWorker = class {
|
|
|
4719
4798
|
state.lengthView.setUint32(0, requestBytes.length);
|
|
4720
4799
|
Atomics.store(state.controlArray, 0, 1);
|
|
4721
4800
|
Atomics.notify(state.controlArray, 0);
|
|
4722
|
-
|
|
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."));
|
|
4723
4811
|
const responseLen = state.lengthView.getUint32(0);
|
|
4724
4812
|
const responseStr = Buffer.from(state.dataArea.slice(0, responseLen)).toString("utf-8");
|
|
4725
4813
|
Atomics.store(state.controlArray, 1, 0);
|
|
@@ -5284,7 +5372,7 @@ function resolveByGlobMapping(mappings, filePath, baseDir) {
|
|
|
5284
5372
|
}
|
|
5285
5373
|
/**
|
|
5286
5374
|
* oxlint discovers nested configuration by walking up from each linted file
|
|
5287
|
-
* looking for files with these names (oxlint 1.
|
|
5375
|
+
* looking for files with these names (oxlint 1.93: JSON, JSONC, and the JS
|
|
5288
5376
|
* configs it loads through Node). We mirror that walk to find the config
|
|
5289
5377
|
* directory a relative `entryPoint` should be anchored to — which is also
|
|
5290
5378
|
* where an `oxlint.config.ts` passes it through `oxlint-tailwindcss/config`.
|
|
@@ -8226,16 +8314,16 @@ function withoutVarGroups(value) {
|
|
|
8226
8314
|
}
|
|
8227
8315
|
/**
|
|
8228
8316
|
* The colour property a class sets, read from the CSS it emits — a colour
|
|
8229
|
-
* property, a read of a `--color-*` theme variable
|
|
8230
|
-
* 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
|
|
8231
8319
|
* (`divide-*`, `placeholder-*` colour other boxes); `@media`-conditional ones
|
|
8232
8320
|
* don't.
|
|
8233
8321
|
*/
|
|
8234
|
-
function colorPropertyOf(decls) {
|
|
8322
|
+
function colorPropertyOf(decls, cache) {
|
|
8235
8323
|
const own = decls.filter((d) => !d.conditional);
|
|
8236
8324
|
for (const d of own) if (COLOR_PROPERTY.test(d.prop)) return d.prop;
|
|
8237
8325
|
for (const d of own) {
|
|
8238
|
-
if (d.readsVars.some((v) =>
|
|
8326
|
+
if (d.readsVars.some((v) => cache.themeColorName(v) !== null)) return d.prop;
|
|
8239
8327
|
if (COLOR_LITERAL.test(withoutVarGroups(d.value))) return d.prop;
|
|
8240
8328
|
}
|
|
8241
8329
|
return null;
|
|
@@ -8353,8 +8441,8 @@ const noDarkWithoutLight = defineRule({
|
|
|
8353
8441
|
if (variant !== void 0) {
|
|
8354
8442
|
const decls = cache ? cache.getCssDeclarations(bare) : [];
|
|
8355
8443
|
let colorProperty;
|
|
8356
|
-
if (decls.length > 0) {
|
|
8357
|
-
const found = colorPropertyOf(decls);
|
|
8444
|
+
if (cache && decls.length > 0) {
|
|
8445
|
+
const found = colorPropertyOf(decls, cache);
|
|
8358
8446
|
if (found === null) continue;
|
|
8359
8447
|
colorProperty = found;
|
|
8360
8448
|
} else if (isNeverColorStatic(bare)) continue;
|
|
@@ -9908,7 +9996,8 @@ const noDynamicClasses = defineRule({
|
|
|
9908
9996
|
}
|
|
9909
9997
|
});
|
|
9910
9998
|
// src/rules/no-default-palette.ts
|
|
9911
|
-
|
|
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-/;
|
|
9912
10001
|
/** `white`, `gray-*` → a test on palette color names. */
|
|
9913
10002
|
function compileAllow(allow) {
|
|
9914
10003
|
const exact = new Set(allow.filter((a) => !a.endsWith("*")));
|
|
@@ -9920,11 +10009,11 @@ function paletteColorOf(cls, cache, entryPoint) {
|
|
|
9920
10009
|
const { bare } = splitImportant(splitUtilityAndVariant(cls).utility);
|
|
9921
10010
|
const base = bare.replace(/\/[^/\]]+$/, "");
|
|
9922
10011
|
let decls = cache.getCssDeclarations(base);
|
|
9923
|
-
if (decls.length === 0 &&
|
|
10012
|
+
if (decls.length === 0 && COLOR_VAR_READ.test(base)) {
|
|
9924
10013
|
resolveDeclarationsSync(entryPoint, cache, [base]);
|
|
9925
10014
|
decls = cache.getCssDeclarations(base);
|
|
9926
10015
|
}
|
|
9927
|
-
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);
|
|
9928
10017
|
return null;
|
|
9929
10018
|
}
|
|
9930
10019
|
const noDefaultPalette = defineRule({
|
package/dist/index.mjs
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { createRequire } from "node:module";
|
|
1
|
+
import { createRequire, isBuiltin } from "node:module";
|
|
2
2
|
import { Worker, threadId } from "node:worker_threads";
|
|
3
3
|
import { createHash } from "node:crypto";
|
|
4
4
|
import { closeSync, existsSync, mkdirSync, openSync, readFileSync, readdirSync, realpathSync, renameSync, statSync, unlinkSync, utimesSync, writeFileSync } from "node:fs";
|
|
5
|
-
import { dirname, isAbsolute, join, relative, resolve } from "node:path";
|
|
5
|
+
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
|
}
|
|
@@ -3809,7 +3827,60 @@ function computeContentHash(content, engineVersion) {
|
|
|
3809
3827
|
}
|
|
3810
3828
|
const IMPORT_RE = /@import\s+(?:url\(\s*)?['"]([^'"]+)['"]/g;
|
|
3811
3829
|
const PLUGIN_RE = /@(?:plugin|config)\s+['"]([^'"]+)['"]/g;
|
|
3830
|
+
const JS_IMPORT_RE = /\b(?:from|import|require)\s*\(?\s*['"]([^'"\r\n]+)['"]/g;
|
|
3831
|
+
const JS_FIRST = [
|
|
3832
|
+
"",
|
|
3833
|
+
".js",
|
|
3834
|
+
".cjs",
|
|
3835
|
+
".mjs",
|
|
3836
|
+
".ts",
|
|
3837
|
+
".cts",
|
|
3838
|
+
".mts",
|
|
3839
|
+
".jsx",
|
|
3840
|
+
".tsx"
|
|
3841
|
+
];
|
|
3842
|
+
const TS_FIRST = [
|
|
3843
|
+
"",
|
|
3844
|
+
".ts",
|
|
3845
|
+
".cts",
|
|
3846
|
+
".mts",
|
|
3847
|
+
".tsx",
|
|
3848
|
+
".js",
|
|
3849
|
+
".cjs",
|
|
3850
|
+
".mjs",
|
|
3851
|
+
".jsx"
|
|
3852
|
+
];
|
|
3853
|
+
const TS_TWINS = {
|
|
3854
|
+
".js": [".ts", ".tsx"],
|
|
3855
|
+
".jsx": [".tsx"],
|
|
3856
|
+
".mjs": [".mts"],
|
|
3857
|
+
".cjs": [".cts"]
|
|
3858
|
+
};
|
|
3812
3859
|
const isPathSpecifier = (spec) => spec.startsWith(".") || spec.startsWith("/") || /^[a-zA-Z]:[\\/]/.test(spec);
|
|
3860
|
+
const isFile = (path) => {
|
|
3861
|
+
try {
|
|
3862
|
+
return statSync(path).isFile();
|
|
3863
|
+
} catch {
|
|
3864
|
+
return false;
|
|
3865
|
+
}
|
|
3866
|
+
};
|
|
3867
|
+
/** The file a relative import from `importer` loads, found as Tailwind does, or `null`. */
|
|
3868
|
+
function resolveLocalModule(importer, spec) {
|
|
3869
|
+
const base = resolve(dirname(importer), spec);
|
|
3870
|
+
const exts = [
|
|
3871
|
+
".js",
|
|
3872
|
+
".cjs",
|
|
3873
|
+
".mjs"
|
|
3874
|
+
].includes(extname(importer)) ? JS_FIRST : TS_FIRST;
|
|
3875
|
+
for (const ext of exts) if (isFile(base + ext)) return base + ext;
|
|
3876
|
+
for (const ext of exts) if (isFile(join(base, `index${ext}`))) return join(base, `index${ext}`);
|
|
3877
|
+
const ext = extname(base);
|
|
3878
|
+
for (const twin of TS_TWINS[ext] ?? []) {
|
|
3879
|
+
const path = base.slice(0, -ext.length) + twin;
|
|
3880
|
+
if (isFile(path)) return path;
|
|
3881
|
+
}
|
|
3882
|
+
return null;
|
|
3883
|
+
}
|
|
3813
3884
|
/** The package a bare specifier names: `@scope/name/sub` → `@scope/name`, `name/sub` → `name`. */
|
|
3814
3885
|
function packageNameOf(spec) {
|
|
3815
3886
|
const parts = spec.split("/");
|
|
@@ -3842,11 +3913,13 @@ function packageVersionFrom(fromDir, name) {
|
|
|
3842
3913
|
* depth (DS-A2: editing `@import "./theme.css"` served a stale design
|
|
3843
3914
|
* system until the entry was touched);
|
|
3844
3915
|
* - local `@plugin` / `@config` files (`@plugin "./my-plugin.js"`), read as
|
|
3845
|
-
* text
|
|
3916
|
+
* text, and every local module they import, recursively — the files
|
|
3917
|
+
* Tailwind's own watch mode rebuilds on (#245: a plugin re-exported from
|
|
3918
|
+
* `./impl.js` kept serving the old design system after `impl.js` changed);
|
|
3846
3919
|
* - the installed version of every PACKAGE the CSS imports or loads as a
|
|
3847
|
-
* plugin (`tw-animate-css`, `@tailwindcss/typography`)
|
|
3848
|
-
* folded into the hash says nothing about
|
|
3849
|
-
* keep serving the old class list (H19).
|
|
3920
|
+
* plugin (`tw-animate-css`, `@tailwindcss/typography`), or a local plugin
|
|
3921
|
+
* imports: the engine version folded into the hash says nothing about
|
|
3922
|
+
* them, so upgrading one used to keep serving the old class list (H19).
|
|
3850
3923
|
*
|
|
3851
3924
|
* Best-effort: an unreadable file contributes nothing and an unresolvable
|
|
3852
3925
|
* package contributes `name@?` — neither can be what the build loads either.
|
|
@@ -3864,23 +3937,27 @@ function hashableContent(entryPath, entryContent) {
|
|
|
3864
3937
|
return null;
|
|
3865
3938
|
}
|
|
3866
3939
|
};
|
|
3940
|
+
const collect = (re, content) => Array.from(content.matchAll(re), (m) => m[1].split("?")[0]);
|
|
3941
|
+
const addPackage = (fromDir, spec) => {
|
|
3942
|
+
const name = packageNameOf(spec);
|
|
3943
|
+
if (name) packages.add(packageVersionFrom(fromDir, name));
|
|
3944
|
+
};
|
|
3945
|
+
const visitJs = (path) => {
|
|
3946
|
+
const content = readOnce(path);
|
|
3947
|
+
if (content === null) return;
|
|
3948
|
+
parts.push(`js:${content}`);
|
|
3949
|
+
if (extname(path) === ".json") return;
|
|
3950
|
+
for (const spec of collect(JS_IMPORT_RE, content)) if (isPathSpecifier(spec)) {
|
|
3951
|
+
const target = resolveLocalModule(path, spec);
|
|
3952
|
+
if (target !== null) visitJs(target);
|
|
3953
|
+
} else if (!spec.startsWith("#") && !isBuiltin(spec)) addPackage(dirname(path), spec);
|
|
3954
|
+
};
|
|
3867
3955
|
const visit = (cssPath, content, depth) => {
|
|
3868
3956
|
if (depth <= 0) return;
|
|
3869
3957
|
const baseDir = dirname(cssPath);
|
|
3870
|
-
const
|
|
3871
|
-
const out = [];
|
|
3872
|
-
re.lastIndex = 0;
|
|
3873
|
-
let m;
|
|
3874
|
-
while ((m = re.exec(content)) !== null) out.push(m[1].split("?")[0]);
|
|
3875
|
-
return out;
|
|
3876
|
-
};
|
|
3877
|
-
const addPackage = (spec) => {
|
|
3878
|
-
const name = packageNameOf(spec);
|
|
3879
|
-
if (name) packages.add(packageVersionFrom(baseDir, name));
|
|
3880
|
-
};
|
|
3881
|
-
for (const spec of collect(IMPORT_RE)) {
|
|
3958
|
+
for (const spec of collect(IMPORT_RE, content)) {
|
|
3882
3959
|
if (!isPathSpecifier(spec)) {
|
|
3883
|
-
addPackage(spec);
|
|
3960
|
+
addPackage(baseDir, spec);
|
|
3884
3961
|
continue;
|
|
3885
3962
|
}
|
|
3886
3963
|
const importPath = resolve(baseDir, spec);
|
|
@@ -3889,19 +3966,18 @@ function hashableContent(entryPath, entryContent) {
|
|
|
3889
3966
|
parts.push(importContent);
|
|
3890
3967
|
visit(importPath, importContent, depth - 1);
|
|
3891
3968
|
}
|
|
3892
|
-
for (const spec of collect(PLUGIN_RE)) {
|
|
3969
|
+
for (const spec of collect(PLUGIN_RE, content)) {
|
|
3893
3970
|
if (!isPathSpecifier(spec)) {
|
|
3894
|
-
addPackage(spec);
|
|
3971
|
+
addPackage(baseDir, spec);
|
|
3895
3972
|
continue;
|
|
3896
3973
|
}
|
|
3897
3974
|
let pluginPath;
|
|
3898
3975
|
try {
|
|
3899
3976
|
pluginPath = createRequire(join(baseDir, "noop.js")).resolve(spec);
|
|
3900
3977
|
} catch {
|
|
3901
|
-
|
|
3978
|
+
pluginPath = resolveLocalModule(cssPath, spec);
|
|
3902
3979
|
}
|
|
3903
|
-
|
|
3904
|
-
if (pluginContent !== null) parts.push(`js:${pluginContent}`);
|
|
3980
|
+
if (pluginPath !== null) visitJs(pluginPath);
|
|
3905
3981
|
}
|
|
3906
3982
|
};
|
|
3907
3983
|
visit(resolve(entryPath), entryContent, 4);
|
|
@@ -4531,7 +4607,10 @@ async function main() {
|
|
|
4531
4607
|
const handler = ${handlerExpr};
|
|
4532
4608
|
|
|
4533
4609
|
while (true) {
|
|
4534
|
-
|
|
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);
|
|
4535
4614
|
const len = lengthView.getUint32(0);
|
|
4536
4615
|
const requestStr = Buffer.from(dataArea.slice(0, len)).toString('utf-8');
|
|
4537
4616
|
Atomics.store(control, 0, 0);
|
|
@@ -4721,7 +4800,16 @@ var DesignSystemWorker = class {
|
|
|
4721
4800
|
state.lengthView.setUint32(0, requestBytes.length);
|
|
4722
4801
|
Atomics.store(state.controlArray, 0, 1);
|
|
4723
4802
|
Atomics.notify(state.controlArray, 0);
|
|
4724
|
-
|
|
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."));
|
|
4725
4813
|
const responseLen = state.lengthView.getUint32(0);
|
|
4726
4814
|
const responseStr = Buffer.from(state.dataArea.slice(0, responseLen)).toString("utf-8");
|
|
4727
4815
|
Atomics.store(state.controlArray, 1, 0);
|
|
@@ -5286,7 +5374,7 @@ function resolveByGlobMapping(mappings, filePath, baseDir) {
|
|
|
5286
5374
|
}
|
|
5287
5375
|
/**
|
|
5288
5376
|
* oxlint discovers nested configuration by walking up from each linted file
|
|
5289
|
-
* looking for files with these names (oxlint 1.
|
|
5377
|
+
* looking for files with these names (oxlint 1.93: JSON, JSONC, and the JS
|
|
5290
5378
|
* configs it loads through Node). We mirror that walk to find the config
|
|
5291
5379
|
* directory a relative `entryPoint` should be anchored to — which is also
|
|
5292
5380
|
* where an `oxlint.config.ts` passes it through `oxlint-tailwindcss/config`.
|
|
@@ -8228,16 +8316,16 @@ function withoutVarGroups(value) {
|
|
|
8228
8316
|
}
|
|
8229
8317
|
/**
|
|
8230
8318
|
* The colour property a class sets, read from the CSS it emits — a colour
|
|
8231
|
-
* property, a read of a `--color-*` theme variable
|
|
8232
|
-
* 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
|
|
8233
8321
|
* (`divide-*`, `placeholder-*` colour other boxes); `@media`-conditional ones
|
|
8234
8322
|
* don't.
|
|
8235
8323
|
*/
|
|
8236
|
-
function colorPropertyOf(decls) {
|
|
8324
|
+
function colorPropertyOf(decls, cache) {
|
|
8237
8325
|
const own = decls.filter((d) => !d.conditional);
|
|
8238
8326
|
for (const d of own) if (COLOR_PROPERTY.test(d.prop)) return d.prop;
|
|
8239
8327
|
for (const d of own) {
|
|
8240
|
-
if (d.readsVars.some((v) =>
|
|
8328
|
+
if (d.readsVars.some((v) => cache.themeColorName(v) !== null)) return d.prop;
|
|
8241
8329
|
if (COLOR_LITERAL.test(withoutVarGroups(d.value))) return d.prop;
|
|
8242
8330
|
}
|
|
8243
8331
|
return null;
|
|
@@ -8355,8 +8443,8 @@ const noDarkWithoutLight = defineRule({
|
|
|
8355
8443
|
if (variant !== void 0) {
|
|
8356
8444
|
const decls = cache ? cache.getCssDeclarations(bare) : [];
|
|
8357
8445
|
let colorProperty;
|
|
8358
|
-
if (decls.length > 0) {
|
|
8359
|
-
const found = colorPropertyOf(decls);
|
|
8446
|
+
if (cache && decls.length > 0) {
|
|
8447
|
+
const found = colorPropertyOf(decls, cache);
|
|
8360
8448
|
if (found === null) continue;
|
|
8361
8449
|
colorProperty = found;
|
|
8362
8450
|
} else if (isNeverColorStatic(bare)) continue;
|
|
@@ -9910,7 +9998,8 @@ const noDynamicClasses = defineRule({
|
|
|
9910
9998
|
}
|
|
9911
9999
|
});
|
|
9912
10000
|
// src/rules/no-default-palette.ts
|
|
9913
|
-
|
|
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-/;
|
|
9914
10003
|
/** `white`, `gray-*` → a test on palette color names. */
|
|
9915
10004
|
function compileAllow(allow) {
|
|
9916
10005
|
const exact = new Set(allow.filter((a) => !a.endsWith("*")));
|
|
@@ -9922,11 +10011,11 @@ function paletteColorOf(cls, cache, entryPoint) {
|
|
|
9922
10011
|
const { bare } = splitImportant(splitUtilityAndVariant(cls).utility);
|
|
9923
10012
|
const base = bare.replace(/\/[^/\]]+$/, "");
|
|
9924
10013
|
let decls = cache.getCssDeclarations(base);
|
|
9925
|
-
if (decls.length === 0 &&
|
|
10014
|
+
if (decls.length === 0 && COLOR_VAR_READ.test(base)) {
|
|
9926
10015
|
resolveDeclarationsSync(entryPoint, cache, [base]);
|
|
9927
10016
|
decls = cache.getCssDeclarations(base);
|
|
9928
10017
|
}
|
|
9929
|
-
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);
|
|
9930
10019
|
return null;
|
|
9931
10020
|
}
|
|
9932
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,19 +66,19 @@
|
|
|
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:",
|
|
74
74
|
"@tailwindcss/typography": "^0.5.20",
|
|
75
|
-
"@types/node": "^26.6.
|
|
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"
|