tailwind-a11y 0.5.1 → 0.6.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.
@@ -14,8 +14,11 @@ const COLOR_TOKEN = /^\[(#[0-9a-fA-F]{3,8})\](\/\d{1,3})?$|^[a-z]+-\d{2,3}(\/\d{
14
14
  // "word-number" shape as a color token but isn't one — without this
15
15
  // exclusion it can silently overwrite a real color match via the
16
16
  // last-token-wins rule below, making a real violation vanish (a false
17
- // negative, the worst failure mode for a linter).
18
- const NON_COLOR_SCALE_NAMES = new Set(["opacity"]);
17
+ // negative, the worst failure mode for a linter). linear-{N}/conic-{N}
18
+ // (Tailwind v4's bg-linear-45/bg-conic-180 gradient-angle utilities) are
19
+ // the same failure mode: bg-linear-45 shares the word-number shape with
20
+ // bg-red-500 and would otherwise mask it via last-token-wins.
21
+ const NON_COLOR_SCALE_NAMES = new Set(["opacity", "linear", "conic"]);
19
22
  export function lastColorToken(className, prefix) {
20
23
  let found = null;
21
24
  for (const raw of className.split(/\s+/).filter(Boolean)) {
@@ -11,6 +11,28 @@ const DEGENERATE_BASES = new Set(["outline-none", "ring-0", "border-0", "shadow-
11
11
  // set (opacity/offset take arbitrary numeric values), so matched with a
12
12
  // pattern instead of enumerated.
13
13
  const MODIFIER_ONLY = /^(bg|border|ring)-opacity-\d{1,3}$|^(ring|outline)-offset-\d{1,3}$|^ring-inset$/;
14
+ // Same failure mode again, one prefix-family level up: these utilities
15
+ // share the bg-*/border-* prefix but control layout/rendering *behavior*
16
+ // (attachment, repeat, size, clip, origin, position, table border mode),
17
+ // not a visible color/width/style that could replace a removed outline.
18
+ // Enumerated, not derived -- a future Tailwind utility sharing one of
19
+ // these prefixes without providing visible styling could reintroduce this
20
+ // gap, the same maintenance caveat as DEGENERATE_BASES/MODIFIER_ONLY above.
21
+ const NON_VISUAL_BASES = new Set([
22
+ "bg-fixed", "bg-local", "bg-scroll",
23
+ "bg-repeat", "bg-no-repeat", "bg-repeat-x", "bg-repeat-y", "bg-repeat-round", "bg-repeat-space",
24
+ "bg-auto", "bg-cover", "bg-contain",
25
+ "bg-clip-border", "bg-clip-padding", "bg-clip-content", "bg-clip-text",
26
+ "bg-origin-border", "bg-origin-padding", "bg-origin-content",
27
+ "bg-none",
28
+ "bg-bottom", "bg-center", "bg-left", "bg-left-bottom", "bg-left-top",
29
+ "bg-right", "bg-right-bottom", "bg-right-top", "bg-top",
30
+ "border-collapse", "border-separate",
31
+ ]);
32
+ // bg-blend-{mode} (e.g. bg-blend-multiply) sets a blend mode, not a color --
33
+ // suffix-varying like MODIFIER_ONLY above, so pattern-matched instead of
34
+ // enumerated.
35
+ const NON_VISUAL_PATTERN = /^bg-blend-/;
14
36
  function baseUtility(raw) {
15
37
  return raw.slice(raw.lastIndexOf(":") + 1);
16
38
  }
@@ -18,6 +40,8 @@ function isReplacement(raw) {
18
40
  const base = baseUtility(raw);
19
41
  if (DEGENERATE_BASES.has(base) || MODIFIER_ONLY.test(base))
20
42
  return false;
43
+ if (NON_VISUAL_BASES.has(base) || NON_VISUAL_PATTERN.test(base))
44
+ return false;
21
45
  return /^(ring|border|shadow|bg|outline)(-|$)/.test(base);
22
46
  }
23
47
  export function checkFocusIndicators(checks) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tailwind-a11y",
3
- "version": "0.5.1",
3
+ "version": "0.6.0",
4
4
  "description": "Static analysis CLI that catches WCAG accessibility violations — color contrast, touch target size, and focus indicator removal — in Tailwind CSS class combinations before they ship.",
5
5
  "type": "module",
6
6
  "bin": {