Skip to content

Commit a6633f3

Browse files
authoredDec 24, 2022
fix: print linting errors in red (#1150)
To make the output of eslint a bit eaier to read, print the errors in red.
1 parent 80f10b3 commit a6633f3

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed
 

‎src/lint.js

+13-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import fs from 'fs-extra'
99
import merge from 'merge-options'
1010
import { fromRoot, readJson, hasTsconfig, isTypescript, findBinary } from './utils.js'
1111
import { fileURLToPath } from 'url'
12+
import kleur from 'kleur'
1213

1314
const __dirname = path.dirname(fileURLToPath(import.meta.url))
1415

@@ -43,7 +44,18 @@ const tasks = new Listr(
4344
}
4445

4546
if (!ctx.silent && hasErrors) {
46-
console.error(formatter.format(results))
47+
const output = await formatter.format(results)
48+
49+
console.error(output
50+
.split('\n')
51+
.map(line => {
52+
if (line.includes('[Error')) {
53+
return kleur.red(line)
54+
}
55+
56+
return line
57+
})
58+
.join('\n'))
4759
}
4860

4961
if (hasErrors) {

0 commit comments

Comments
 (0)
Please sign in to comment.