44 * @fileoverview Stylish reporter
55 * @author Sindre Sorhus
66 */
7- import { bold , dim , red , reset , underline , yellow } from 'ansis' ;
7+ import ansis from 'ansis' ;
88import type { ESLint } from 'eslint' ;
99import { stripVTControlCharacters } from 'node:util' ;
1010import { textTable } from './text-table.js' ;
@@ -49,18 +49,18 @@ export function stylishFormatter(results: ESLint.LintResult[]): string {
4949 fixableErrorCount += result . fixableErrorCount ;
5050 fixableWarningCount += result . fixableWarningCount ;
5151
52- output += `${ underline ( result . filePath ) } \n` ;
52+ output += `${ ansis . underline ( result . filePath ) } \n` ;
5353
5454 output += `${ textTable (
5555 messages . map ( message => {
5656 // eslint-disable-next-line functional/no-let
5757 let messageType ;
5858
5959 if ( message . fatal || message . severity === 2 ) {
60- messageType = red ( 'error' ) ;
60+ messageType = ansis . red ( 'error' ) ;
6161 summaryColor = 'red' ;
6262 } else {
63- messageType = yellow ( 'warning' ) ;
63+ messageType = ansis . yellow ( 'warning' ) ;
6464 }
6565
6666 return [
@@ -69,7 +69,7 @@ export function stylishFormatter(results: ESLint.LintResult[]): string {
6969 String ( message . column || 0 ) ,
7070 messageType ,
7171 message . message . replace ( / ( [ ^ ] ) \. $ / u, '$1' ) ,
72- dim ( message . ruleId || '' ) ,
72+ ansis . dim ( message . ruleId || '' ) ,
7373 ] ;
7474 } ) ,
7575 {
@@ -81,16 +81,16 @@ export function stylishFormatter(results: ESLint.LintResult[]): string {
8181 )
8282 . split ( '\n' )
8383 . map ( el =>
84- el . replace ( / ( \d + ) \s + ( \d + ) / u, ( m , p1 , p2 ) => dim ( `${ p1 } :${ p2 } ` ) ) ,
84+ el . replace ( / ( \d + ) \s + ( \d + ) / u, ( m , p1 , p2 ) => ansis . dim ( `${ p1 } :${ p2 } ` ) ) ,
8585 )
8686 . join ( '\n' ) } \n\n`;
8787 } ) ;
8888
8989 const total = errorCount + warningCount ;
9090
9191 if ( total > 0 ) {
92- const colorFn = summaryColor === 'red' ? red : yellow ;
93- output += bold (
92+ const colorFn = summaryColor === 'red' ? ansis . red : ansis . yellow ;
93+ output += ansis . bold (
9494 colorFn (
9595 [
9696 '\u2716 ' ,
@@ -108,7 +108,7 @@ export function stylishFormatter(results: ESLint.LintResult[]): string {
108108 ) ;
109109
110110 if ( fixableErrorCount > 0 || fixableWarningCount > 0 ) {
111- output += bold (
111+ output += ansis . bold (
112112 colorFn (
113113 [
114114 ' ' ,
@@ -125,5 +125,5 @@ export function stylishFormatter(results: ESLint.LintResult[]): string {
125125 }
126126
127127 // Resets output color, for prevent change on top level
128- return total > 0 ? reset ( output ) : '' ;
128+ return total > 0 ? ansis . reset ( output ) : '' ;
129129}
0 commit comments