Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified .yarn/install-state.gz
Binary file not shown.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,14 @@
},
"dependencies": {
"@babel/code-frame": "^7.16.7",
"chalk": "^4.1.2",
"chokidar": "^4.0.1",
"cosmiconfig": "^8.2.0",
"deepmerge": "^4.2.2",
"fs-extra": "^10.0.0",
"memfs": "^3.4.1",
"minimatch": "^3.0.4",
"node-abort-controller": "^3.0.1",
"picocolors": "^1.1.1",
"schema-utils": "^3.1.1",
"semver": "^7.3.5",
"tapable": "^2.2.1"
Expand Down
4 changes: 2 additions & 2 deletions src/formatter/basic-formatter.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import chalk from 'chalk';
import pc from 'picocolors';

import type { Formatter } from './formatter';

function createBasicFormatter(): Formatter {
return function basicFormatter(issue) {
return chalk.grey(issue.code + ': ') + issue.message;
return pc.gray(issue.code + ': ') + issue.message;
};
}

Expand Down
6 changes: 3 additions & 3 deletions src/formatter/stats-formatter.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import chalk from 'chalk';
import pc from 'picocolors';
import type { Stats } from 'webpack';

import type { Issue } from '../issue';
Expand All @@ -8,10 +8,10 @@ export function statsFormatter(issues: Issue[], stats: Stats): string {
const errorsNumber = issues.filter((issue) => issue.severity === 'error').length;
const warningsNumber = issues.filter((issue) => issue.severity === 'warning').length;
const errorsFormatted = errorsNumber
? chalk.red.bold(`${errorsNumber} ${errorsNumber === 1 ? 'error' : 'errors'}`)
? pc.bold(pc.red(`${errorsNumber} ${errorsNumber === 1 ? 'error' : 'errors'}`))
: '';
const warningsFormatted = warningsNumber
? chalk.yellow.bold(`${warningsNumber} ${warningsNumber === 1 ? 'warning' : 'warnings'}`)
? pc.bold(pc.yellow(`${warningsNumber} ${warningsNumber === 1 ? 'warning' : 'warnings'}`))
: '';
const timeFormatted = Math.round(Date.now() - stats.startTime);

Expand Down
9 changes: 5 additions & 4 deletions src/formatter/webpack-formatter.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import os from 'os';
import path from 'path';

import chalk from 'chalk';
import pc from 'picocolors';

import { formatIssueLocation } from '../issue';
import { forwardSlash } from '../utils/path/forward-slash';
Expand All @@ -12,18 +12,19 @@ import type { Formatter, FormatterPathType } from './formatter';
function createWebpackFormatter(formatter: Formatter, pathType: FormatterPathType): Formatter {
// mimics webpack error formatter
return function webpackFormatter(issue) {
const color = issue.severity === 'warning' ? chalk.yellow.bold : chalk.red.bold;
const color = (text: string) =>
issue.severity === 'warning' ? pc.bold(pc.yellow(text)) : pc.bold(pc.red(text));

const severity = issue.severity.toUpperCase();

if (issue.file) {
let location = chalk.bold(
let location = pc.bold(
pathType === 'absolute'
? forwardSlash(path.resolve(issue.file))
: relativeToContext(issue.file, process.cwd())
);
if (issue.location) {
location += `:${chalk.green.bold(formatIssueLocation(issue.location))}`;
location += `:${pc.bold(pc.green(formatIssueLocation(issue.location)))}`;
}

return [`${color(severity)} in ${location}`, formatter(issue), ''].join(os.EOL);
Expand Down
6 changes: 3 additions & 3 deletions src/hooks/tap-done-to-async-get-issues.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import chalk from 'chalk';
import pc from 'picocolors';
import type * as webpack from 'webpack';

import { statsFormatter } from '../formatter/stats-formatter';
Expand Down Expand Up @@ -32,7 +32,7 @@ function tapDoneToAsyncGetIssues(
try {
if (await isPending(issuesPromise)) {
hooks.waiting.call(stats.compilation);
config.logger.log(chalk.cyan('Type-checking in progress...'));
config.logger.log(pc.cyan('Type-checking in progress...'));
} else {
// wait 10ms to log issues after webpack stats
await wait(10);
Expand Down Expand Up @@ -68,7 +68,7 @@ function tapDoneToAsyncGetIssues(
// print stats of the compilation
config.logger.log(statsFormatter(issues, stats));
} else {
config.logger.log(chalk.green('No typescript errors found.'));
config.logger.log(pc.green('No typescript errors found.'));
}

// report issues to webpack-dev-server, if it's listening
Expand Down
6 changes: 3 additions & 3 deletions src/hooks/tap-error-to-log-message.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import chalk from 'chalk';
import pc from 'picocolors';
import type * as webpack from 'webpack';

import type { ForkTsCheckerWebpackPluginConfig } from '../plugin-config';
Expand All @@ -22,15 +22,15 @@ function tapErrorToLogMessage(
if (error instanceof RpcExitError) {
if (error.signal === 'SIGINT') {
config.logger.error(
chalk.red(
pc.red(
'Issues checking service interrupted - If running in a docker container, this may be caused ' +
"by the container running out of memory. If so, try increasing the container's memory limit " +
'or lowering the `memoryLimit` value in the ForkTsCheckerWebpackPlugin configuration.'
)
);
} else {
config.logger.error(
chalk.red(
pc.red(
'Issues checking service aborted - probably out of memory. ' +
'Check the `memoryLimit` option in the ForkTsCheckerWebpackPlugin configuration.\n' +
"If increasing the memory doesn't solve the issue, it's most probably a bug in the TypeScript."
Expand Down
98 changes: 0 additions & 98 deletions test/unit/formatter/__mocks__/chalk.js

This file was deleted.

38 changes: 38 additions & 0 deletions test/unit/formatter/__mocks__/picocolors.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// picocolors mock - bypass all styling for deterministic test output
function identity(str) {
return String(str);
}

const colors = {
isColorSupported: false,
reset: identity,
bold: identity,
dim: identity,
italic: identity,
underline: identity,
inverse: identity,
hidden: identity,
strikethrough: identity,
black: identity,
red: identity,
green: identity,
yellow: identity,
blue: identity,
magenta: identity,
cyan: identity,
white: identity,
gray: identity,
bgBlack: identity,
bgRed: identity,
bgGreen: identity,
bgYellow: identity,
bgBlue: identity,
bgMagenta: identity,
bgCyan: identity,
bgWhite: identity,
createColors: () => colors,
};

colors.default = colors;

module.exports = colors;
4 changes: 2 additions & 2 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2902,7 +2902,7 @@ __metadata:
languageName: node
linkType: hard

"chalk@npm:^4.0.0, chalk@npm:^4.1.0, chalk@npm:^4.1.2":
"chalk@npm:^4.0.0, chalk@npm:^4.1.0":
version: 4.1.2
resolution: "chalk@npm:4.1.2"
dependencies:
Expand Down Expand Up @@ -4506,7 +4506,6 @@ __metadata:
"@types/semver": "npm:^7.3.9"
"@typescript-eslint/eslint-plugin": "npm:^5.10.1"
"@typescript-eslint/parser": "npm:^5.10.1"
chalk: "npm:^4.1.2"
chokidar: "npm:^4.0.1"
commitlint: "npm:^16.1.0"
cosmiconfig: "npm:^8.2.0"
Expand All @@ -4529,6 +4528,7 @@ __metadata:
minimatch: "npm:^3.0.4"
mock-fs: "npm:^5.1.2"
node-abort-controller: "npm:^3.0.1"
picocolors: "npm:^1.1.1"
prettier: "npm:^2.5.1"
rimraf: "npm:^3.0.2"
schema-utils: "npm:^3.1.1"
Expand Down