@weerachai06/tw-scanner 1.0.2 → 1.0.3

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/validator.js CHANGED
@@ -48,9 +48,13 @@ function selectorInOutput(selector, output) {
48
48
  const next = output[idx + selector.length];
49
49
  return next === '{' || next === ' ' || next === ':' || next === '[' || next === ',';
50
50
  }
51
+ // Marker classes that are valid but generate no CSS of their own
52
+ const MARKER_CLASS_RE = /^(group|peer)(\/\S+)?$/;
51
53
  // ─── Validation cache: per-context ───────────────────────────────────────────
52
54
  const validityCache = new Map();
53
55
  export function isValidClass(cls, context) {
56
+ if (MARKER_CLASS_RE.test(cls))
57
+ return true;
54
58
  if (!validityCache.has(context))
55
59
  validityCache.set(context, new Map());
56
60
  const cache = validityCache.get(context);
@@ -69,9 +73,12 @@ export function validateBatch(classes, context) {
69
73
  const cache = validityCache.get(context) ?? new Map();
70
74
  if (!validityCache.has(context))
71
75
  validityCache.set(context, cache);
72
- // Use cache first
76
+ // Use cache first; skip marker classes
73
77
  for (const cls of classes) {
74
- if (cache.has(cls)) {
78
+ if (MARKER_CLASS_RE.test(cls)) {
79
+ result.set(cls, true);
80
+ }
81
+ else if (cache.has(cls)) {
75
82
  result.set(cls, cache.get(cls));
76
83
  }
77
84
  else {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@weerachai06/tw-scanner",
3
- "version": "1.0.2",
3
+ "version": "1.0.3",
4
4
  "description": "AST-based Tailwind v4 class validator for React projects",
5
5
  "type": "module",
6
6
  "bin": {