This repository has been archived by the owner on Mar 31, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c84938e
commit 557b38d
Showing
7 changed files
with
168 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/*jslint node, es6, maxlen: 80 */ | ||
|
||
"use strict"; | ||
|
||
const R = require("ramda"); | ||
|
||
const prettyPrintWarnings = require("./pretty-print-warnings"); | ||
const prettyPrintSummary = require("./pretty-print-summary"); | ||
|
||
module.exports = function prettyPrintReport(report) { | ||
return R.pipe( | ||
R.reject(R.isEmpty), | ||
R.join("\n") | ||
)([ | ||
prettyPrintWarnings(report), | ||
prettyPrintSummary(report) | ||
]); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/*jslint node, es6, maxlen: 80 */ | ||
|
||
"use strict"; | ||
|
||
const wordwrap = require("wordwrap"); | ||
|
||
const maxLineLength = 80; | ||
|
||
const wrapTo80 = wordwrap(maxLineLength); | ||
|
||
module.exports = function prettyPrintSummary({numbers, usedLinters}) { | ||
return usedLinters.length > 0 | ||
? wrapTo80(`Used linters: ${usedLinters.join(", ")} | ||
Total files checked: ${numbers.totalFiles} | ||
Files with warnings: ${numbers.filesWithWarnings} | ||
Total warnings: ${numbers.totalWarnings} | ||
`) | ||
: "Nothing to check\n"; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
/*jslint node, es6, maxlen: 80 */ | ||
/*eslint "func-names": "off" */ | ||
|
||
"use strict"; | ||
|
||
const {test} = require("tap"); | ||
|
||
const prettyPrintSummary = require("../src/pretty-print-summary"); | ||
|
||
test("prettyPrintSummary()", function (t) { | ||
const result = prettyPrintSummary({ | ||
numbers: { | ||
totalFiles: 15, | ||
filesWithWarnings: 4, | ||
totalWarnings: 8 | ||
}, | ||
usedLinters: ["linterA", "linterB"] | ||
}); | ||
|
||
t.strictSame( | ||
result, | ||
`Used linters: linterA, linterB | ||
Total files checked: 15 | ||
Files with warnings: 4 | ||
Total warnings: 8 | ||
`, | ||
"should pretty print summary" | ||
); | ||
|
||
t.end(); | ||
}); | ||
|
||
test("prettyPrintSummary()", function (t) { | ||
const resultWithoutFiles = prettyPrintSummary({usedLinters: []}); | ||
|
||
t.strictSame( | ||
resultWithoutFiles, | ||
"Nothing to check\n", | ||
"should pretty print if there were no used linters" | ||
); | ||
|
||
t.end(); | ||
}); | ||
|
||
test("prettyPrintSummary()", function (t) { | ||
const result = prettyPrintSummary({ | ||
numbers: { | ||
totalFiles: 15, | ||
filesWithWarnings: 4, | ||
totalWarnings: 8 | ||
}, | ||
usedLinters: [ | ||
"linterNameA", | ||
"linterNameB", | ||
"linterNameC", | ||
"longLinterNameD", | ||
"linterNameE", | ||
"linterNameF", | ||
"linterNameG", | ||
"linterNameH", | ||
"linterNameI", | ||
"linterNameJ" | ||
] | ||
}); | ||
|
||
t.strictSame( | ||
result, | ||
`Used linters: linterNameA, linterNameB, linterNameC, longLinterNameD, | ||
linterNameE, linterNameF, linterNameG, linterNameH, linterNameI, linterNameJ | ||
Total files checked: 15 | ||
Files with warnings: 4 | ||
Total warnings: 8 | ||
`, | ||
"should wrap lines to 80 characters" | ||
); | ||
|
||
t.end(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"jslint": { | ||
"files": [ | ||
"nonexistent" | ||
] | ||
} | ||
} |