@@ -68,7 +68,7 @@ const prepareText = (value: string): string =>
68
68
. replace ( / \d (? ! $ | \d ) / g, '$& ' )
69
69
. replace ( / \s + / g, ' ' )
70
70
71
- export class TwindTemplateLanguageService implements TemplateLanguageService {
71
+ export class TwindLanguageService implements TemplateLanguageService {
72
72
private readonly typescript : typeof ts
73
73
private readonly configurationManager : ConfigurationManager
74
74
private readonly logger : Logger
@@ -234,11 +234,11 @@ export class TwindTemplateLanguageService implements TemplateLanguageService {
234
234
switch ( info . id ) {
235
235
case 'UNKNOWN_DIRECTIVE' : {
236
236
return {
237
- messageText : `Unknown utility "${ rule . name } "` ,
237
+ messageText : `Unknown utility "${ info . rule } "` ,
238
238
start : rule . loc . start ,
239
239
length : rule . loc . end - rule . loc . start ,
240
240
file : context . node . getSourceFile ( ) ,
241
- category : this . typescript . DiagnosticCategory . Warning ,
241
+ category : this . typescript . DiagnosticCategory . Error ,
242
242
code : ErrorCodes . UNKNOWN_DIRECTIVE ,
243
243
}
244
244
}
@@ -251,17 +251,36 @@ export class TwindTemplateLanguageService implements TemplateLanguageService {
251
251
start : rule . loc . start ,
252
252
length : rule . loc . end - rule . loc . start ,
253
253
file : context . node . getSourceFile ( ) ,
254
- category : this . typescript . DiagnosticCategory . Warning ,
254
+ category : this . typescript . DiagnosticCategory . Error ,
255
255
code : ErrorCodes . UNKNOWN_THEME_VALUE ,
256
256
}
257
257
}
258
258
}
259
259
}
260
260
} )
261
+ // Check non-empty directive
262
+ . concat (
263
+ rule . name
264
+ ? undefined
265
+ : {
266
+ messageText : `Missing utility class` ,
267
+ start : rule . loc . start ,
268
+ length : rule . loc . end - rule . loc . start ,
269
+ file : context . node . getSourceFile ( ) ,
270
+ category : this . typescript . DiagnosticCategory . Error ,
271
+ code : ErrorCodes . UNKNOWN_DIRECTIVE ,
272
+ } ,
273
+ )
261
274
// check if every rule.variants exist
262
275
. concat (
263
276
rule . variants
264
- . filter ( ( variant ) => ! this . _twind . completions . variants . has ( variant . value ) )
277
+ . filter (
278
+ ( variant ) =>
279
+ ! (
280
+ this . _twind . completions . variants . has ( variant . value ) ||
281
+ ( variant . value [ 0 ] == '[' && variant . value [ variant . value . length - 2 ] == ']' )
282
+ ) ,
283
+ )
265
284
. map (
266
285
( variant ) : ts . Diagnostic => ( {
267
286
messageText : `Unknown variant "${ variant . value } "` ,
@@ -390,13 +409,8 @@ export class TwindTemplateLanguageService implements TemplateLanguageService {
390
409
keys : [ ( completion ) => prepareText ( completion . value + ' ' + completion . detail ) ] ,
391
410
baseSort,
392
411
} ) ,
393
- ...matchSorter ( utilities , needle , {
394
- // threshold: matchSorter.rankings.ACRONYM,
395
- keys : [ ( completion ) => prepareText ( completion . value ) ] ,
396
- baseSort,
397
- } ) ,
398
- ...matchSorter ( variants , needle , {
399
- // threshold: matchSorter.rankings.ACRONYM,
412
+ ...matchSorter ( [ ...utilities , ...variants ] , needle , {
413
+ // threshold: matchSorter.rankings.MATCHES,
400
414
keys : [ ( completion ) => prepareText ( completion . value ) ] ,
401
415
baseSort,
402
416
} ) ,
0 commit comments