oxlint-tailwindcss 0.1.2 → 0.1.4
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 +42 -74
- package/dist/index.cjs +94 -36
- package/dist/index.mjs +94 -36
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -64,16 +64,35 @@ The plugin auto-detects your Tailwind CSS entry point. No configuration needed i
|
|
|
64
64
|
The plugin searches for a CSS file containing a Tailwind import signal (`@import "tailwindcss"`, `@import 'tailwindcss'`, `@import tailwindcss`, `@tailwind base`) in these locations, walking upward from the linted file:
|
|
65
65
|
|
|
66
66
|
```
|
|
67
|
-
src/
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
style.css styles/globals.css app/globals.css
|
|
71
|
-
assets/css/tailwind.css
|
|
67
|
+
src/{name}.css {name}.css app/{name}.css
|
|
68
|
+
styles/{name}.css style/{name}.css css/{name}.css
|
|
69
|
+
assets/{name}.css assets/css/{name}.css resources/css/{name}.css
|
|
72
70
|
```
|
|
73
71
|
|
|
72
|
+
Where `{name}` is one of: `app`, `globals`, `global`, `style`, `styles`, `index`, `main`, `tailwind`, `tailwindcss`.
|
|
73
|
+
|
|
74
74
|
The search is monorepo-aware — it stops at `package.json` boundaries so each package resolves its own Tailwind config.
|
|
75
75
|
|
|
76
|
-
|
|
76
|
+
If auto-detection doesn't find your CSS file, set `entryPoint` once in `settings`:
|
|
77
|
+
|
|
78
|
+
```jsonc
|
|
79
|
+
{
|
|
80
|
+
"jsPlugins": ["oxlint-tailwindcss"],
|
|
81
|
+
"settings": {
|
|
82
|
+
"tailwindcss": {
|
|
83
|
+
"entryPoint": "app/tailwind.css",
|
|
84
|
+
},
|
|
85
|
+
},
|
|
86
|
+
"rules": {
|
|
87
|
+
"tailwindcss/no-unknown-classes": "error",
|
|
88
|
+
// ...
|
|
89
|
+
},
|
|
90
|
+
}
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
The design system is loaded once and shared across all rules.
|
|
94
|
+
|
|
95
|
+
You can also override per rule if needed:
|
|
77
96
|
|
|
78
97
|
```jsonc
|
|
79
98
|
{
|
|
@@ -83,6 +102,10 @@ To override auto-detection, pass `entryPoint` as an option:
|
|
|
83
102
|
}
|
|
84
103
|
```
|
|
85
104
|
|
|
105
|
+
Resolution order: rule option > `settings.tailwindcss.entryPoint` > auto-detect.
|
|
106
|
+
|
|
107
|
+
If no entry point is found (neither configured nor auto-detected), rules that require the design system (`no-unknown-classes`, `no-conflicting-classes`, `no-deprecated-classes`, `enforce-canonical`, `enforce-sort-order`, `no-unnecessary-arbitrary-value`, `consistent-variant-order`) are silently disabled. All other rules work without it.
|
|
108
|
+
|
|
86
109
|
## Supported patterns
|
|
87
110
|
|
|
88
111
|
The plugin extracts Tailwind classes from:
|
|
@@ -98,18 +121,10 @@ The plugin extracts Tailwind classes from:
|
|
|
98
121
|
// Ternaries
|
|
99
122
|
<div className={active ? "bg-blue-500" : "bg-gray-200"} />
|
|
100
123
|
|
|
101
|
-
// Utility functions
|
|
124
|
+
// Utility functions (cn, clsx, cx, cva, twMerge, twJoin, classnames, ctl, cc, clb, cnb, objstr)
|
|
102
125
|
cn("flex items-center", condition && "hidden")
|
|
103
126
|
clsx("flex", { "bg-red-500": isError })
|
|
104
127
|
twMerge("p-4", "p-2")
|
|
105
|
-
cx("flex", "items-center")
|
|
106
|
-
classnames("flex", "items-center")
|
|
107
|
-
ctl("flex items-center")
|
|
108
|
-
twJoin("flex", "items-center")
|
|
109
|
-
cc("flex", "items-center")
|
|
110
|
-
clb("flex", "items-center")
|
|
111
|
-
cnb("flex", "items-center")
|
|
112
|
-
objstr({ "flex": true, "items-center": true })
|
|
113
128
|
|
|
114
129
|
// cva() — full extraction: base, variants, compoundVariants
|
|
115
130
|
cva("flex items-center", {
|
|
@@ -164,7 +179,6 @@ Reports classes not recognized by Tailwind CSS. Includes typo suggestions.
|
|
|
164
179
|
|
|
165
180
|
| Option | Type | Description |
|
|
166
181
|
| ---------------- | ---------- | ------------------------------------- |
|
|
167
|
-
| `entryPoint` | `string` | Path to Tailwind CSS entry file |
|
|
168
182
|
| `allowlist` | `string[]` | Custom classes to allow |
|
|
169
183
|
| `ignorePrefixes` | `string[]` | Prefixes to ignore (e.g. `["data-"]`) |
|
|
170
184
|
|
|
@@ -204,12 +218,6 @@ Detects classes that set the same CSS property. Reports which property conflicts
|
|
|
204
218
|
|
|
205
219
|
> **Note:** Shorthand vs longhand conflicts (e.g., `p-4` vs `px-2`) are not currently detected. See [Known limitations](#known-limitations).
|
|
206
220
|
|
|
207
|
-
**Options:**
|
|
208
|
-
|
|
209
|
-
| Option | Type | Description |
|
|
210
|
-
| ------------ | -------- | ------------------------------- |
|
|
211
|
-
| `entryPoint` | `string` | Path to Tailwind CSS entry file |
|
|
212
|
-
|
|
213
221
|
**Requires design system.** No autofix.
|
|
214
222
|
|
|
215
223
|
---
|
|
@@ -294,21 +302,14 @@ Detects variant-prefixed classes that are redundant because the base class alrea
|
|
|
294
302
|
<div className="flex dark:flex" />
|
|
295
303
|
<div className="hidden hover:hidden" />
|
|
296
304
|
|
|
297
|
-
// ✅ OK — different values,
|
|
305
|
+
// ✅ OK — different values, both conditional, or different selector targets
|
|
298
306
|
<div className="text-white dark:text-black" />
|
|
299
|
-
<div className="bg-white hover:bg-blue-500" />
|
|
300
|
-
|
|
301
|
-
// ✅ OK — no base class, both are conditional
|
|
302
307
|
<div className="hover:flex dark:flex" />
|
|
303
|
-
|
|
304
|
-
// ✅ OK — pseudo-elements and child selectors target different elements
|
|
305
308
|
<div className="absolute after:absolute" />
|
|
306
309
|
<div className="shrink-0 [&>svg]:shrink-0" />
|
|
307
|
-
<div className="bg-transparent file:bg-transparent" />
|
|
308
|
-
<div className="flex *:data-[slot=value]:flex" />
|
|
309
310
|
```
|
|
310
311
|
|
|
311
|
-
Only
|
|
312
|
+
Only flags when the exact same utility exists both as base and with a conditional variant. Variants that change the selector target (pseudo-elements, child/descendant selectors, arbitrary selectors) are not flagged.
|
|
312
313
|
|
|
313
314
|
**No options.** **No autofix.**
|
|
314
315
|
|
|
@@ -327,12 +328,6 @@ Suggests the canonical form of a class when a shorter equivalent exists. Only kn
|
|
|
327
328
|
"-p-0" → "p-0"
|
|
328
329
|
```
|
|
329
330
|
|
|
330
|
-
**Options:**
|
|
331
|
-
|
|
332
|
-
| Option | Type | Description |
|
|
333
|
-
| ------------ | -------- | ------------------------------- |
|
|
334
|
-
| `entryPoint` | `string` | Path to Tailwind CSS entry file |
|
|
335
|
-
|
|
336
331
|
**Requires design system.** **Autofix:** Replaces with canonical form.
|
|
337
332
|
|
|
338
333
|
---
|
|
@@ -361,10 +356,9 @@ In `strict` mode, classes are grouped by variant prefix, sorted within each grou
|
|
|
361
356
|
|
|
362
357
|
**Options:**
|
|
363
358
|
|
|
364
|
-
| Option
|
|
365
|
-
|
|
|
366
|
-
| `
|
|
367
|
-
| `mode` | `"default"` \| `"strict"` | `"default"` | Sort mode |
|
|
359
|
+
| Option | Type | Default | Description |
|
|
360
|
+
| ------ | ------------------------- | ----------- | ----------- |
|
|
361
|
+
| `mode` | `"default"` \| `"strict"` | `"default"` | Sort mode |
|
|
368
362
|
|
|
369
363
|
**Requires design system.** **Autofix:** Reorders classes.
|
|
370
364
|
|
|
@@ -404,22 +398,7 @@ Converts physical properties to logical ones for LTR/RTL support.
|
|
|
404
398
|
"right-0" → "end-0"
|
|
405
399
|
```
|
|
406
400
|
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
| Physical | Logical |
|
|
410
|
-
| --------------------------- | --------------------------- |
|
|
411
|
-
| `ml` | `ms` |
|
|
412
|
-
| `mr` | `me` |
|
|
413
|
-
| `pl` | `ps` |
|
|
414
|
-
| `pr` | `pe` |
|
|
415
|
-
| `left` | `start` |
|
|
416
|
-
| `right` | `end` |
|
|
417
|
-
| `border-l` / `border-r` | `border-s` / `border-e` |
|
|
418
|
-
| `rounded-l` / `rounded-r` | `rounded-s` / `rounded-e` |
|
|
419
|
-
| `rounded-tl` / `rounded-tr` | `rounded-ss` / `rounded-se` |
|
|
420
|
-
| `rounded-bl` / `rounded-br` | `rounded-es` / `rounded-ee` |
|
|
421
|
-
| `scroll-ml` / `scroll-mr` | `scroll-ms` / `scroll-me` |
|
|
422
|
-
| `scroll-pl` / `scroll-pr` | `scroll-ps` / `scroll-pe` |
|
|
401
|
+
Also converts `border-l/r`, `rounded-l/r/tl/tr/bl/br`, and `scroll-ml/mr/pl/pr` to their logical equivalents.
|
|
423
402
|
|
|
424
403
|
**Autofix:** Replaces with logical equivalent.
|
|
425
404
|
|
|
@@ -506,18 +485,13 @@ Does NOT convert complex expressions — only simple `var(--name)` wrappers:
|
|
|
506
485
|
|
|
507
486
|
Enforces a consistent order for variant prefixes.
|
|
508
487
|
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
A user-specified `order` option always takes the highest priority, overriding both the design system and the static default.
|
|
512
|
-
|
|
513
|
-
Only checks classes with 2+ variants. Single-variant classes are always valid.
|
|
488
|
+
Uses the design system's variant order when available, falls back to a sensible static default. Only checks classes with 2+ variants.
|
|
514
489
|
|
|
515
490
|
**Options:**
|
|
516
491
|
|
|
517
|
-
| Option
|
|
518
|
-
|
|
|
519
|
-
| `
|
|
520
|
-
| `order` | `string[]` | (DS order or builtin order) | Custom variant priority list |
|
|
492
|
+
| Option | Type | Default | Description |
|
|
493
|
+
| ------- | ---------- | --------------------------- | ---------------------------- |
|
|
494
|
+
| `order` | `string[]` | (DS order or builtin order) | Custom variant priority list |
|
|
521
495
|
|
|
522
496
|
**Optionally uses design system.** **Autofix:** Reorders variants.
|
|
523
497
|
|
|
@@ -570,7 +544,7 @@ Warns when a class string exceeds the configured print width or classes-per-line
|
|
|
570
544
|
| `printWidth` | `number` | `80` | Max class string length |
|
|
571
545
|
| `classesPerLine` | `number` | | Max classes per line |
|
|
572
546
|
|
|
573
|
-
**
|
|
547
|
+
**Autofix:** Only for `classesPerLine` with template literals.
|
|
574
548
|
|
|
575
549
|
---
|
|
576
550
|
|
|
@@ -639,7 +613,7 @@ Flags hardcoded color values in arbitrary brackets. Encourages use of design tok
|
|
|
639
613
|
<div className="tracking-[0.5em]" />
|
|
640
614
|
```
|
|
641
615
|
|
|
642
|
-
Detects hex, rgb/rgba, hsl/hsla, oklch, oklab,
|
|
616
|
+
Detects hex, rgb/rgba, hsl/hsla, oklch, oklab, and other color function values inside `[...]` on color-related utility prefixes (`bg-`, `text-`, `border-`, `ring-`, `shadow-`, `fill-`, `stroke-`, etc.).
|
|
643
617
|
|
|
644
618
|
**Options:**
|
|
645
619
|
|
|
@@ -665,12 +639,6 @@ Detects arbitrary values that have a named Tailwind equivalent. The arbitrary fo
|
|
|
665
639
|
"bg-[#custom]"
|
|
666
640
|
```
|
|
667
641
|
|
|
668
|
-
**Options:**
|
|
669
|
-
|
|
670
|
-
| Option | Type | Description |
|
|
671
|
-
| ------------ | -------- | ------------------------------- |
|
|
672
|
-
| `entryPoint` | `string` | Path to Tailwind CSS entry file |
|
|
673
|
-
|
|
674
642
|
**Requires design system.** **Autofix:** Replaces with named class.
|
|
675
643
|
|
|
676
644
|
---
|
package/dist/index.cjs
CHANGED
|
@@ -1,7 +1,19 @@
|
|
|
1
1
|
let _oxlint_plugins = require("@oxlint/plugins");
|
|
2
2
|
let node_child_process = require("node:child_process");
|
|
3
|
-
let
|
|
3
|
+
let node_crypto = require("node:crypto");
|
|
4
4
|
let node_fs = require("node:fs");
|
|
5
|
+
let node_path = require("node:path");
|
|
6
|
+
let node_os = require("node:os");
|
|
7
|
+
//#region src/utils/extractors.ts
|
|
8
|
+
/**
|
|
9
|
+
* Preserves leading/trailing spaces in fixed class strings for template literals.
|
|
10
|
+
* Without this, `h-3 w-3 ${x}` fixed to `size-3${x}` would break classes.
|
|
11
|
+
*/
|
|
12
|
+
function preserveSpaces(loc, fixed) {
|
|
13
|
+
if (loc.preserveLeadingSpace && !fixed.startsWith(" ")) fixed = ` ${fixed}`;
|
|
14
|
+
if (loc.preserveTrailingSpace && !fixed.endsWith(" ")) fixed = `${fixed} `;
|
|
15
|
+
return fixed;
|
|
16
|
+
}
|
|
5
17
|
const DEFAULT_EXTRACTOR_CONFIG = {
|
|
6
18
|
attributes: ["className", "class"],
|
|
7
19
|
callees: [
|
|
@@ -268,7 +280,7 @@ const noDuplicateClasses = (0, _oxlint_plugins.defineRule)({
|
|
|
268
280
|
messageId: "duplicate",
|
|
269
281
|
data: { className: dup },
|
|
270
282
|
fix(fixer) {
|
|
271
|
-
return fixer.replaceTextRange(loc.range, fixed);
|
|
283
|
+
return fixer.replaceTextRange(loc.range, preserveSpaces(loc, fixed));
|
|
272
284
|
}
|
|
273
285
|
});
|
|
274
286
|
}
|
|
@@ -684,9 +696,18 @@ async function main() {
|
|
|
684
696
|
}
|
|
685
697
|
main().catch(e => { process.stderr.write(e.message); process.exit(1); });
|
|
686
698
|
`;
|
|
699
|
+
const CACHE_DIR = (0, node_path.join)((0, node_os.tmpdir)(), "oxlint-tailwindcss");
|
|
700
|
+
function getCachePath(cssPath, mtime) {
|
|
701
|
+
return (0, node_path.join)(CACHE_DIR, `${(0, node_crypto.createHash)("md5").update(`${cssPath}:${mtime}`).digest("hex")}.json`);
|
|
702
|
+
}
|
|
687
703
|
function loadDesignSystemSync(cssPath) {
|
|
688
704
|
const resolvedPath = (0, node_path.resolve)(cssPath);
|
|
689
705
|
try {
|
|
706
|
+
const mtime = (0, node_fs.statSync)(resolvedPath).mtimeMs;
|
|
707
|
+
const cachePath = getCachePath(resolvedPath, mtime);
|
|
708
|
+
if ((0, node_fs.existsSync)(cachePath)) try {
|
|
709
|
+
return JSON.parse((0, node_fs.readFileSync)(cachePath, "utf-8"));
|
|
710
|
+
} catch {}
|
|
690
711
|
const stdout = (0, node_child_process.execFileSync)(process.execPath, ["-e", PRECOMPUTE_SCRIPT], {
|
|
691
712
|
encoding: "utf-8",
|
|
692
713
|
timeout: 3e4,
|
|
@@ -697,6 +718,10 @@ function loadDesignSystemSync(cssPath) {
|
|
|
697
718
|
},
|
|
698
719
|
cwd: (0, node_path.dirname)(resolvedPath)
|
|
699
720
|
});
|
|
721
|
+
try {
|
|
722
|
+
(0, node_fs.mkdirSync)(CACHE_DIR, { recursive: true });
|
|
723
|
+
(0, node_fs.writeFileSync)(cachePath, stdout);
|
|
724
|
+
} catch {}
|
|
700
725
|
return JSON.parse(stdout);
|
|
701
726
|
} catch (error) {
|
|
702
727
|
console.error(`[oxlint-tailwindcss] Failed to load design system from "${resolvedPath}":`, error instanceof Error ? error.message : error);
|
|
@@ -705,21 +730,29 @@ function loadDesignSystemSync(cssPath) {
|
|
|
705
730
|
}
|
|
706
731
|
//#endregion
|
|
707
732
|
//#region src/design-system/auto-detect.ts
|
|
708
|
-
const
|
|
709
|
-
"src
|
|
710
|
-
"
|
|
711
|
-
"
|
|
712
|
-
"
|
|
713
|
-
"
|
|
714
|
-
"
|
|
715
|
-
"
|
|
716
|
-
"
|
|
717
|
-
"
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
"app
|
|
721
|
-
"
|
|
733
|
+
const CANDIDATE_DIRS = [
|
|
734
|
+
"src",
|
|
735
|
+
".",
|
|
736
|
+
"app",
|
|
737
|
+
"styles",
|
|
738
|
+
"style",
|
|
739
|
+
"css",
|
|
740
|
+
"assets",
|
|
741
|
+
"assets/css",
|
|
742
|
+
"resources/css"
|
|
743
|
+
];
|
|
744
|
+
const CANDIDATE_NAMES = [
|
|
745
|
+
"app",
|
|
746
|
+
"globals",
|
|
747
|
+
"global",
|
|
748
|
+
"style",
|
|
749
|
+
"styles",
|
|
750
|
+
"index",
|
|
751
|
+
"main",
|
|
752
|
+
"tailwind",
|
|
753
|
+
"tailwindcss"
|
|
722
754
|
];
|
|
755
|
+
const CANDIDATE_PATHS = CANDIDATE_DIRS.flatMap((dir) => CANDIDATE_NAMES.map((name) => dir === "." ? `${name}.css` : `${dir}/${name}.css`));
|
|
723
756
|
const TAILWIND_SIGNALS = [
|
|
724
757
|
"@import \"tailwindcss\"",
|
|
725
758
|
"@import 'tailwindcss'",
|
|
@@ -766,12 +799,24 @@ function autoDetectEntryPoint(filePath) {
|
|
|
766
799
|
//#region src/design-system/loader.ts
|
|
767
800
|
let singleton = null;
|
|
768
801
|
/**
|
|
802
|
+
* Extracts `entryPoint` from `context.settings.tailwindcss`.
|
|
803
|
+
*/
|
|
804
|
+
function entryPointFromSettings(settings) {
|
|
805
|
+
const tw = settings?.tailwindcss;
|
|
806
|
+
if (tw && typeof tw === "object" && "entryPoint" in tw) {
|
|
807
|
+
const ep = tw.entryPoint;
|
|
808
|
+
if (typeof ep === "string") return ep;
|
|
809
|
+
}
|
|
810
|
+
}
|
|
811
|
+
/**
|
|
769
812
|
* Returns the design system cache, loading synchronously on first call.
|
|
770
813
|
* Uses execFileSync internally to bridge the async Tailwind API.
|
|
771
814
|
* All rules receive the SAME instance.
|
|
815
|
+
*
|
|
816
|
+
* Resolution order: rule option `entryPoint` > `settings.tailwindcss.entryPoint` > auto-detect.
|
|
772
817
|
*/
|
|
773
|
-
function getLoadedDesignSystem(entryPoint) {
|
|
774
|
-
const cssPath = entryPoint ?? singleton?.path ?? autoDetectEntryPoint();
|
|
818
|
+
function getLoadedDesignSystem(entryPoint, settings) {
|
|
819
|
+
const cssPath = entryPoint ?? entryPointFromSettings(settings) ?? singleton?.path ?? autoDetectEntryPoint();
|
|
775
820
|
if (!cssPath) return null;
|
|
776
821
|
const resolvedPath = (0, node_path.resolve)(cssPath);
|
|
777
822
|
try {
|
|
@@ -814,6 +859,19 @@ function safeOptions(context) {
|
|
|
814
859
|
return;
|
|
815
860
|
}
|
|
816
861
|
}
|
|
862
|
+
/**
|
|
863
|
+
* Safely read context.settings.
|
|
864
|
+
*
|
|
865
|
+
* Like `safeOptions`, `context.settings` may not be accessible in `createOnce()`.
|
|
866
|
+
* The try/catch handles that gracefully.
|
|
867
|
+
*/
|
|
868
|
+
function safeSettings(context) {
|
|
869
|
+
try {
|
|
870
|
+
return context.settings ?? void 0;
|
|
871
|
+
} catch {
|
|
872
|
+
return;
|
|
873
|
+
}
|
|
874
|
+
}
|
|
817
875
|
//#endregion
|
|
818
876
|
//#region src/rules/no-unknown-classes.ts
|
|
819
877
|
const noUnknownClasses = (0, _oxlint_plugins.defineRule)({
|
|
@@ -842,7 +900,7 @@ const noUnknownClasses = (0, _oxlint_plugins.defineRule)({
|
|
|
842
900
|
},
|
|
843
901
|
createOnce(context) {
|
|
844
902
|
const options = safeOptions(context);
|
|
845
|
-
const result = getLoadedDesignSystem(options?.entryPoint);
|
|
903
|
+
const result = getLoadedDesignSystem(options?.entryPoint, safeSettings(context));
|
|
846
904
|
if (!result) return {};
|
|
847
905
|
const { cache } = result;
|
|
848
906
|
const allowlist = new Set(options?.allowlist ?? []);
|
|
@@ -910,7 +968,7 @@ const noConflictingClasses = (0, _oxlint_plugins.defineRule)({
|
|
|
910
968
|
messages: { conflict: "\"{{classA}}\" and \"{{classB}}\" affect {{properties}}. \"{{winner}}\" takes precedence (appears later)." }
|
|
911
969
|
},
|
|
912
970
|
createOnce(context) {
|
|
913
|
-
const result = getLoadedDesignSystem(safeOptions(context)?.entryPoint);
|
|
971
|
+
const result = getLoadedDesignSystem(safeOptions(context)?.entryPoint, safeSettings(context));
|
|
914
972
|
if (!result) return {};
|
|
915
973
|
const { cache } = result;
|
|
916
974
|
function check(locations) {
|
|
@@ -997,7 +1055,7 @@ const noDeprecatedClasses = (0, _oxlint_plugins.defineRule)({
|
|
|
997
1055
|
messages: { deprecated: "\"{{className}}\" is deprecated in Tailwind v4. Use \"{{replacement}}\" instead." }
|
|
998
1056
|
},
|
|
999
1057
|
createOnce(context) {
|
|
1000
|
-
const result = getLoadedDesignSystem(safeOptions(context)?.entryPoint);
|
|
1058
|
+
const result = getLoadedDesignSystem(safeOptions(context)?.entryPoint, safeSettings(context));
|
|
1001
1059
|
function check(locations) {
|
|
1002
1060
|
for (const loc of locations) {
|
|
1003
1061
|
const classes = splitClasses(loc.value);
|
|
@@ -1019,7 +1077,7 @@ const noDeprecatedClasses = (0, _oxlint_plugins.defineRule)({
|
|
|
1019
1077
|
},
|
|
1020
1078
|
fix(fixer) {
|
|
1021
1079
|
const fixed = loc.value.replace(cls, fullReplacement);
|
|
1022
|
-
return fixer.replaceTextRange(loc.range, fixed);
|
|
1080
|
+
return fixer.replaceTextRange(loc.range, preserveSpaces(loc, fixed));
|
|
1023
1081
|
}
|
|
1024
1082
|
});
|
|
1025
1083
|
}
|
|
@@ -1056,7 +1114,7 @@ const enforceCanonical = (0, _oxlint_plugins.defineRule)({
|
|
|
1056
1114
|
messages: { nonCanonical: "\"{{className}}\" can be written as \"{{canonical}}\". Use the canonical form." }
|
|
1057
1115
|
},
|
|
1058
1116
|
createOnce(context) {
|
|
1059
|
-
const result = getLoadedDesignSystem(safeOptions(context)?.entryPoint);
|
|
1117
|
+
const result = getLoadedDesignSystem(safeOptions(context)?.entryPoint, safeSettings(context));
|
|
1060
1118
|
if (!result) return {};
|
|
1061
1119
|
const { cache } = result;
|
|
1062
1120
|
function check(locations) {
|
|
@@ -1079,7 +1137,7 @@ const enforceCanonical = (0, _oxlint_plugins.defineRule)({
|
|
|
1079
1137
|
canonical
|
|
1080
1138
|
},
|
|
1081
1139
|
fix(fixer) {
|
|
1082
|
-
return fixer.replaceTextRange(loc.range, fixedValue);
|
|
1140
|
+
return fixer.replaceTextRange(loc.range, preserveSpaces(loc, fixedValue));
|
|
1083
1141
|
}
|
|
1084
1142
|
});
|
|
1085
1143
|
} else context.report({
|
|
@@ -1130,7 +1188,7 @@ const enforceSortOrder = (0, _oxlint_plugins.defineRule)({
|
|
|
1130
1188
|
messages: { unsorted: "Tailwind classes are not in the recommended order." }
|
|
1131
1189
|
},
|
|
1132
1190
|
createOnce(context) {
|
|
1133
|
-
const result = getLoadedDesignSystem(safeOptions(context)?.entryPoint);
|
|
1191
|
+
const result = getLoadedDesignSystem(safeOptions(context)?.entryPoint, safeSettings(context));
|
|
1134
1192
|
if (!result) return {};
|
|
1135
1193
|
const { cache } = result;
|
|
1136
1194
|
let _mode = null;
|
|
@@ -1193,7 +1251,7 @@ const enforceSortOrder = (0, _oxlint_plugins.defineRule)({
|
|
|
1193
1251
|
node: loc.node,
|
|
1194
1252
|
messageId: "unsorted",
|
|
1195
1253
|
fix(fixer) {
|
|
1196
|
-
return fixer.replaceTextRange(loc.range, sortedNames.join(" "));
|
|
1254
|
+
return fixer.replaceTextRange(loc.range, preserveSpaces(loc, sortedNames.join(" ")));
|
|
1197
1255
|
}
|
|
1198
1256
|
});
|
|
1199
1257
|
}
|
|
@@ -1304,7 +1362,7 @@ const enforceShorthand = (0, _oxlint_plugins.defineRule)({
|
|
|
1304
1362
|
replacement: rule.replacement
|
|
1305
1363
|
},
|
|
1306
1364
|
fix(fixer) {
|
|
1307
|
-
return fixer.replaceTextRange(loc.range, remaining.join(" "));
|
|
1365
|
+
return fixer.replaceTextRange(loc.range, preserveSpaces(loc, remaining.join(" ")));
|
|
1308
1366
|
}
|
|
1309
1367
|
});
|
|
1310
1368
|
}
|
|
@@ -1387,7 +1445,7 @@ const enforceLogical = (0, _oxlint_plugins.defineRule)({
|
|
|
1387
1445
|
replacement
|
|
1388
1446
|
},
|
|
1389
1447
|
fix(fixer) {
|
|
1390
|
-
return fixer.replaceTextRange(loc.range, fixedValue);
|
|
1448
|
+
return fixer.replaceTextRange(loc.range, preserveSpaces(loc, fixedValue));
|
|
1391
1449
|
}
|
|
1392
1450
|
});
|
|
1393
1451
|
else context.report({
|
|
@@ -1677,7 +1735,7 @@ const enforceConsistentImportantPosition = (0, _oxlint_plugins.defineRule)({
|
|
|
1677
1735
|
replacement
|
|
1678
1736
|
},
|
|
1679
1737
|
fix(fixer) {
|
|
1680
|
-
return fixer.replaceTextRange(loc.range, fixedValue);
|
|
1738
|
+
return fixer.replaceTextRange(loc.range, preserveSpaces(loc, fixedValue));
|
|
1681
1739
|
}
|
|
1682
1740
|
});
|
|
1683
1741
|
else context.report({
|
|
@@ -1757,7 +1815,7 @@ const enforceNegativeArbitraryValues = (0, _oxlint_plugins.defineRule)({
|
|
|
1757
1815
|
replacement
|
|
1758
1816
|
},
|
|
1759
1817
|
fix(fixer) {
|
|
1760
|
-
return fixer.replaceTextRange(loc.range, fixedValue);
|
|
1818
|
+
return fixer.replaceTextRange(loc.range, preserveSpaces(loc, fixedValue));
|
|
1761
1819
|
}
|
|
1762
1820
|
});
|
|
1763
1821
|
else context.report({
|
|
@@ -1858,7 +1916,7 @@ const enforceConsistentVariableSyntax = (0, _oxlint_plugins.defineRule)({
|
|
|
1858
1916
|
replacement
|
|
1859
1917
|
},
|
|
1860
1918
|
fix(fixer) {
|
|
1861
|
-
return fixer.replaceTextRange(loc.range, fixedValue);
|
|
1919
|
+
return fixer.replaceTextRange(loc.range, preserveSpaces(loc, fixedValue));
|
|
1862
1920
|
}
|
|
1863
1921
|
});
|
|
1864
1922
|
else context.report({
|
|
@@ -2266,7 +2324,7 @@ const consistentVariantOrder = (0, _oxlint_plugins.defineRule)({
|
|
|
2266
2324
|
messages: { wrongOrder: "\"{{className}}\" has variants in wrong order. Use \"{{replacement}}\" instead." }
|
|
2267
2325
|
},
|
|
2268
2326
|
createOnce(context) {
|
|
2269
|
-
const dsCache = getLoadedDesignSystem()?.cache ?? null;
|
|
2327
|
+
const dsCache = getLoadedDesignSystem(void 0, safeSettings(context))?.cache ?? null;
|
|
2270
2328
|
let _config = null;
|
|
2271
2329
|
function getConfig() {
|
|
2272
2330
|
if (_config === null) {
|
|
@@ -2340,7 +2398,7 @@ const consistentVariantOrder = (0, _oxlint_plugins.defineRule)({
|
|
|
2340
2398
|
replacement
|
|
2341
2399
|
},
|
|
2342
2400
|
fix(fixer) {
|
|
2343
|
-
return fixer.replaceTextRange(loc.range, fixedValue);
|
|
2401
|
+
return fixer.replaceTextRange(loc.range, preserveSpaces(loc, fixedValue));
|
|
2344
2402
|
}
|
|
2345
2403
|
});
|
|
2346
2404
|
else context.report({
|
|
@@ -2430,7 +2488,7 @@ const enforceConsistentLineWrapping = (0, _oxlint_plugins.defineRule)({
|
|
|
2430
2488
|
max: String(classesPerLine)
|
|
2431
2489
|
},
|
|
2432
2490
|
fix(fixer) {
|
|
2433
|
-
return fixer.replaceTextRange(loc.range, fixedValue);
|
|
2491
|
+
return fixer.replaceTextRange(loc.range, preserveSpaces(loc, fixedValue));
|
|
2434
2492
|
}
|
|
2435
2493
|
});
|
|
2436
2494
|
} else context.report({
|
|
@@ -2475,7 +2533,7 @@ const noUnnecessaryArbitraryValue = (0, _oxlint_plugins.defineRule)({
|
|
|
2475
2533
|
messages: { unnecessaryArbitrary: "\"{{className}}\" can be written as \"{{replacement}}\". Use the named class instead." }
|
|
2476
2534
|
},
|
|
2477
2535
|
createOnce(context) {
|
|
2478
|
-
const result = getLoadedDesignSystem(safeOptions(context)?.entryPoint);
|
|
2536
|
+
const result = getLoadedDesignSystem(safeOptions(context)?.entryPoint, safeSettings(context));
|
|
2479
2537
|
if (!result) return {};
|
|
2480
2538
|
const { cache } = result;
|
|
2481
2539
|
function check(locations) {
|
|
@@ -2505,7 +2563,7 @@ const noUnnecessaryArbitraryValue = (0, _oxlint_plugins.defineRule)({
|
|
|
2505
2563
|
replacement
|
|
2506
2564
|
},
|
|
2507
2565
|
fix(fixer) {
|
|
2508
|
-
return fixer.replaceTextRange(loc.range, fixedValue);
|
|
2566
|
+
return fixer.replaceTextRange(loc.range, preserveSpaces(loc, fixedValue));
|
|
2509
2567
|
}
|
|
2510
2568
|
});
|
|
2511
2569
|
else context.report({
|