Skip to content

Commit 708aa2f

Browse files
committed
feature: @putout/formatter-dump: get rid of chalk
1 parent 5210ddf commit 708aa2f

File tree

3 files changed

+10
-16
lines changed

3 files changed

+10
-16
lines changed

packages/formatter-dump/eslint.config.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,8 @@ import {defineConfig} from 'eslint/config';
44
export default defineConfig([
55
safeAlign, {
66
ignores: ['**/fixture'],
7+
rules: {
8+
'n/no-unsupported-features/node-builtins': 'off',
9+
},
710
},
811
]);

packages/formatter-dump/lib/dump.js

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,10 @@
1+
import {styleText} from 'node:util';
12
import {
23
table,
34
getBorderCharacters,
45
} from 'table';
5-
import chalk from 'chalk';
66
import {jsonFormatter} from '@putout/formatter-json';
77

8-
const {
9-
underline,
10-
red,
11-
grey,
12-
bold,
13-
redBright,
14-
} = chalk;
15-
168
export 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

packages/formatter-dump/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
},
2626
"dependencies": {
2727
"@putout/formatter-json": "^3.0.0",
28-
"chalk": "^5.3.0",
2928
"table": "^6.0.1"
3029
},
3130
"keywords": [

0 commit comments

Comments
 (0)