tailwind-typescript-plugin 1.4.0-beta.3 → 1.4.0-beta.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/CHANGELOG.md CHANGED
@@ -1,3 +1,13 @@
1
+ ## [1.4.0-beta.4](https://github.com/IvanRodriCalleja/tailwind-typescript-plugin/compare/v1.4.0-beta.3...v1.4.0-beta.4) (2025-11-27)
2
+
3
+ ### ✨ Features
4
+
5
+ * warn on all duplicate class occurrences ([d01d878](https://github.com/IvanRodriCalleja/tailwind-typescript-plugin/commit/d01d87844da17e15d5608ddddb1e3fdc033c8d38))
6
+
7
+ ### 🐛 Bug Fixes
8
+
9
+ * dispose plugin in benchmark to close file watchers ([9efdc6a](https://github.com/IvanRodriCalleja/tailwind-typescript-plugin/commit/9efdc6a8e24de4dd3000c44fc075bb765ddba1bb))
10
+
1
11
  ## [1.4.0-beta.3](https://github.com/IvanRodriCalleja/tailwind-typescript-plugin/compare/v1.4.0-beta.2...v1.4.0-beta.3) (2025-11-26)
2
12
 
3
13
  ### ✨ Features
package/README.md CHANGED
@@ -842,19 +842,19 @@ const card2 = tv({ base: 'flex justify-center' });
842
842
  Validates variables in class-variance-authority cva() definitions
843
843
  Example: `const baseClasses = 'invalid-class'; const button = cva(baseClasses)`
844
844
 
845
- - [X] **Duplicate Classes** → [`duplicate-classes.tsx`](./example/src/duplicate-classes.tsx)
845
+ - [X] **Duplicate Classes** → [`duplicate-classes/`](./example/src/duplicate-classes/)
846
846
  Detects duplicate classes within the same className attribute
847
- Example: `className="flex flex items-center"` shows warning on second `flex`
847
+ Example: `className="flex flex items-center"` shows warning on both `flex` occurrences
848
848
 
849
- - [X] **Duplicate Classes in Ternary** → [`duplicate-classes.tsx`](./example/src/duplicate-classes.tsx)
849
+ - [X] **Duplicate Classes in Ternary** → [`duplicate-classes/`](./example/src/duplicate-classes/)
850
850
  Smart detection of duplicates in ternary expressions:
851
- - Root + branch duplicate: `clsx('flex', isActive ? 'flex' : 'flex')` → Warning (true duplicate)
851
+ - Root + branch duplicate: `clsx('flex', isActive ? 'flex' : 'flex')` → Warning on all occurrences
852
852
  - Both branches same class: `clsx('mt-4', isActive ? 'flex' : 'flex')` → Warning (consider extracting)
853
853
  - Single branch only: `clsx('mt-4', isActive ? 'flex' : '')` → No warning (valid pattern)
854
854
 
855
- - [X] **Duplicate Classes in Variables with Conditionals** → [`duplicate-classes.tsx`](./example/src/duplicate-classes.tsx)
855
+ - [X] **Duplicate Classes in Variables with Conditionals** → [`duplicate-classes/`](./example/src/duplicate-classes/)
856
856
  Resolves variables containing ternary expressions and detects duplicates:
857
- - `const x = isActive ? 'flex' : 'flex'; clsx('flex', x)` → Warning (root + variable duplicate)
857
+ - `const x = isActive ? 'flex' : 'flex'; clsx('flex', x)` → Warning on all occurrences
858
858
  - `const x = isActive ? 'flex' : 'flex'; clsx('mt-4', x)` → Warning (consider extracting from variable)
859
859
  - `const x = isActive ? 'flex' : ''; clsx('mt-4', x)` → No warning (single branch)
860
860
 
@@ -10,31 +10,36 @@ export interface ConflictInfo {
10
10
  /** The CSS property that is being overwritten (e.g., 'text-align', 'display') */
11
11
  cssProperty: string;
12
12
  }
13
+ /**
14
+ * Interface for getting CSS from class names
15
+ */
16
+ export interface ICssProvider {
17
+ getCssForClasses(classNames: string[]): (string | null)[];
18
+ }
13
19
  /**
14
20
  * Service for detecting conflicting Tailwind CSS utility classes.
15
- * Conflicting classes are utilities that set the same CSS property to different values.
21
+ * Uses Tailwind's design system to compile classes and analyze their CSS output.
22
+ * Two classes conflict when they set the same CSS properties in the same context.
16
23
  */
17
24
  export declare class TailwindConflictDetector {
18
- /** Map from class name to its conflict group */
19
- private classToGroup;
20
- /** Map from conflict group to set of class names */
21
- private groupToClasses;
22
- constructor();
25
+ private cssProvider;
23
26
  /**
24
- * Get the conflict group for a class name, if any.
25
- * Returns the CSS property name that this class affects.
27
+ * Set the CSS provider (TailwindValidator)
26
28
  */
27
- getConflictGroup(className: string): string | null;
29
+ setCssProvider(provider: ICssProvider): void;
30
+ /**
31
+ * Parse CSS string and extract properties and context
32
+ */
33
+ private parseCss;
28
34
  /**
29
35
  * Extract the prefix (variants) from a class name.
30
36
  * e.g., "md:hover:text-left" -> "md:hover:"
31
37
  */
32
38
  private extractPrefix;
33
39
  /**
34
- * Extract the base class from a potentially prefixed class name.
35
- * Handles responsive variants (sm:, md:, lg:, xl:, 2xl:) and state variants (hover:, focus:, etc.)
40
+ * Compare two ClassCssInfo arrays for equality
36
41
  */
37
- private extractBaseClass;
42
+ private cssInfoEquals;
38
43
  /**
39
44
  * Find all conflicting classes in a list of ClassNameInfo.
40
45
  * Returns ConflictInfo for each class that conflicts with another.
@@ -51,22 +56,27 @@ export declare class TailwindConflictDetector {
51
56
  * Handles conditional branches - classes in mutually exclusive branches don't conflict.
52
57
  */
53
58
  private findConflictsInClassGroup;
59
+ /**
60
+ * Get the CSS property that causes a conflict between two classes, or null if no conflict.
61
+ */
62
+ private getConflictProperty;
54
63
  /**
55
64
  * Find conflicts in a flat list of classes (no branch handling).
56
- * Used for root classes or classes within the same branch.
57
- *
58
- * Classes with different prefixes (e.g., sm:text-left vs md:text-center) do NOT conflict
59
- * because they apply at different breakpoints/states.
60
- *
61
- * All classes involved in a conflict are flagged, not just subsequent ones.
62
65
  */
63
66
  private findConflictsInList;
64
67
  /**
65
68
  * Check if two class names conflict with each other.
66
69
  */
67
70
  doClassesConflict(className1: string, className2: string): boolean;
71
+ /**
72
+ * Get the conflict group for a class name, if any.
73
+ * Returns the CSS properties that this class affects.
74
+ */
75
+ getConflictGroup(className: string): string | null;
68
76
  /**
69
77
  * Get all classes that would conflict with a given class.
78
+ * Note: This is a simplified implementation that returns an empty array
79
+ * since we no longer have a static conflict group map.
70
80
  */
71
81
  getConflictingClasses(className: string): string[];
72
82
  }
@@ -1 +1 @@
1
- {"version":3,"file":"TailwindConflictDetector.d.ts","sourceRoot":"","sources":["../../src/infrastructure/TailwindConflictDetector.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAE9C;;GAEG;AACH,MAAM,WAAW,YAAY;IAC5B,oCAAoC;IACpC,SAAS,EAAE,aAAa,CAAC;IACzB,sCAAsC;IACtC,aAAa,EAAE,MAAM,EAAE,CAAC;IACxB,iFAAiF;IACjF,WAAW,EAAE,MAAM,CAAC;CACpB;AA+cD;;;GAGG;AACH,qBAAa,wBAAwB;IACpC,gDAAgD;IAChD,OAAO,CAAC,YAAY,CAAsB;IAE1C,oDAAoD;IACpD,OAAO,CAAC,cAAc,CAA2B;;IAiBjD;;;OAGG;IACH,gBAAgB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI;IAOlD;;;OAGG;IACH,OAAO,CAAC,aAAa;IAMrB;;;OAGG;IACH,OAAO,CAAC,gBAAgB;IAMxB;;;OAGG;IACH,aAAa,CAAC,UAAU,EAAE,aAAa,EAAE,GAAG,YAAY,EAAE;IAuB1D;;;;OAIG;IACH,OAAO,CAAC,wBAAwB;IAgBhC;;;OAGG;IACH,OAAO,CAAC,yBAAyB;IAoDjC;;;;;;;;OAQG;IACH,OAAO,CAAC,mBAAmB;IAuD3B;;OAEG;IACH,iBAAiB,CAAC,UAAU,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO;IAOlE;;OAEG;IACH,qBAAqB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,EAAE;CASlD"}
1
+ {"version":3,"file":"TailwindConflictDetector.d.ts","sourceRoot":"","sources":["../../src/infrastructure/TailwindConflictDetector.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAE9C;;GAEG;AACH,MAAM,WAAW,YAAY;IAC5B,oCAAoC;IACpC,SAAS,EAAE,aAAa,CAAC;IACzB,sCAAsC;IACtC,aAAa,EAAE,MAAM,EAAE,CAAC;IACxB,iFAAiF;IACjF,WAAW,EAAE,MAAM,CAAC;CACpB;AAYD;;GAEG;AACH,MAAM,WAAW,YAAY;IAC5B,gBAAgB,CAAC,UAAU,EAAE,MAAM,EAAE,GAAG,CAAC,MAAM,GAAG,IAAI,CAAC,EAAE,CAAC;CAC1D;AAED;;;;GAIG;AACH,qBAAa,wBAAwB;IACpC,OAAO,CAAC,WAAW,CAA6B;IAEhD;;OAEG;IACH,cAAc,CAAC,QAAQ,EAAE,YAAY,GAAG,IAAI;IAI5C;;OAEG;IACH,OAAO,CAAC,QAAQ;IAsDhB;;;OAGG;IACH,OAAO,CAAC,aAAa;IAMrB;;OAEG;IACH,OAAO,CAAC,aAAa;IAuBrB;;;OAGG;IACH,aAAa,CAAC,UAAU,EAAE,aAAa,EAAE,GAAG,YAAY,EAAE;IA2B1D;;;;OAIG;IACH,OAAO,CAAC,wBAAwB;IAgBhC;;;OAGG;IACH,OAAO,CAAC,yBAAyB;IA8CjC;;OAEG;IACH,OAAO,CAAC,mBAAmB;IA6B3B;;OAEG;IACH,OAAO,CAAC,mBAAmB;IA+F3B;;OAEG;IACH,iBAAiB,CAAC,UAAU,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO;IAIlE;;;OAGG;IACH,gBAAgB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI;IAgBlD;;;;OAIG;IAEH,qBAAqB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,EAAE;CAKlD"}