@@ -68,7 +68,7 @@ const prepareText = (value: string): string =>
6868 . replace ( / \d (? ! $ | \d ) / g, '$& ' )
6969 . replace ( / \s + / g, ' ' )
7070
71- export class TwindTemplateLanguageService implements TemplateLanguageService {
71+ export class TwindLanguageService implements TemplateLanguageService {
7272 private readonly typescript : typeof ts
7373 private readonly configurationManager : ConfigurationManager
7474 private readonly logger : Logger
@@ -234,11 +234,11 @@ export class TwindTemplateLanguageService implements TemplateLanguageService {
234234 switch ( info . id ) {
235235 case 'UNKNOWN_DIRECTIVE' : {
236236 return {
237- messageText : `Unknown utility "${ rule . name } "` ,
237+ messageText : `Unknown utility "${ info . rule } "` ,
238238 start : rule . loc . start ,
239239 length : rule . loc . end - rule . loc . start ,
240240 file : context . node . getSourceFile ( ) ,
241- category : this . typescript . DiagnosticCategory . Warning ,
241+ category : this . typescript . DiagnosticCategory . Error ,
242242 code : ErrorCodes . UNKNOWN_DIRECTIVE ,
243243 }
244244 }
@@ -251,17 +251,36 @@ export class TwindTemplateLanguageService implements TemplateLanguageService {
251251 start : rule . loc . start ,
252252 length : rule . loc . end - rule . loc . start ,
253253 file : context . node . getSourceFile ( ) ,
254- category : this . typescript . DiagnosticCategory . Warning ,
254+ category : this . typescript . DiagnosticCategory . Error ,
255255 code : ErrorCodes . UNKNOWN_THEME_VALUE ,
256256 }
257257 }
258258 }
259259 }
260260 } )
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+ )
261274 // check if every rule.variants exist
262275 . concat (
263276 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+ )
265284 . map (
266285 ( variant ) : ts . Diagnostic => ( {
267286 messageText : `Unknown variant "${ variant . value } "` ,
@@ -390,13 +409,8 @@ export class TwindTemplateLanguageService implements TemplateLanguageService {
390409 keys : [ ( completion ) => prepareText ( completion . value + ' ' + completion . detail ) ] ,
391410 baseSort,
392411 } ) ,
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,
400414 keys : [ ( completion ) => prepareText ( completion . value ) ] ,
401415 baseSort,
402416 } ) ,
0 commit comments