Skip to content

Commit d6afef6

Browse files
authored
Improve console color constrast (#609)
1 parent 59dd6cb commit d6afef6

File tree

3 files changed

+12
-18
lines changed

3 files changed

+12
-18
lines changed

Diff for: src/console-reporter.ts

+4-10
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,9 @@ const oneFile = 1;
1212
* @internal
1313
*/
1414
const printResultSetIssues = (issues: LintIssue[]): void => {
15-
// eslint-disable-next-line no-restricted-syntax
16-
for (const issue of issues) {
17-
// eslint-disable-next-line no-console
15+
issues.forEach((issue) => {
1816
console.log(issue.toString());
19-
}
17+
});
2018
};
2119

2220
/**
@@ -26,7 +24,6 @@ const printResultSetIssues = (issues: LintIssue[]): void => {
2624
* @param quiet True suppress warnings, false show warnings
2725
* @internal
2826
*/
29-
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
3027
const printIndividualResultSet = (resultSet, quiet: boolean): void => {
3128
const {filePath, issues, ignored, errorCount, warningCount} = resultSet;
3229

@@ -59,7 +56,6 @@ const printIndividualResultSet = (resultSet, quiet: boolean): void => {
5956
* @param quiet True suppress warnings, false show warnings
6057
* @internal
6158
*/
62-
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
6359
const printTotals = (linterOutput, quiet: boolean): void => {
6460
const {errorCount, warningCount, ignoreCount} = linterOutput;
6561

@@ -86,12 +82,10 @@ const printTotals = (linterOutput, quiet: boolean): void => {
8682
* @param quiet Flag indicating whether to print warnings.
8783
* @internal
8884
*/
89-
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
9085
export const write = (linterOutput, quiet: boolean): void => {
91-
// eslint-disable-next-line no-restricted-syntax
92-
for (const result of linterOutput.results) {
86+
linterOutput.results.forEach((result) => {
9387
printIndividualResultSet(result, quiet);
94-
}
88+
});
9589

9690
if (linterOutput.results.length > oneFile) {
9791
printTotals(linterOutput, quiet);

Diff for: src/lint-issue.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,10 @@ export class LintIssue {
6060
*/
6161
toString(): string {
6262
const logSymbol = this.severity === Severity.Error ? logSymbols.error : logSymbols.warning;
63-
const formattedLintId = chalk.gray.dim(this.lintId);
64-
const formattedNode = chalk.gray.bold(this.node);
63+
const formattedLintId = chalk.cyan.bold(this.lintId);
64+
const formattedNode = chalk.magenta.bold(this.node);
6565
const formattedMessage =
66-
this.severity === Severity.Error ? chalk.bold.red(this.lintMessage) : chalk.yellow(this.lintMessage);
66+
this.severity === Severity.Error ? chalk.red.bold(this.lintMessage) : chalk.yellow(this.lintMessage);
6767

6868
return `${logSymbol} ${formattedLintId} - node: ${formattedNode} - ${formattedMessage}`;
6969
}

Diff for: test/unit/lint-issue.test.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -29,18 +29,18 @@ describe('LintIssue Unit Tests', () => {
2929
describe('toString method', () => {
3030
describe('when the severity is an error', () => {
3131
test('the formattedMessage should equal', () => {
32-
const formattedLintId = chalk.gray.dim('lintId');
33-
const formattedNode = chalk.gray.bold('node');
34-
const formattedMessage = chalk.bold.red('lintMessage');
32+
const formattedLintId = chalk.cyan.bold('lintId');
33+
const formattedNode = chalk.magenta.bold('node');
34+
const formattedMessage = chalk.red.bold('lintMessage');
3535
const output = `${logSymbols.error} ${formattedLintId} - node: ${formattedNode} - ${formattedMessage}`;
3636
const lintIssue = new LintIssue('lintId', Severity.Error, 'node', 'lintMessage');
3737

3838
expect(lintIssue.toString()).toStrictEqual(output);
3939
});
4040

4141
test('when an array with one error is passed a formatted message should be returned saying there is one error', () => {
42-
const formattedLintId = chalk.gray.dim('lintId');
43-
const formattedNode = chalk.gray.bold('node');
42+
const formattedLintId = chalk.cyan.bold('lintId');
43+
const formattedNode = chalk.magenta.bold('node');
4444
const formattedMessage = chalk.yellow('lintMessage');
4545
const output = `${logSymbols.warning} ${formattedLintId} - node: ${formattedNode} - ${formattedMessage}`;
4646
const lintIssue = new LintIssue('lintId', Severity.Warning, 'node', 'lintMessage');

0 commit comments

Comments
 (0)