1
1
import EasyTable from 'easy-table' ;
2
2
import type { Entries } from 'type-fest' ;
3
3
import type { Issue , ReporterOptions } from '../types/issues.js' ;
4
- import { relative , toRelative } from '../util/path.js' ;
4
+ import { relative } from '../util/path.js' ;
5
5
import { getTitle } from './util.js' ;
6
6
7
7
const printHeader = ( size : number , title ?: string ) =>
@@ -16,7 +16,8 @@ const logIssueRecord = (issues: Issue[]) => {
16
16
issue . parentSymbol && table . cell ( 'parentSymbol' , issue . parentSymbol ) ;
17
17
issue . symbolType && table . cell ( 'symbolType' , issue . symbolType ) ;
18
18
const pos = issue . line === undefined ? '' : `:${ issue . line } ${ issue . col === undefined ? '' : `:${ issue . col } ` } ` ;
19
- const cell = `${ relative ( issue . filePath ) } ${ pos } ` ;
19
+ // @ts -expect-error TODO Fix up in next major
20
+ const cell = issue . type === 'files' ? '' : `${ relative ( issue . filePath ) } ${ pos } ` ;
20
21
table . cell ( 'filePath' , cell ) ;
21
22
table . newRow ( ) ;
22
23
}
@@ -27,29 +28,17 @@ export default ({ report, issues }: ReporterOptions) => {
27
28
const reportMultipleGroups = Object . values ( report ) . filter ( Boolean ) . length > 1 ;
28
29
let totalIssues = 0 ;
29
30
30
- for ( const [ reportType , isReportType ] of Object . entries ( report ) as Entries < typeof report > ) {
31
- if ( reportType === '_files ' ) continue ;
31
+ for ( let [ reportType , isReportType ] of Object . entries ( report ) as Entries < typeof report > ) {
32
+ if ( reportType === 'files ' ) reportType = '_files' ;
32
33
33
34
if ( isReportType ) {
34
35
const title = reportMultipleGroups ? getTitle ( reportType ) : undefined ;
35
-
36
- if ( reportType === 'files' ) {
37
- const issuesForType = Array . from ( issues . _files ) ;
38
- if ( issuesForType . length > 0 ) {
39
- printHeader ( issuesForType . length , title ) ;
40
- const sortedIssues = issuesForType . sort ( ( a , b ) => a . filePath . localeCompare ( b . filePath ) ) ;
41
- for ( const issue of sortedIssues ) console . log ( toRelative ( issue . filePath ) ) ;
42
- totalIssues = totalIssues + issuesForType . length ;
43
- printFooter ( ) ;
44
- }
45
- } else {
46
- const issuesForType = Object . values ( issues [ reportType ] ) . flatMap ( Object . values ) ;
47
- if ( issuesForType . length > 0 ) {
48
- printHeader ( issuesForType . length , title ) ;
49
- logIssueRecord ( issuesForType ) ;
50
- totalIssues = totalIssues + issuesForType . length ;
51
- printFooter ( ) ;
52
- }
36
+ const issuesForType = Object . values ( issues [ reportType ] ) . flatMap ( Object . values ) ;
37
+ if ( issuesForType . length > 0 ) {
38
+ printHeader ( issuesForType . length , title ) ;
39
+ logIssueRecord ( issuesForType ) ;
40
+ totalIssues = totalIssues + issuesForType . length ;
41
+ printFooter ( ) ;
53
42
}
54
43
}
55
44
}
0 commit comments