oxlint-tailwindcss 1.11.1 → 1.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -3,7 +3,7 @@
3
3
  24 Tailwind CSS linting rules for [oxlint](https://oxc.rs/docs/guide/usage/linter). Built for
4
4
  Tailwind CSS v4 with deterministic config, typo suggestions, and autofixes.
5
5
 
6
- > **v1.0.0** — Upgrading from v0.x? See the
6
+ > **v1** — Upgrading from v0.x? See the
7
7
  > **[migration guide](https://oxlint-tailwindcss.pages.dev/migration/v0-to-v1)**. The headline
8
8
  > change: `settings.tailwindcss.entryPoint` is now required.
9
9
 
@@ -222,17 +222,18 @@ Output:
222
222
 
223
223
  If no entry point is configured, the DS-dependent rules (`no-unknown-classes`,
224
224
  `no-conflicting-classes`, `enforce-canonical`, `enforce-sort-order`,
225
- `no-unnecessary-arbitrary-value`, `prefer-theme-tokens`) emit a single `designSystemUnavailable`
226
- diagnostic per file with an actionable hint — no more silent skips. `consistent-variant-order`
227
- tolerates a missing entryPoint (its static fallback is itself deterministic), and
228
- `no-deprecated-classes` needs no design system at all (it only consults a hardcoded v3→v4 rename
229
- map). All non-DS rules work without an entry point.
225
+ `no-unnecessary-arbitrary-value`, `prefer-scale-token`, `prefer-theme-tokens`) emit a single
226
+ `designSystemUnavailable` diagnostic per file with an actionable hint — no more silent skips.
227
+ `consistent-variant-order` tolerates a missing entryPoint (its static fallback is itself
228
+ deterministic), and `no-deprecated-classes` tolerates one too — it falls back to a hardcoded v3→v4
229
+ rename map, and derives a richer map from the design system when an entry point is configured. All
230
+ non-DS rules work without an entry point.
230
231
 
231
232
  ## Custom class detection
232
233
 
233
234
  By default the plugin detects Tailwind classes in `className`/`class` attributes, 14 utility
234
- functions (`cn`, `clsx`, `cva`, `tv`, `classed`, etc.), `tw` tagged templates, and variables named
235
- `className`/`classes`/`style`.
235
+ functions (`cn`, `clsx`, `cva`, `tv`, `classed`, etc.), `tw` tagged templates, and variables whose
236
+ names match `className`/`classNames`/`classes`/`style`/`styles`.
236
237
 
237
238
  You can extend these defaults via `settings.tailwindcss`. All values are **additive** — your custom
238
239
  entries are appended to the built-in defaults:
@@ -715,8 +716,9 @@ Handles variants correctly — the `!` is placed on the utility, not the variant
715
716
  | `position` | `"prefix"` \| `"suffix"` | `"suffix"` | Where to place the `!` modifier |
716
717
 
717
718
  > **Note:** The default is `"suffix"` to match Tailwind CSS v4's canonical form. The prefix form
718
- > (`!flex`) is deprecated in v4. Using `"prefix"` may conflict with `enforce-canonical`, which also
719
- > normalizes `!` to the suffix position.
719
+ > (`!flex`) is the v3 spelling. `enforce-canonical` preserves whatever `!` position you write (it
720
+ > does not normalize it), so this rule is the single source of truth for `!` placement and the two
721
+ > never conflict.
720
722
 
721
723
  **Autofix:** Moves `!` to the correct position.
722
724
 
@@ -837,12 +839,14 @@ Warns when a class string exceeds the configured print width or classes-per-line
837
839
 
838
840
  **Options:**
839
841
 
840
- | Option | Type | Default | Description |
841
- | ---------------- | -------- | ------- | ----------------------- |
842
- | `printWidth` | `number` | `80` | Max class string length |
843
- | `classesPerLine` | `number` | | Max classes per line |
842
+ | Option | Type | Default | Description |
843
+ | ---------------- | ------------------------------------- | ----------- | ------------------------------------------------------------------- |
844
+ | `printWidth` | `number` | `80` | Max class string length |
845
+ | `classesPerLine` | `number` | | Max classes per line |
846
+ | `wrapLines` | `'overWidth' \| 'all'` | | Re-wrap lines: only over-width, or always into the canonical layout |
847
+ | `group` | `'newLine' \| 'emptyLine' \| 'never'` | `'newLine'` | How the `wrapLines: 'all'` layout separates variant groups |
844
848
 
845
- **Autofix:** Only for `classesPerLine` with template literals.
849
+ **Autofix:** `classesPerLine` and `wrapLines` re-wrap template literals; `printWidth` is warn-only.
846
850
 
847
851
  ---
848
852
 
package/dist/index.cjs CHANGED
@@ -897,6 +897,39 @@ function reattachImportant(bare, position) {
897
897
  if (position === "suffix") return `${bare}!`;
898
898
  return bare;
899
899
  }
900
+ const EXPLICIT_VAR_RE = /^([a-z][a-z0-9-]*(?:-[a-z0-9]+)*)-\[var\((--[a-zA-Z0-9-]+)\)\]$/;
901
+ const SHORTHAND_VAR_RE = /^([a-z][a-z0-9-]*(?:-[a-z0-9]+)*)-\((--[a-zA-Z0-9-]+)\)$/;
902
+ /**
903
+ * Convert a class between the two CSS-variable syntaxes:
904
+ * `bg-[var(--x)]` (explicit) ↔ `bg-(--x)` (shorthand). Returns the converted
905
+ * class, or `null` when it isn't a simple single-variable utility.
906
+ *
907
+ * Deliberately narrow — it matches ONLY the bare-bracket form, so compound
908
+ * expressions (`bg-[color-mix(...)]`) and opacity-modifier forms
909
+ * (`text-[var(--c)]/90`, whose trailing `/90` fails the `$` anchor) return
910
+ * `null`. Variants and `!` position round-trip via `splitUtilityAndVariant` /
911
+ * `splitImportant`. This is the single set of classes over which
912
+ * `enforce-consistent-variable-syntax` (which owns the policy) and
913
+ * `enforce-canonical` (which cedes it) overlap, so both consume this one helper.
914
+ */
915
+ function convertVarSyntax(cls, syntax) {
916
+ const { utility, variant } = splitUtilityAndVariant(cls);
917
+ const { bare: bareUtility, position } = splitImportant(utility);
918
+ if (syntax === "shorthand") {
919
+ const match = EXPLICIT_VAR_RE.exec(bareUtility);
920
+ if (match) {
921
+ const [, prefix, varName] = match;
922
+ return `${variant}${reattachImportant(`${prefix}-(${varName})`, position)}`;
923
+ }
924
+ } else {
925
+ const match = SHORTHAND_VAR_RE.exec(bareUtility);
926
+ if (match) {
927
+ const [, prefix, varName] = match;
928
+ return `${variant}${reattachImportant(`${prefix}-[var(${varName})]`, position)}`;
929
+ }
930
+ }
931
+ return null;
932
+ }
900
933
  /**
901
934
  * Pseudo-element variants, as a static fallback for when no design system is
902
935
  * configured. They select a generated box (`::before`, `::marker`, …) rather than
@@ -5273,7 +5306,13 @@ const enforceCanonical = defineRule({
5273
5306
  if (!dynamic) return;
5274
5307
  for (let k = 0; k < arbitrary.length; k++) {
5275
5308
  const { canonical, safe } = dynamic[k];
5276
- canonicals[arbitraryIdx[k]] = safe ? preserveImportantPosition(arbitrary[k], canonical) : arbitrary[k];
5309
+ const idx = arbitraryIdx[k];
5310
+ if (!safe) {
5311
+ canonicals[idx] = arbitrary[k];
5312
+ continue;
5313
+ }
5314
+ const preserved = preserveImportantPosition(arbitrary[k], canonical);
5315
+ canonicals[idx] = convertVarSyntax(arbitrary[k], "shorthand") === preserved ? arbitrary[k] : preserved;
5277
5316
  }
5278
5317
  }
5279
5318
  reportClassReplacements(context, loc, split, classes, classes.flatMap((cls, i) => canonicals[i] === cls ? [] : [{
@@ -6197,7 +6236,7 @@ const noArbitraryValue = defineRule({
6197
6236
  const enforceConsistentImportantPosition = defineRule({
6198
6237
  meta: {
6199
6238
  type: "suggestion",
6200
- docs: { description: "Enforce consistent position of the important (!) modifier. Default: suffix (Tailwind v4 canonical form). Note: using \"prefix\" may conflict with enforce-canonical which normalizes to suffix." },
6239
+ docs: { description: "Enforce consistent position of the important (!) modifier. Default: suffix (Tailwind v4 canonical form). This rule is the single source of truth for ! placement — enforce-canonical preserves the position you wrote, so the two never conflict." },
6201
6240
  fixable: "code",
6202
6241
  schema: [{
6203
6242
  type: "object",
@@ -6295,26 +6334,6 @@ const enforceNegativeArbitraryValues = defineRule({
6295
6334
  });
6296
6335
  //#endregion
6297
6336
  //#region src/rules/enforce-consistent-variable-syntax.ts
6298
- const EXPLICIT_VAR_RE = /^([a-z][a-z0-9-]*(?:-[a-z0-9]+)*)-\[var\((--[a-zA-Z0-9-]+)\)\]$/;
6299
- const SHORTHAND_VAR_RE = /^([a-z][a-z0-9-]*(?:-[a-z0-9]+)*)-\((--[a-zA-Z0-9-]+)\)$/;
6300
- function convertClass(cls, syntax) {
6301
- const { utility, variant } = splitUtilityAndVariant(cls);
6302
- const { bare: bareUtility, position } = splitImportant(utility);
6303
- if (syntax === "shorthand") {
6304
- const match = EXPLICIT_VAR_RE.exec(bareUtility);
6305
- if (match) {
6306
- const [, prefix, varName] = match;
6307
- return `${variant}${reattachImportant(`${prefix}-(${varName})`, position)}`;
6308
- }
6309
- } else {
6310
- const match = SHORTHAND_VAR_RE.exec(bareUtility);
6311
- if (match) {
6312
- const [, prefix, varName] = match;
6313
- return `${variant}${reattachImportant(`${prefix}-[var(${varName})]`, position)}`;
6314
- }
6315
- }
6316
- return null;
6317
- }
6318
6337
  const enforceConsistentVariableSyntax = defineRule({
6319
6338
  meta: {
6320
6339
  type: "suggestion",
@@ -6344,7 +6363,7 @@ const enforceConsistentVariableSyntax = defineRule({
6344
6363
  for (const loc of locations) {
6345
6364
  const split = splitClassesWithSeparators(loc.value);
6346
6365
  const offending = split.classes.flatMap((cls) => {
6347
- const converted = convertClass(cls, syntax);
6366
+ const converted = convertVarSyntax(cls, syntax);
6348
6367
  return converted ? [{
6349
6368
  cls,
6350
6369
  replacement: converted
package/dist/index.mjs CHANGED
@@ -901,6 +901,39 @@ function reattachImportant(bare, position) {
901
901
  if (position === "suffix") return `${bare}!`;
902
902
  return bare;
903
903
  }
904
+ const EXPLICIT_VAR_RE = /^([a-z][a-z0-9-]*(?:-[a-z0-9]+)*)-\[var\((--[a-zA-Z0-9-]+)\)\]$/;
905
+ const SHORTHAND_VAR_RE = /^([a-z][a-z0-9-]*(?:-[a-z0-9]+)*)-\((--[a-zA-Z0-9-]+)\)$/;
906
+ /**
907
+ * Convert a class between the two CSS-variable syntaxes:
908
+ * `bg-[var(--x)]` (explicit) ↔ `bg-(--x)` (shorthand). Returns the converted
909
+ * class, or `null` when it isn't a simple single-variable utility.
910
+ *
911
+ * Deliberately narrow — it matches ONLY the bare-bracket form, so compound
912
+ * expressions (`bg-[color-mix(...)]`) and opacity-modifier forms
913
+ * (`text-[var(--c)]/90`, whose trailing `/90` fails the `$` anchor) return
914
+ * `null`. Variants and `!` position round-trip via `splitUtilityAndVariant` /
915
+ * `splitImportant`. This is the single set of classes over which
916
+ * `enforce-consistent-variable-syntax` (which owns the policy) and
917
+ * `enforce-canonical` (which cedes it) overlap, so both consume this one helper.
918
+ */
919
+ function convertVarSyntax(cls, syntax) {
920
+ const { utility, variant } = splitUtilityAndVariant(cls);
921
+ const { bare: bareUtility, position } = splitImportant(utility);
922
+ if (syntax === "shorthand") {
923
+ const match = EXPLICIT_VAR_RE.exec(bareUtility);
924
+ if (match) {
925
+ const [, prefix, varName] = match;
926
+ return `${variant}${reattachImportant(`${prefix}-(${varName})`, position)}`;
927
+ }
928
+ } else {
929
+ const match = SHORTHAND_VAR_RE.exec(bareUtility);
930
+ if (match) {
931
+ const [, prefix, varName] = match;
932
+ return `${variant}${reattachImportant(`${prefix}-[var(${varName})]`, position)}`;
933
+ }
934
+ }
935
+ return null;
936
+ }
904
937
  /**
905
938
  * Pseudo-element variants, as a static fallback for when no design system is
906
939
  * configured. They select a generated box (`::before`, `::marker`, …) rather than
@@ -5277,7 +5310,13 @@ const enforceCanonical = defineRule({
5277
5310
  if (!dynamic) return;
5278
5311
  for (let k = 0; k < arbitrary.length; k++) {
5279
5312
  const { canonical, safe } = dynamic[k];
5280
- canonicals[arbitraryIdx[k]] = safe ? preserveImportantPosition(arbitrary[k], canonical) : arbitrary[k];
5313
+ const idx = arbitraryIdx[k];
5314
+ if (!safe) {
5315
+ canonicals[idx] = arbitrary[k];
5316
+ continue;
5317
+ }
5318
+ const preserved = preserveImportantPosition(arbitrary[k], canonical);
5319
+ canonicals[idx] = convertVarSyntax(arbitrary[k], "shorthand") === preserved ? arbitrary[k] : preserved;
5281
5320
  }
5282
5321
  }
5283
5322
  reportClassReplacements(context, loc, split, classes, classes.flatMap((cls, i) => canonicals[i] === cls ? [] : [{
@@ -6201,7 +6240,7 @@ const noArbitraryValue = defineRule({
6201
6240
  const enforceConsistentImportantPosition = defineRule({
6202
6241
  meta: {
6203
6242
  type: "suggestion",
6204
- docs: { description: "Enforce consistent position of the important (!) modifier. Default: suffix (Tailwind v4 canonical form). Note: using \"prefix\" may conflict with enforce-canonical which normalizes to suffix." },
6243
+ docs: { description: "Enforce consistent position of the important (!) modifier. Default: suffix (Tailwind v4 canonical form). This rule is the single source of truth for ! placement — enforce-canonical preserves the position you wrote, so the two never conflict." },
6205
6244
  fixable: "code",
6206
6245
  schema: [{
6207
6246
  type: "object",
@@ -6299,26 +6338,6 @@ const enforceNegativeArbitraryValues = defineRule({
6299
6338
  });
6300
6339
  //#endregion
6301
6340
  //#region src/rules/enforce-consistent-variable-syntax.ts
6302
- const EXPLICIT_VAR_RE = /^([a-z][a-z0-9-]*(?:-[a-z0-9]+)*)-\[var\((--[a-zA-Z0-9-]+)\)\]$/;
6303
- const SHORTHAND_VAR_RE = /^([a-z][a-z0-9-]*(?:-[a-z0-9]+)*)-\((--[a-zA-Z0-9-]+)\)$/;
6304
- function convertClass(cls, syntax) {
6305
- const { utility, variant } = splitUtilityAndVariant(cls);
6306
- const { bare: bareUtility, position } = splitImportant(utility);
6307
- if (syntax === "shorthand") {
6308
- const match = EXPLICIT_VAR_RE.exec(bareUtility);
6309
- if (match) {
6310
- const [, prefix, varName] = match;
6311
- return `${variant}${reattachImportant(`${prefix}-(${varName})`, position)}`;
6312
- }
6313
- } else {
6314
- const match = SHORTHAND_VAR_RE.exec(bareUtility);
6315
- if (match) {
6316
- const [, prefix, varName] = match;
6317
- return `${variant}${reattachImportant(`${prefix}-[var(${varName})]`, position)}`;
6318
- }
6319
- }
6320
- return null;
6321
- }
6322
6341
  const enforceConsistentVariableSyntax = defineRule({
6323
6342
  meta: {
6324
6343
  type: "suggestion",
@@ -6348,7 +6367,7 @@ const enforceConsistentVariableSyntax = defineRule({
6348
6367
  for (const loc of locations) {
6349
6368
  const split = splitClassesWithSeparators(loc.value);
6350
6369
  const offending = split.classes.flatMap((cls) => {
6351
- const converted = convertClass(cls, syntax);
6370
+ const converted = convertVarSyntax(cls, syntax);
6352
6371
  return converted ? [{
6353
6372
  cls,
6354
6373
  replacement: converted
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "oxlint-tailwindcss",
3
- "version": "1.11.1",
3
+ "version": "1.12.0",
4
4
  "description": "Tailwind CSS linting rules for oxlint",
5
5
  "keywords": [
6
6
  "css",