tailwind-typescript-plugin 1.4.1-beta.12 → 1.4.1-beta.14
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 +16 -0
- package/README.md +212 -143
- package/lib/core/interfaces.d.ts +17 -12
- package/lib/core/interfaces.d.ts.map +1 -1
- package/lib/core/types.d.ts +81 -0
- package/lib/core/types.d.ts.map +1 -1
- package/lib/extractors/SvelteAttributeExtractor.d.ts +17 -0
- package/lib/extractors/SvelteAttributeExtractor.d.ts.map +1 -0
- package/lib/extractors/SvelteAttributeExtractor.js +27 -0
- package/lib/extractors/SvelteAttributeExtractor.js.map +1 -0
- package/lib/extractors/VueAttributeExtractor.d.ts +18 -0
- package/lib/extractors/VueAttributeExtractor.d.ts.map +1 -0
- package/lib/extractors/VueAttributeExtractor.js +28 -0
- package/lib/extractors/VueAttributeExtractor.js.map +1 -0
- package/lib/infrastructure/TailwindValidator.css-vars.spec.js +1 -11
- package/lib/infrastructure/TailwindValidator.css-vars.spec.js.map +1 -1
- package/lib/infrastructure/TailwindValidator.d.ts +1 -3
- package/lib/infrastructure/TailwindValidator.d.ts.map +1 -1
- package/lib/infrastructure/TailwindValidator.js +6 -26
- package/lib/infrastructure/TailwindValidator.js.map +1 -1
- package/lib/infrastructure/TailwindValidator.spec.js +7 -17
- package/lib/infrastructure/TailwindValidator.spec.js.map +1 -1
- package/lib/plugin/TailwindTypescriptPlugin.d.ts +0 -1
- package/lib/plugin/TailwindTypescriptPlugin.d.ts.map +1 -1
- package/lib/plugin/TailwindTypescriptPlugin.js +29 -66
- package/lib/plugin/TailwindTypescriptPlugin.js.map +1 -1
- package/lib/services/ClassNameExtractionService.d.ts +19 -3
- package/lib/services/ClassNameExtractionService.d.ts.map +1 -1
- package/lib/services/ClassNameExtractionService.js +74 -13
- package/lib/services/ClassNameExtractionService.js.map +1 -1
- package/lib/services/ClassNameExtractionService.spec.d.ts +2 -0
- package/lib/services/ClassNameExtractionService.spec.d.ts.map +1 -0
- package/lib/services/ClassNameExtractionService.spec.js +160 -0
- package/lib/services/ClassNameExtractionService.spec.js.map +1 -0
- package/lib/services/CodeActionService.spec.js +1 -2
- package/lib/services/CodeActionService.spec.js.map +1 -1
- package/lib/services/CompletionService.d.ts +1 -3
- package/lib/services/CompletionService.d.ts.map +1 -1
- package/lib/services/CompletionService.js +1 -12
- package/lib/services/CompletionService.js.map +1 -1
- package/lib/services/CompletionService.spec.js +11 -12
- package/lib/services/CompletionService.spec.js.map +1 -1
- package/lib/services/ConflictClassDetection.spec.js +5 -5
- package/lib/services/ConflictClassDetection.spec.js.map +1 -1
- package/lib/services/DiagnosticService.d.ts +8 -8
- package/lib/services/DiagnosticService.d.ts.map +1 -1
- package/lib/services/DiagnosticService.js +29 -13
- package/lib/services/DiagnosticService.js.map +1 -1
- package/lib/services/DuplicateClassDetection.spec.js +20 -21
- package/lib/services/DuplicateClassDetection.spec.js.map +1 -1
- package/lib/services/PluginConfigService.d.ts +38 -15
- package/lib/services/PluginConfigService.d.ts.map +1 -1
- package/lib/services/PluginConfigService.js +182 -82
- package/lib/services/PluginConfigService.js.map +1 -1
- package/lib/services/ValidationService.d.ts +5 -4
- package/lib/services/ValidationService.d.ts.map +1 -1
- package/lib/services/ValidationService.js +39 -42
- package/lib/services/ValidationService.js.map +1 -1
- package/lib/utils/FrameworkDetector.d.ts +24 -0
- package/lib/utils/FrameworkDetector.d.ts.map +1 -0
- package/lib/utils/FrameworkDetector.js +52 -0
- package/lib/utils/FrameworkDetector.js.map +1 -0
- package/lib/utils/FrameworkDetector.spec.d.ts +2 -0
- package/lib/utils/FrameworkDetector.spec.d.ts.map +1 -0
- package/lib/utils/FrameworkDetector.spec.js +75 -0
- package/lib/utils/FrameworkDetector.spec.js.map +1 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,19 @@
|
|
|
1
|
+
## [1.4.0-beta.14](https://github.com/IvanRodriCalleja/tailwind-typescript-plugin/compare/v1.4.0-beta.13...v1.4.0-beta.14) (2025-12-02)
|
|
2
|
+
|
|
3
|
+
### ⚠ BREAKING CHANGES
|
|
4
|
+
|
|
5
|
+
* Old config format no longer supported
|
|
6
|
+
|
|
7
|
+
### ♻️ Code Refactoring
|
|
8
|
+
|
|
9
|
+
* restructure plugin configuration ([00c8816](https://github.com/IvanRodriCalleja/tailwind-typescript-plugin/commit/00c881612449e4c424c129f4994c57117d94d3c4))
|
|
10
|
+
|
|
11
|
+
## [1.4.0-beta.13](https://github.com/IvanRodriCalleja/tailwind-typescript-plugin/compare/v1.4.0-beta.12...v1.4.0-beta.13) (2025-11-30)
|
|
12
|
+
|
|
13
|
+
### ✨ Features
|
|
14
|
+
|
|
15
|
+
* add hover information for Tailwind CSS classes ([33cac86](https://github.com/IvanRodriCalleja/tailwind-typescript-plugin/commit/33cac864f774e6925c0d7dd63e29dced85a0b157))
|
|
16
|
+
|
|
1
17
|
## [1.4.0-beta.12](https://github.com/IvanRodriCalleja/tailwind-typescript-plugin/compare/v1.4.0-beta.11...v1.4.0-beta.12) (2025-11-30)
|
|
2
18
|
|
|
3
19
|
### ✨ Features
|
package/README.md
CHANGED
|
@@ -59,6 +59,21 @@ pnpm add tailwind-typescript-plugin
|
|
|
59
59
|
|
|
60
60
|
Add the plugin to the `compilerOptions.plugins` array in your `tsconfig.json`:
|
|
61
61
|
|
|
62
|
+
```json
|
|
63
|
+
{
|
|
64
|
+
"compilerOptions": {
|
|
65
|
+
"plugins": [
|
|
66
|
+
{
|
|
67
|
+
"name": "tailwind-typescript-plugin",
|
|
68
|
+
"globalCss": "./src/global.css"
|
|
69
|
+
}
|
|
70
|
+
]
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
**Full configuration example with all options:**
|
|
76
|
+
|
|
62
77
|
```json
|
|
63
78
|
{
|
|
64
79
|
"compilerOptions": {
|
|
@@ -66,11 +81,41 @@ Add the plugin to the `compilerOptions.plugins` array in your `tsconfig.json`:
|
|
|
66
81
|
{
|
|
67
82
|
"name": "tailwind-typescript-plugin",
|
|
68
83
|
"globalCss": "./src/global.css",
|
|
69
|
-
"
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
84
|
+
"libraries": {
|
|
85
|
+
"utilities": {
|
|
86
|
+
"cn": "@/lib/utils",
|
|
87
|
+
"merge": "tailwind-merge",
|
|
88
|
+
"myFn": "*"
|
|
89
|
+
},
|
|
90
|
+
"variants": {
|
|
91
|
+
"tailwindVariants": true,
|
|
92
|
+
"classVarianceAuthority": true
|
|
93
|
+
}
|
|
94
|
+
},
|
|
95
|
+
"validation": {
|
|
96
|
+
"enabled": true,
|
|
97
|
+
"severity": "error",
|
|
98
|
+
"allowedClasses": ["custom-*", "app-*"]
|
|
99
|
+
},
|
|
100
|
+
"lint": {
|
|
101
|
+
"enabled": true,
|
|
102
|
+
"conflictingClasses": {
|
|
103
|
+
"enabled": true,
|
|
104
|
+
"severity": "warning"
|
|
105
|
+
},
|
|
106
|
+
"repeatedClasses": {
|
|
107
|
+
"enabled": true,
|
|
108
|
+
"severity": "warning"
|
|
109
|
+
}
|
|
110
|
+
},
|
|
111
|
+
"editor": {
|
|
112
|
+
"enabled": true,
|
|
113
|
+
"autocomplete": {
|
|
114
|
+
"enabled": true
|
|
115
|
+
},
|
|
116
|
+
"hover": {
|
|
117
|
+
"enabled": true
|
|
118
|
+
}
|
|
74
119
|
}
|
|
75
120
|
}
|
|
76
121
|
]
|
|
@@ -80,159 +125,183 @@ Add the plugin to the `compilerOptions.plugins` array in your `tsconfig.json`:
|
|
|
80
125
|
|
|
81
126
|
**Configuration options:**
|
|
82
127
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
- `allowedClasses` (optional): Array of custom class names or wildcard patterns that should be treated as valid alongside Tailwind classes. Useful for project-specific or third-party utility classes that aren't part of Tailwind.
|
|
86
|
-
- **Default**: `[]` (no custom classes allowed)
|
|
87
|
-
- **Supports wildcard patterns**:
|
|
88
|
-
| Pattern | Description | Example | Matches |
|
|
89
|
-
|---------|-------------|---------|---------|
|
|
90
|
-
| `prefix-*` | Matches classes starting with prefix | `custom-*` | `custom-button`, `custom-card` |
|
|
91
|
-
| `*-suffix` | Matches classes ending with suffix | `*-icon` | `arrow-icon`, `close-icon` |
|
|
92
|
-
| `*-contains-*` | Matches classes containing the string | `*-component-*` | `app-component-header` |
|
|
93
|
-
| `exact` | Exact match (no wildcards) | `my-class` | Only `my-class` |
|
|
94
|
-
- **Example**:
|
|
95
|
-
```json
|
|
96
|
-
{
|
|
97
|
-
"allowedClasses": [
|
|
98
|
-
"custom-*",
|
|
99
|
-
"*-icon",
|
|
100
|
-
"*-component-*",
|
|
101
|
-
"exact-class"
|
|
102
|
-
]
|
|
103
|
-
}
|
|
104
|
-
```
|
|
105
|
-
- Classes matching any pattern will be considered valid and won't trigger validation errors
|
|
106
|
-
- Works with all extraction patterns (literals, expressions, functions, arrays, etc.)
|
|
107
|
-
- Combines with Tailwind classes - both are validated independently
|
|
108
|
-
|
|
109
|
-
- `variants` (optional): Configure which variant library extractors to enable. This is useful for performance optimization when you only use one library.
|
|
110
|
-
- **Default behavior (no config)**: Both `tailwind-variants` and `class-variance-authority` are enabled
|
|
111
|
-
- **Selective enabling**: If you specify ANY variant config, only those explicitly set to `true` are enabled
|
|
112
|
-
- **Example configurations**:
|
|
113
|
-
```json
|
|
114
|
-
// Enable only tailwind-variants
|
|
115
|
-
{
|
|
116
|
-
"variants": {
|
|
117
|
-
"tailwindVariants": true
|
|
118
|
-
}
|
|
119
|
-
}
|
|
128
|
+
#### `globalCss` (required)
|
|
129
|
+
Path to your global CSS file that imports Tailwind CSS. This can be relative to your project root.
|
|
120
130
|
|
|
121
|
-
|
|
122
|
-
{
|
|
123
|
-
"variants": {
|
|
124
|
-
"classVarianceAuthority": true
|
|
125
|
-
}
|
|
126
|
-
}
|
|
131
|
+
---
|
|
127
132
|
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
"variants": {
|
|
131
|
-
"tailwindVariants": true,
|
|
132
|
-
"classVarianceAuthority": true
|
|
133
|
-
}
|
|
134
|
-
}
|
|
133
|
+
#### `libraries` (optional)
|
|
134
|
+
Configure utility functions and variant libraries.
|
|
135
135
|
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
// variants not specified - both libraries validated
|
|
139
|
-
}
|
|
140
|
-
```
|
|
141
|
-
- **Performance impact**: Disabling unused extractors skips TypeChecker operations and symbol resolution for that library, providing faster validation
|
|
136
|
+
##### `libraries.utilities`
|
|
137
|
+
Configure which utility functions to scan for class names. Keys are function names, values control import matching:
|
|
142
138
|
|
|
143
|
-
|
|
139
|
+
| Value | Description |
|
|
140
|
+
|-------|-------------|
|
|
141
|
+
| `"*"` | Match any import source |
|
|
142
|
+
| `"off"` | Disable this utility function |
|
|
143
|
+
| `"package-name"` | Only match if imported from this package |
|
|
144
144
|
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
145
|
+
**Defaults** (automatically included):
|
|
146
|
+
```json
|
|
147
|
+
{
|
|
148
|
+
"cn": "*",
|
|
149
|
+
"clsx": "clsx",
|
|
150
|
+
"classnames": "classnames",
|
|
151
|
+
"classNames": "classnames",
|
|
152
|
+
"cx": "classnames",
|
|
153
|
+
"twMerge": "tailwind-merge"
|
|
154
|
+
}
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
**Example - Add custom utility and disable a default**:
|
|
158
|
+
```json
|
|
159
|
+
{
|
|
160
|
+
"libraries": {
|
|
161
|
+
"utilities": {
|
|
162
|
+
"myMerge": "@/lib/utils",
|
|
163
|
+
"clsx": "off"
|
|
164
|
+
}
|
|
149
165
|
}
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
166
|
+
}
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
**Supported import patterns**:
|
|
170
|
+
```typescript
|
|
171
|
+
// Named import
|
|
172
|
+
import { merge } from '@/lib/utils';
|
|
173
|
+
className={merge('flex', 'items-center')} // ✅ Validated
|
|
174
|
+
|
|
175
|
+
// Default import
|
|
176
|
+
import merge from '@/lib/utils';
|
|
177
|
+
className={merge('flex', 'items-center')} // ✅ Validated
|
|
178
|
+
|
|
179
|
+
// Namespace import
|
|
180
|
+
import * as utils from '@/lib/utils';
|
|
181
|
+
className={utils.merge('flex', 'items-center')} // ✅ Validated
|
|
182
|
+
|
|
183
|
+
// Aliased import
|
|
184
|
+
import { something as merge } from '@/lib/utils';
|
|
185
|
+
className={merge('flex', 'items-center')} // ✅ Validated
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
##### `libraries.variants`
|
|
189
|
+
Configure which variant library extractors to enable.
|
|
190
|
+
|
|
191
|
+
| Option | Default | Description |
|
|
192
|
+
|--------|---------|-------------|
|
|
193
|
+
| `tailwindVariants` | `true` | Enable `tv()` function support |
|
|
194
|
+
| `classVarianceAuthority` | `true` | Enable `cva()` function support |
|
|
195
|
+
|
|
196
|
+
**Example - Enable only tailwind-variants**:
|
|
197
|
+
```json
|
|
198
|
+
{
|
|
199
|
+
"libraries": {
|
|
200
|
+
"variants": {
|
|
201
|
+
"tailwindVariants": true,
|
|
202
|
+
"classVarianceAuthority": false
|
|
203
|
+
}
|
|
159
204
|
}
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
205
|
+
}
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
---
|
|
209
|
+
|
|
210
|
+
#### `validation` (optional)
|
|
211
|
+
Configure invalid class detection.
|
|
212
|
+
|
|
213
|
+
| Option | Default | Description |
|
|
214
|
+
|--------|---------|-------------|
|
|
215
|
+
| `enabled` | `true` | Enable/disable invalid class validation |
|
|
216
|
+
| `severity` | `"error"` | `"error"` \| `"warning"` \| `"suggestion"` \| `"off"` |
|
|
217
|
+
| `allowedClasses` | `[]` | Custom class patterns to allow |
|
|
218
|
+
|
|
219
|
+
##### `validation.allowedClasses`
|
|
220
|
+
Array of custom class names or wildcard patterns that should be treated as valid.
|
|
221
|
+
|
|
222
|
+
| Pattern | Description | Example | Matches |
|
|
223
|
+
|---------|-------------|---------|---------|
|
|
224
|
+
| `prefix-*` | Matches classes starting with prefix | `custom-*` | `custom-button`, `custom-card` |
|
|
225
|
+
| `*-suffix` | Matches classes ending with suffix | `*-icon` | `arrow-icon`, `close-icon` |
|
|
226
|
+
| `*-contains-*` | Matches classes containing the string | `*-component-*` | `app-component-header` |
|
|
227
|
+
| `exact` | Exact match (no wildcards) | `my-class` | Only `my-class` |
|
|
228
|
+
|
|
229
|
+
**Example**:
|
|
230
|
+
```json
|
|
231
|
+
{
|
|
232
|
+
"validation": {
|
|
233
|
+
"allowedClasses": ["custom-*", "*-icon", "exact-class"]
|
|
169
234
|
}
|
|
170
|
-
|
|
235
|
+
}
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
---
|
|
171
239
|
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
- **Subpath matching**: `{ "name": "fn", "from": "my-pkg" }` also matches `import { fn } from 'my-pkg/utils'`
|
|
240
|
+
#### `lint` (optional)
|
|
241
|
+
Configure lint rules for code quality issues.
|
|
175
242
|
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
243
|
+
| Option | Default | Description |
|
|
244
|
+
|--------|---------|-------------|
|
|
245
|
+
| `enabled` | `true` | Master switch for all lint rules |
|
|
246
|
+
| `conflictingClasses` | `{ enabled: true, severity: "warning" }` | Detect conflicting utilities |
|
|
247
|
+
| `repeatedClasses` | `{ enabled: true, severity: "warning" }` | Detect duplicate classes |
|
|
248
|
+
|
|
249
|
+
**Example - Disable conflicting class detection**:
|
|
250
|
+
```json
|
|
251
|
+
{
|
|
252
|
+
"lint": {
|
|
253
|
+
"conflictingClasses": {
|
|
254
|
+
"enabled": false
|
|
255
|
+
}
|
|
181
256
|
}
|
|
257
|
+
}
|
|
258
|
+
```
|
|
182
259
|
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
260
|
+
**Example - Make duplicate classes an error**:
|
|
261
|
+
```json
|
|
262
|
+
{
|
|
263
|
+
"lint": {
|
|
264
|
+
"repeatedClasses": {
|
|
265
|
+
"severity": "error"
|
|
266
|
+
}
|
|
189
267
|
}
|
|
268
|
+
}
|
|
269
|
+
```
|
|
190
270
|
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
271
|
+
---
|
|
272
|
+
|
|
273
|
+
#### `editor` (optional)
|
|
274
|
+
Configure editor features like autocomplete and hover.
|
|
275
|
+
|
|
276
|
+
| Option | Default | Description |
|
|
277
|
+
|--------|---------|-------------|
|
|
278
|
+
| `enabled` | `true` | Master switch for all editor features |
|
|
279
|
+
| `autocomplete.enabled` | `true` | Enable Tailwind class autocomplete |
|
|
280
|
+
| `hover.enabled` | `true` | Enable hover information showing CSS |
|
|
281
|
+
|
|
282
|
+
**Example - Disable autocomplete**:
|
|
283
|
+
```json
|
|
284
|
+
{
|
|
285
|
+
"editor": {
|
|
286
|
+
"autocomplete": {
|
|
287
|
+
"enabled": false
|
|
288
|
+
}
|
|
197
289
|
}
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
// Wrong import source (not validated when using object format)
|
|
215
|
-
import { merge } from 'different-package';
|
|
216
|
-
className={merge('flex', 'invalid-class')} // ⏭️ Skipped (wrong import)
|
|
217
|
-
```
|
|
218
|
-
|
|
219
|
-
**Supported call patterns**:
|
|
220
|
-
```typescript
|
|
221
|
-
// Simple calls (validated by default):
|
|
222
|
-
className={clsx('flex', 'items-center')}
|
|
223
|
-
className={cn('flex', 'items-center')}
|
|
224
|
-
|
|
225
|
-
// Member expressions (nested property access):
|
|
226
|
-
className={utils.cn('flex', 'items-center')}
|
|
227
|
-
className={lib.clsx('flex', 'items-center')}
|
|
228
|
-
|
|
229
|
-
// Custom functions (add via config):
|
|
230
|
-
className={myCustomFn('flex', 'items-center')}
|
|
231
|
-
className={buildClasses('flex', 'items-center')}
|
|
232
|
-
|
|
233
|
-
// Dynamic calls (ignored, won't throw errors):
|
|
234
|
-
className={functions['cn']('flex', 'items-center')}
|
|
235
|
-
```
|
|
290
|
+
}
|
|
291
|
+
```
|
|
292
|
+
|
|
293
|
+
---
|
|
294
|
+
|
|
295
|
+
### Backwards Compatibility
|
|
296
|
+
|
|
297
|
+
The following deprecated options are still supported but will be removed in a future version:
|
|
298
|
+
|
|
299
|
+
| Deprecated | New Location |
|
|
300
|
+
|------------|--------------|
|
|
301
|
+
| `utilityFunctions` | `libraries.utilities` |
|
|
302
|
+
| `variants` | `libraries.variants` |
|
|
303
|
+
| `allowedClasses` | `validation.allowedClasses` |
|
|
304
|
+
| `enableLogging` | Removed (no replacement) |
|
|
236
305
|
|
|
237
306
|
### 2. Ensure your CSS file imports Tailwind
|
|
238
307
|
|
package/lib/core/interfaces.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as ts from 'typescript/lib/tsserverlibrary';
|
|
2
|
-
import { ClassNameInfo, ExtractionContext,
|
|
2
|
+
import { ClassNameInfo, EditorConfig, ExtractionContext, LibrariesConfig, LintConfig, ValidationConfig } from './types';
|
|
3
3
|
/**
|
|
4
4
|
* Base interface for class name extractors
|
|
5
5
|
* Follows the Strategy pattern for extensibility
|
|
@@ -22,22 +22,27 @@ export interface IClassNameValidator {
|
|
|
22
22
|
isInitialized(): boolean;
|
|
23
23
|
setAllowedClasses(allowedClasses: string[]): void;
|
|
24
24
|
}
|
|
25
|
-
/**
|
|
26
|
-
* Interface for variant library configuration
|
|
27
|
-
*/
|
|
28
|
-
export interface IVariantsConfig {
|
|
29
|
-
tailwindVariants?: boolean;
|
|
30
|
-
classVarianceAuthority?: boolean;
|
|
31
|
-
}
|
|
32
25
|
/**
|
|
33
26
|
* Interface for configuration management
|
|
34
27
|
*/
|
|
35
28
|
export interface IPluginConfig {
|
|
36
29
|
globalCss?: string;
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
30
|
+
/**
|
|
31
|
+
* Library configurations (utilities and variants)
|
|
32
|
+
*/
|
|
33
|
+
libraries?: LibrariesConfig;
|
|
34
|
+
/**
|
|
35
|
+
* Validation configuration (invalid class detection)
|
|
36
|
+
*/
|
|
37
|
+
validation?: ValidationConfig;
|
|
38
|
+
/**
|
|
39
|
+
* Lint configuration (conflicting and repeated classes)
|
|
40
|
+
*/
|
|
41
|
+
lint?: LintConfig;
|
|
42
|
+
/**
|
|
43
|
+
* Editor features configuration (autocomplete and hover)
|
|
44
|
+
*/
|
|
45
|
+
editor?: EditorConfig;
|
|
41
46
|
}
|
|
42
47
|
/**
|
|
43
48
|
* Interface for diagnostic creation
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../../src/core/interfaces.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,gCAAgC,CAAC;AAErD,OAAO,
|
|
1
|
+
{"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../../src/core/interfaces.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,gCAAgC,CAAC;AAErD,OAAO,EACN,aAAa,EACb,YAAY,EACZ,iBAAiB,EACjB,eAAe,EACf,UAAU,EACV,gBAAgB,EAChB,MAAM,SAAS,CAAC;AAEjB;;;GAGG;AACH,MAAM,WAAW,mBAAmB;IACnC;;OAEG;IACH,SAAS,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,EAAE,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC;IAE9D;;OAEG;IACH,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,EAAE,OAAO,EAAE,iBAAiB,GAAG,aAAa,EAAE,CAAC;CACpE;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB;IACnC,YAAY,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC;IACzC,aAAa,IAAI,OAAO,CAAC;IACzB,iBAAiB,CAAC,cAAc,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;CAClD;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC7B,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB;;OAEG;IACH,SAAS,CAAC,EAAE,eAAe,CAAC;IAE5B;;OAEG;IACH,UAAU,CAAC,EAAE,gBAAgB,CAAC;IAE9B;;OAEG;IACH,IAAI,CAAC,EAAE,UAAU,CAAC;IAElB;;OAEG;IACH,MAAM,CAAC,EAAE,YAAY,CAAC;CACtB;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB;IAClC,gBAAgB,CAAC,SAAS,EAAE,aAAa,EAAE,UAAU,EAAE,EAAE,CAAC,UAAU,GAAG,EAAE,CAAC,UAAU,CAAC;CACrF"}
|
package/lib/core/types.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as ts from 'typescript/lib/tsserverlibrary';
|
|
2
|
+
import { Framework } from '../utils/FrameworkDetector';
|
|
2
3
|
/**
|
|
3
4
|
* Represents a utility function configuration with optional import source
|
|
4
5
|
* When 'from' is specified, the import will be verified before matching
|
|
@@ -6,6 +7,8 @@ import * as ts from 'typescript/lib/tsserverlibrary';
|
|
|
6
7
|
* Examples:
|
|
7
8
|
* - { name: 'clsx', from: 'clsx' } - matches `import { clsx } from 'clsx'` or `import clsx from 'clsx'`
|
|
8
9
|
* - { name: 'cn', from: '@/lib/utils' } - matches `import { cn } from '@/lib/utils'`
|
|
10
|
+
*
|
|
11
|
+
* @deprecated Use the new libraries.utilities config format instead
|
|
9
12
|
*/
|
|
10
13
|
export interface UtilityFunctionConfig {
|
|
11
14
|
name: string;
|
|
@@ -15,8 +18,81 @@ export interface UtilityFunctionConfig {
|
|
|
15
18
|
* A utility function can be either:
|
|
16
19
|
* - A simple string (matches by function name only, backwards compatible)
|
|
17
20
|
* - A UtilityFunctionConfig object (matches by name AND verifies import source)
|
|
21
|
+
*
|
|
22
|
+
* @deprecated Use the new libraries.utilities config format instead
|
|
18
23
|
*/
|
|
19
24
|
export type UtilityFunction = string | UtilityFunctionConfig;
|
|
25
|
+
/**
|
|
26
|
+
* Severity level for diagnostics
|
|
27
|
+
*/
|
|
28
|
+
export type DiagnosticSeverity = 'error' | 'warning' | 'suggestion' | 'off';
|
|
29
|
+
/**
|
|
30
|
+
* Configuration for utilities (utility functions like cn, clsx, etc.)
|
|
31
|
+
* Key is the function name, value is:
|
|
32
|
+
* - string: import path (e.g., "clsx", "@/lib/utils")
|
|
33
|
+
* - "*": match any import source
|
|
34
|
+
* - "off": disable this utility function
|
|
35
|
+
*/
|
|
36
|
+
export type UtilitiesConfig = {
|
|
37
|
+
[functionName: string]: string;
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* Configuration for variant libraries
|
|
41
|
+
*/
|
|
42
|
+
export interface VariantsConfig {
|
|
43
|
+
tailwindVariants?: boolean;
|
|
44
|
+
classVarianceAuthority?: boolean;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Configuration for libraries (utilities and variants)
|
|
48
|
+
*/
|
|
49
|
+
export interface LibrariesConfig {
|
|
50
|
+
utilities?: UtilitiesConfig;
|
|
51
|
+
variants?: VariantsConfig;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Configuration for validation (invalid class detection)
|
|
55
|
+
*/
|
|
56
|
+
export interface ValidationConfig {
|
|
57
|
+
enabled?: boolean;
|
|
58
|
+
severity?: DiagnosticSeverity;
|
|
59
|
+
allowedClasses?: string[];
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Configuration for a single lint rule
|
|
63
|
+
*/
|
|
64
|
+
export interface LintRuleConfig {
|
|
65
|
+
enabled?: boolean;
|
|
66
|
+
severity?: DiagnosticSeverity;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Configuration for lint rules
|
|
70
|
+
*/
|
|
71
|
+
export interface LintConfig {
|
|
72
|
+
enabled?: boolean;
|
|
73
|
+
conflictingClasses?: LintRuleConfig;
|
|
74
|
+
repeatedClasses?: LintRuleConfig;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Configuration for autocomplete
|
|
78
|
+
*/
|
|
79
|
+
export interface AutocompleteConfig {
|
|
80
|
+
enabled?: boolean;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Configuration for hover information
|
|
84
|
+
*/
|
|
85
|
+
export interface HoverConfig {
|
|
86
|
+
enabled?: boolean;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Configuration for editor features
|
|
90
|
+
*/
|
|
91
|
+
export interface EditorConfig {
|
|
92
|
+
enabled?: boolean;
|
|
93
|
+
autocomplete?: AutocompleteConfig;
|
|
94
|
+
hover?: HoverConfig;
|
|
95
|
+
}
|
|
20
96
|
/**
|
|
21
97
|
* Represents information about a class name found in source code
|
|
22
98
|
*/
|
|
@@ -65,6 +141,11 @@ export interface ExtractionContext {
|
|
|
65
141
|
readonly sourceFile: ts.SourceFile;
|
|
66
142
|
readonly utilityFunctions: UtilityFunction[];
|
|
67
143
|
readonly typeChecker?: ts.TypeChecker;
|
|
144
|
+
/**
|
|
145
|
+
* The detected framework for the current file
|
|
146
|
+
* Used to determine which extractor to use
|
|
147
|
+
*/
|
|
148
|
+
readonly framework?: Framework;
|
|
68
149
|
}
|
|
69
150
|
/**
|
|
70
151
|
* Result of extraction operation
|
package/lib/core/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/core/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,gCAAgC,CAAC;AAErD
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/core/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,gCAAgC,CAAC;AAErD,OAAO,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AAEvD;;;;;;;;;GASG;AACH,MAAM,WAAW,qBAAqB;IACrC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACb;AAED;;;;;;GAMG;AACH,MAAM,MAAM,eAAe,GAAG,MAAM,GAAG,qBAAqB,CAAC;AAE7D;;GAEG;AACH,MAAM,MAAM,kBAAkB,GAAG,OAAO,GAAG,SAAS,GAAG,YAAY,GAAG,KAAK,CAAC;AAE5E;;;;;;GAMG;AACH,MAAM,MAAM,eAAe,GAAG;IAC7B,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM,CAAC;CAC/B,CAAC;AAEF;;GAEG;AACH,MAAM,WAAW,cAAc;IAC9B,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,sBAAsB,CAAC,EAAE,OAAO,CAAC;CACjC;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC/B,SAAS,CAAC,EAAE,eAAe,CAAC;IAC5B,QAAQ,CAAC,EAAE,cAAc,CAAC;CAC1B;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAChC,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,QAAQ,CAAC,EAAE,kBAAkB,CAAC;IAC9B,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;CAC1B;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC9B,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,QAAQ,CAAC,EAAE,kBAAkB,CAAC;CAC9B;AAED;;GAEG;AACH,MAAM,WAAW,UAAU;IAC1B,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,kBAAkB,CAAC,EAAE,cAAc,CAAC;IACpC,eAAe,CAAC,EAAE,cAAc,CAAC;CACjC;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB;IAClC,OAAO,CAAC,EAAE,OAAO,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IAC3B,OAAO,CAAC,EAAE,OAAO,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IAC5B,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,YAAY,CAAC,EAAE,kBAAkB,CAAC;IAClC,KAAK,CAAC,EAAE,WAAW,CAAC;CACpB;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC7B,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,EAAE,MAAM,CAAC;IACtB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb;;;OAGG;IACH,aAAa,CAAC,EAAE;QACf,YAAY,EAAE,MAAM,CAAC;QACrB,SAAS,EAAE,MAAM,CAAC;KAClB,CAAC;IACF;;;;OAIG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;;;;OAMG;IACH,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B;;;;;;OAMG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;CACpB;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IACjC,QAAQ,CAAC,UAAU,EAAE,OAAO,EAAE,CAAC;IAC/B,QAAQ,CAAC,UAAU,EAAE,EAAE,CAAC,UAAU,CAAC;IACnC,QAAQ,CAAC,gBAAgB,EAAE,eAAe,EAAE,CAAC;IAC7C,QAAQ,CAAC,WAAW,CAAC,EAAE,EAAE,CAAC,WAAW,CAAC;IACtC;;;OAGG;IACH,QAAQ,CAAC,SAAS,CAAC,EAAE,SAAS,CAAC;CAC/B;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAChC,UAAU,EAAE,aAAa,EAAE,CAAC;CAC5B"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import * as ts from 'typescript/lib/tsserverlibrary';
|
|
2
|
+
import { ClassNameInfo, ExtractionContext } from '../core/types';
|
|
3
|
+
import { BaseExtractor } from './BaseExtractor';
|
|
4
|
+
/**
|
|
5
|
+
* Extracts class names from Svelte template class attributes
|
|
6
|
+
* Assumes proper Svelte language support is configured
|
|
7
|
+
*
|
|
8
|
+
* TODO: Implement Svelte-specific extraction logic
|
|
9
|
+
* - Handle class static attributes
|
|
10
|
+
* - Handle class:name={condition} directive syntax
|
|
11
|
+
* - Handle {expression} dynamic bindings
|
|
12
|
+
*/
|
|
13
|
+
export declare class SvelteAttributeExtractor extends BaseExtractor {
|
|
14
|
+
canHandle(node: ts.Node, context: ExtractionContext): boolean;
|
|
15
|
+
extract(node: ts.Node, context: ExtractionContext): ClassNameInfo[];
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=SvelteAttributeExtractor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SvelteAttributeExtractor.d.ts","sourceRoot":"","sources":["../../src/extractors/SvelteAttributeExtractor.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,gCAAgC,CAAC;AAErD,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AACjE,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEhD;;;;;;;;GAQG;AACH,qBAAa,wBAAyB,SAAQ,aAAa;IAC1D,SAAS,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,EAAE,OAAO,EAAE,iBAAiB,GAAG,OAAO;IAM7D,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,EAAE,OAAO,EAAE,iBAAiB,GAAG,aAAa,EAAE;CAKnE"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SvelteAttributeExtractor = void 0;
|
|
4
|
+
const BaseExtractor_1 = require("./BaseExtractor");
|
|
5
|
+
/**
|
|
6
|
+
* Extracts class names from Svelte template class attributes
|
|
7
|
+
* Assumes proper Svelte language support is configured
|
|
8
|
+
*
|
|
9
|
+
* TODO: Implement Svelte-specific extraction logic
|
|
10
|
+
* - Handle class static attributes
|
|
11
|
+
* - Handle class:name={condition} directive syntax
|
|
12
|
+
* - Handle {expression} dynamic bindings
|
|
13
|
+
*/
|
|
14
|
+
class SvelteAttributeExtractor extends BaseExtractor_1.BaseExtractor {
|
|
15
|
+
canHandle(node, context) {
|
|
16
|
+
// TODO: Implement Svelte node detection
|
|
17
|
+
// For now, return false as this is a stub
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
20
|
+
extract(node, context) {
|
|
21
|
+
// TODO: Implement Svelte class extraction
|
|
22
|
+
// This is a placeholder that will be implemented in the next phase
|
|
23
|
+
return [];
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
exports.SvelteAttributeExtractor = SvelteAttributeExtractor;
|
|
27
|
+
//# sourceMappingURL=SvelteAttributeExtractor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SvelteAttributeExtractor.js","sourceRoot":"","sources":["../../src/extractors/SvelteAttributeExtractor.ts"],"names":[],"mappings":";;;AAIA,mDAAgD;AAEhD;;;;;;;;GAQG;AACH,MAAa,wBAAyB,SAAQ,6BAAa;IAC1D,SAAS,CAAC,IAAa,EAAE,OAA0B;QAClD,wCAAwC;QACxC,0CAA0C;QAC1C,OAAO,KAAK,CAAC;IACd,CAAC;IAED,OAAO,CAAC,IAAa,EAAE,OAA0B;QAChD,0CAA0C;QAC1C,mEAAmE;QACnE,OAAO,EAAE,CAAC;IACX,CAAC;CACD;AAZD,4DAYC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import * as ts from 'typescript/lib/tsserverlibrary';
|
|
2
|
+
import { ClassNameInfo, ExtractionContext } from '../core/types';
|
|
3
|
+
import { BaseExtractor } from './BaseExtractor';
|
|
4
|
+
/**
|
|
5
|
+
* Extracts class names from Vue template class attributes
|
|
6
|
+
* Assumes @vue/language-tools is configured and transforms Vue templates
|
|
7
|
+
*
|
|
8
|
+
* TODO: Implement Vue-specific extraction logic
|
|
9
|
+
* - Handle :class (v-bind:class) dynamic bindings
|
|
10
|
+
* - Handle class static attributes
|
|
11
|
+
* - Handle object syntax: :class="{ 'active': isActive }"
|
|
12
|
+
* - Handle array syntax: :class="['base', { 'active': isActive }]"
|
|
13
|
+
*/
|
|
14
|
+
export declare class VueAttributeExtractor extends BaseExtractor {
|
|
15
|
+
canHandle(node: ts.Node, context: ExtractionContext): boolean;
|
|
16
|
+
extract(node: ts.Node, context: ExtractionContext): ClassNameInfo[];
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=VueAttributeExtractor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"VueAttributeExtractor.d.ts","sourceRoot":"","sources":["../../src/extractors/VueAttributeExtractor.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,gCAAgC,CAAC;AAErD,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AACjE,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEhD;;;;;;;;;GASG;AACH,qBAAa,qBAAsB,SAAQ,aAAa;IACvD,SAAS,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,EAAE,OAAO,EAAE,iBAAiB,GAAG,OAAO;IAM7D,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,EAAE,OAAO,EAAE,iBAAiB,GAAG,aAAa,EAAE;CAKnE"}
|