Skip to content

Commit 27d2c6a

Browse files
committed
Clean up whitespace in reporter code
1 parent 19c4f35 commit 27d2c6a

File tree

1 file changed

+19
-89
lines changed

1 file changed

+19
-89
lines changed

lib/reporters/default.js

+19-89
Original file line numberDiff line numberDiff line change
@@ -112,10 +112,7 @@ class Reporter {
112112
this.stdStream = stdStream;
113113
this.watching = watching;
114114
this.relativeFile = file => path.relative(projectDir, file);
115-
this.consumeStateChange = whileCorked(
116-
this.reportStream,
117-
this.consumeStateChange
118-
);
115+
this.consumeStateChange = whileCorked(this.reportStream, this.consumeStateChange);
119116

120117
if (this.verbose) {
121118
this.durationThreshold = durationThreshold || 100;
@@ -132,10 +129,7 @@ class Reporter {
132129
stream: reportStream
133130
});
134131
this.lineWriter = new LineWriterWithSpinner(this.reportStream, this.spinner);
135-
this.endRun = whileCorked(
136-
this.reportStream,
137-
whileCorked(this.lineWriter, this.endRun)
138-
);
132+
this.endRun = whileCorked(this.reportStream, whileCorked(this.lineWriter, this.endRun));
139133
}
140134

141135
this.reset();
@@ -334,8 +328,7 @@ class Reporter {
334328

335329
if (this.verbose && !this.filesWithMissingAvaImports.has(event.testFile)) {
336330
if (event.nonZeroExitCode) {
337-
this.lineWriter.writeLine(colors.error(`${figures.cross} ${this.relativeFile(event.testFile)} exited with a non-zero exit code: ${event.nonZeroExitCode}`)
338-
);
331+
this.lineWriter.writeLine(colors.error(`${figures.cross} ${this.relativeFile(event.testFile)} exited with a non-zero exit code: ${event.nonZeroExitCode}`));
339332
} else {
340333
this.lineWriter.writeLine(colors.error(`${figures.cross} ${this.relativeFile(event.testFile)} exited due to ${event.signal}`));
341334
}
@@ -443,55 +436,24 @@ class Reporter {
443436
string += os.EOL;
444437
}
445438

446-
let firstLinePostfix = this.watching ?
447-
' ' +
448-
chalk.gray.dim(
449-
'[' + new Date().toLocaleTimeString('en-US', {hour12: false}) + ']'
450-
) :
451-
'';
439+
let firstLinePostfix = this.watching ? ' ' + chalk.gray.dim('[' + new Date().toLocaleTimeString('en-US', {hour12: false}) + ']') : '';
452440

453441
if (this.stats.passedTests > 0) {
454-
string +=
455-
os.EOL +
456-
colors.pass(`${this.stats.passedTests} passed`) +
457-
firstLinePostfix;
442+
string += os.EOL + colors.pass(`${this.stats.passedTests} passed`) + firstLinePostfix;
458443
firstLinePostfix = '';
459444
}
460445

461446
if (this.stats.passedKnownFailingTests > 0) {
462-
string +=
463-
os.EOL +
464-
colors.error(
465-
`${this.stats.passedKnownFailingTests} ${plur(
466-
'known failure',
467-
this.stats.passedKnownFailingTests
468-
)}`
469-
);
447+
string += os.EOL + colors.error(`${this.stats.passedKnownFailingTests} ${plur('known failure', this.stats.passedKnownFailingTests)}`);
470448
}
471449

472450
if (this.stats.failedHooks > 0) {
473-
string +=
474-
os.EOL +
475-
colors.error(
476-
`${this.stats.failedHooks} ${plur(
477-
'hook',
478-
this.stats.failedHooks
479-
)} failed`
480-
) +
481-
firstLinePostfix;
451+
string += os.EOL + colors.error(`${this.stats.failedHooks} ${plur('hook', this.stats.failedHooks)} failed`) + firstLinePostfix;
482452
firstLinePostfix = '';
483453
}
484454

485455
if (this.stats.failedTests > 0) {
486-
string +=
487-
os.EOL +
488-
colors.error(
489-
`${this.stats.failedTests} ${plur(
490-
'test',
491-
this.stats.failedTests
492-
)} failed`
493-
) +
494-
firstLinePostfix;
456+
string += os.EOL + colors.error(`${this.stats.failedTests} ${plur('test', this.stats.failedTests)} failed`) + firstLinePostfix;
495457
firstLinePostfix = '';
496458
}
497459

@@ -507,21 +469,15 @@ class Reporter {
507469
}
508470

509471
writeErr(event) {
510-
if (
511-
event.err.name === 'TSError' &&
512-
event.err.object &&
513-
event.err.object.diagnosticText
514-
) {
472+
if (event.err.name === 'TSError' && event.err.object && event.err.object.diagnosticText) {
515473
this.lineWriter.writeLine(colors.errorStack(trimOffNewlines(event.err.object.diagnosticText)));
516474
this.lineWriter.writeLine();
517475
return;
518476
}
519477

520478
if (event.err.source) {
521479
this.lineWriter.writeLine(colors.errorSource(`${this.relativeFile(event.err.source.file)}:${event.err.source.line}`));
522-
const excerpt = codeExcerpt(event.err.source, {
523-
maxWidth: this.reportStream.columns - 2
524-
});
480+
const excerpt = codeExcerpt(event.err.source, {maxWidth: this.reportStream.columns - 2});
525481
if (excerpt) {
526482
this.lineWriter.writeLine();
527483
this.lineWriter.writeLine(excerpt);
@@ -636,9 +592,7 @@ class Reporter {
636592
}
637593

638594
endRun() {// eslint-disable-line complexity
639-
let firstLinePostfix = this.watching ?
640-
` ${chalk.gray.dim(`[${new Date().toLocaleTimeString('en-US', {hour12: false})}]`)}` :
641-
'';
595+
let firstLinePostfix = this.watching ? ` ${chalk.gray.dim(`[${new Date().toLocaleTimeString('en-US', {hour12: false})}]`)}` : '';
642596
let wroteSomething = false;
643597

644598
if (!this.verbose) {
@@ -694,10 +648,7 @@ class Reporter {
694648

695649
if (this.filesWithoutMatchedLineNumbers.size > 0) {
696650
for (const testFile of this.filesWithoutMatchedLineNumbers) {
697-
if (
698-
!this.filesWithMissingAvaImports.has(testFile) &&
699-
!this.filesWithoutDeclaredTests.has(testFile)
700-
) {
651+
if (!this.filesWithMissingAvaImports.has(testFile) && !this.filesWithoutDeclaredTests.has(testFile)) {
701652
this.lineWriter.writeLine(colors.error(`${figures.cross} Line numbers for ${this.relativeFile(testFile)} did not match any tests`) + firstLinePostfix);
702653
firstLinePostfix = '';
703654
wroteSomething = true;
@@ -714,10 +665,7 @@ class Reporter {
714665
}
715666

716667
if (this.failures.length > 0) {
717-
const writeTrailingLines =
718-
this.internalErrors.length > 0 ||
719-
this.uncaughtExceptions.length > 0 ||
720-
this.unhandledRejections.length > 0;
668+
const writeTrailingLines = this.internalErrors.length > 0 || this.uncaughtExceptions.length > 0 || this.unhandledRejections.length > 0;
721669

722670
const lastFailure = this.failures[this.failures.length - 1];
723671
for (const event of this.failures) {
@@ -741,9 +689,7 @@ class Reporter {
741689

742690
if (!this.verbose) {
743691
if (this.internalErrors.length > 0) {
744-
const writeTrailingLines =
745-
this.uncaughtExceptions.length > 0 ||
746-
this.unhandledRejections.length > 0;
692+
const writeTrailingLines = this.uncaughtExceptions.length > 0 || this.unhandledRejections.length > 0;
747693

748694
const last = this.internalErrors[this.internalErrors.length - 1];
749695
for (const event of this.internalErrors) {
@@ -768,9 +714,7 @@ class Reporter {
768714
if (this.uncaughtExceptions.length > 0) {
769715
const writeTrailingLines = this.unhandledRejections.length > 0;
770716

771-
const last = this.uncaughtExceptions[
772-
this.uncaughtExceptions.length - 1
773-
];
717+
const last = this.uncaughtExceptions[this.uncaughtExceptions.length - 1];
774718
for (const event of this.uncaughtExceptions) {
775719
this.lineWriter.writeLine(colors.title(`Uncaught exception in ${this.relativeFile(event.testFile)}`));
776720
this.lineWriter.writeLine();
@@ -785,9 +729,7 @@ class Reporter {
785729
}
786730

787731
if (this.unhandledRejections.length > 0) {
788-
const last = this.unhandledRejections[
789-
this.unhandledRejections.length - 1
790-
];
732+
const last = this.unhandledRejections[this.unhandledRejections.length - 1];
791733
for (const event of this.unhandledRejections) {
792734
this.lineWriter.writeLine(colors.title(`Unhandled rejection in ${this.relativeFile(event.testFile)}`));
793735
this.lineWriter.writeLine();
@@ -807,30 +749,18 @@ class Reporter {
807749
}
808750
}
809751

810-
if (
811-
this.failFastEnabled &&
812-
(this.stats.remainingTests > 0 ||
813-
this.stats.files > this.stats.finishedWorkers)
814-
) {
752+
if (this.failFastEnabled && (this.stats.remainingTests > 0 || this.stats.files > this.stats.finishedWorkers)) {
815753
let remaining = '';
816754
if (this.stats.remainingTests > 0) {
817-
remaining += `At least ${this.stats.remainingTests} ${plur(
818-
'test was',
819-
'tests were',
820-
this.stats.remainingTests
821-
)} skipped`;
755+
remaining += `At least ${this.stats.remainingTests} ${plur('test was', 'tests were', this.stats.remainingTests)} skipped`;
822756
if (this.stats.files > this.stats.finishedWorkers) {
823757
remaining += ', as well as ';
824758
}
825759
}
826760

827761
if (this.stats.files > this.stats.finishedWorkers) {
828762
const skippedFileCount = this.stats.files - this.stats.finishedWorkers;
829-
remaining += `${skippedFileCount} ${plur(
830-
'test file',
831-
'test files',
832-
skippedFileCount
833-
)}`;
763+
remaining += `${skippedFileCount} ${plur('test file', 'test files', skippedFileCount)}`;
834764
if (this.stats.remainingTests === 0) {
835765
remaining += ` ${plur('was', 'were', skippedFileCount)} skipped`;
836766
}

0 commit comments

Comments
 (0)