@@ -6,14 +6,26 @@ import type { Issue, ReporterOptions } from '../types/issues.js';
6
6
import { relative , toRelative } from '../util/path.js' ;
7
7
import { getTitle , identity , logTitle } from './util.js' ;
8
8
9
+ const dim = picocolors . gray ;
10
+ const bright = picocolors . whiteBright ;
11
+
9
12
const TRUNCATE_WIDTH = 40 ;
10
13
const truncate = ( text : string ) => ( text . length > TRUNCATE_WIDTH ? `${ text . slice ( 0 , TRUNCATE_WIDTH - 3 ) } ...` : text ) ;
11
14
15
+ const hl = ( issue : Issue ) => {
16
+ if ( issue . specifier && issue . specifier !== issue . symbol && issue . specifier . includes ( issue . symbol ) ) {
17
+ const parts = issue . specifier . split ( issue . symbol ) ;
18
+ const rest = parts . slice ( 1 ) . join ( '' ) ;
19
+ return [ dim ( parts [ 0 ] ) , bright ( issue . symbol ) , dim ( rest ) ] . join ( '' ) ;
20
+ }
21
+ return issue . symbol ;
22
+ } ;
23
+
12
24
const logIssueRecord = ( issues : Issue [ ] ) => {
13
25
const table = new EasyTable ( ) ;
14
26
for ( const issue of issues ) {
15
- const print = issue . isFixed || issue . severity === 'warn' ? picocolors . gray : identity ;
16
- table . cell ( 'symbol' , print ( issue . symbols ? truncate ( issue . symbols . map ( s => s . symbol ) . join ( ', ' ) ) : issue . symbol ) ) ;
27
+ const print = issue . isFixed || issue . severity === 'warn' ? dim : identity ;
28
+ table . cell ( 'symbol' , print ( issue . symbols ? truncate ( issue . symbols . map ( s => s . symbol ) . join ( ', ' ) ) : hl ( issue ) ) ) ;
17
29
issue . parentSymbol && table . cell ( 'parentSymbol' , print ( issue . parentSymbol ) ) ;
18
30
issue . symbolType && table . cell ( 'symbolType' , print ( issue . symbolType ) ) ;
19
31
const pos = issue . line === undefined ? '' : `:${ issue . line } ${ issue . col === undefined ? '' : `:${ issue . col } ` } ` ;
@@ -41,8 +53,8 @@ export default ({ report, issues, tagHints, configurationHints, noConfigHints, i
41
53
title && logTitle ( title , issuesForType . length ) ;
42
54
for ( const issue of issuesForType ) {
43
55
const relPath = toRelative ( issue . filePath ) ;
44
- if ( issue . isFixed ) console . log ( picocolors . gray ( `${ relPath } (removed)` ) ) ;
45
- else if ( issue . severity === 'warn' ) console . log ( picocolors . gray ( relPath ) ) ;
56
+ if ( issue . isFixed ) console . log ( dim ( `${ relPath } (removed)` ) ) ;
57
+ else if ( issue . severity === 'warn' ) console . log ( dim ( relPath ) ) ;
46
58
else console . log ( relPath ) ;
47
59
}
48
60
totalIssues = totalIssues + issuesForType . length ;
@@ -66,15 +78,15 @@ export default ({ report, issues, tagHints, configurationHints, noConfigHints, i
66
78
const message = `Unused item in ${ type } ` ;
67
79
const workspace =
68
80
workspaceName && workspaceName !== ROOT_WORKSPACE_NAME ? ` (workspace: ${ workspaceName } )` : '' ;
69
- console . warn ( picocolors . gray ( `${ message } ${ workspace } :` ) , identifier ) ;
81
+ console . warn ( dim ( `${ message } ${ workspace } :` ) , identifier ) ;
70
82
}
71
83
}
72
84
if ( tagHints . size > 0 ) {
73
85
logTitle ( 'Tag issues' , tagHints . size ) ;
74
86
for ( const hint of tagHints ) {
75
87
const { filePath, identifier, tagName } = hint ;
76
88
const message = `Unused tag in ${ toRelative ( filePath ) } :` ;
77
- console . warn ( picocolors . gray ( message ) , `${ identifier } → ${ tagName } ` ) ;
89
+ console . warn ( dim ( message ) , `${ identifier } → ${ tagName } ` ) ;
78
90
}
79
91
}
80
92
}
0 commit comments