1+ import { styleText } from 'node:util' ;
12import {
23 table ,
34 getBorderCharacters ,
45} from 'table' ;
5- import chalk from 'chalk' ;
66import { jsonFormatter } from '@putout/formatter-json' ;
77
8- const {
9- underline,
10- red,
11- grey,
12- bold,
13- redBright,
14- } = chalk ;
15-
168export default ( { name, places, index, count, filesCount, errorsCount} ) => {
179 const json = jsonFormatter ( {
1810 name,
@@ -35,7 +27,7 @@ export default ({name, places, index, count, filesCount, errorsCount}) => {
3527 const line = buildLine ( places ) ;
3628
3729 output . push ( [
38- underline ( name ) ,
30+ styleText ( 'underline' , name ) ,
3931 table ( line , {
4032 border : getBorderCharacters ( 'void' ) ,
4133 drawHorizontalLine : ( ) => false ,
@@ -46,8 +38,8 @@ export default ({name, places, index, count, filesCount, errorsCount}) => {
4638 const maybeErrors = errorsCount === 1 ? 'error' : 'errors' ;
4739 const maybeFiles = filesCount === 1 ? 'file' : 'files' ;
4840
49- output . push ( bold ( redBright ( `✖ ${ errorsCount } ${ maybeErrors } in ${ filesCount } ${ maybeFiles } ` ) ) ) ;
50- output . push ( bold ( redBright ( ' fixable with the `--fix` option') ) ) ;
41+ output . push ( styleText ( [ 'bold' , ' redBright' ] , `✖ ${ errorsCount } ${ maybeErrors } in ${ filesCount } ${ maybeFiles } ` ) ) ;
42+ output . push ( styleText ( [ 'bold' , ' redBright' ] , ' fixable with the `--fix` option') ) ;
5143
5244 return output . join ( '\n' ) + '\n' ;
5345} ;
@@ -59,9 +51,9 @@ function buildLine(places) {
5951 const { line, column} = position ;
6052
6153 data . push ( [
62- grey ( `${ line } :${ column } ` ) ,
63- `${ red ( 'error' ) } ${ message } ` ,
64- grey ( rule ) ,
54+ styleText ( 'grey' , `${ line } :${ column } ` ) ,
55+ `${ styleText ( 'red' , 'error' ) } ${ message } ` ,
56+ styleText ( 'grey' , rule ) ,
6557 ] ) ;
6658 }
6759
0 commit comments