main
Last change
on this file was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago |
Update repo after prototype presentation
|
-
Property mode
set to
100644
|
File size:
1.4 KB
|
Rev | Line | |
---|
[d565449] | 1 | /**
|
---|
| 2 | * @fileoverview Compact reporter
|
---|
| 3 | * @author Nicholas C. Zakas
|
---|
| 4 | */
|
---|
| 5 | "use strict";
|
---|
| 6 |
|
---|
| 7 | //------------------------------------------------------------------------------
|
---|
| 8 | // Helper Functions
|
---|
| 9 | //------------------------------------------------------------------------------
|
---|
| 10 |
|
---|
| 11 | /**
|
---|
| 12 | * Returns the severity of warning or error
|
---|
| 13 | * @param {Object} message message object to examine
|
---|
| 14 | * @returns {string} severity level
|
---|
| 15 | * @private
|
---|
| 16 | */
|
---|
| 17 | function getMessageType(message) {
|
---|
| 18 | if (message.fatal || message.severity === 2) {
|
---|
| 19 | return "Error";
|
---|
| 20 | }
|
---|
| 21 | return "Warning";
|
---|
| 22 |
|
---|
| 23 | }
|
---|
| 24 |
|
---|
| 25 |
|
---|
| 26 | //------------------------------------------------------------------------------
|
---|
| 27 | // Public Interface
|
---|
| 28 | //------------------------------------------------------------------------------
|
---|
| 29 |
|
---|
| 30 | module.exports = function(results) {
|
---|
| 31 |
|
---|
| 32 | let output = "",
|
---|
| 33 | total = 0;
|
---|
| 34 |
|
---|
| 35 | results.forEach(result => {
|
---|
| 36 |
|
---|
| 37 | const messages = result.messages;
|
---|
| 38 |
|
---|
| 39 | total += messages.length;
|
---|
| 40 |
|
---|
| 41 | messages.forEach(message => {
|
---|
| 42 |
|
---|
| 43 | output += `${result.filePath}: `;
|
---|
| 44 | output += `line ${message.line || 0}`;
|
---|
| 45 | output += `, col ${message.column || 0}`;
|
---|
| 46 | output += `, ${getMessageType(message)}`;
|
---|
| 47 | output += ` - ${message.message}`;
|
---|
| 48 | output += message.ruleId ? ` (${message.ruleId})` : "";
|
---|
| 49 | output += "\n";
|
---|
| 50 |
|
---|
| 51 | });
|
---|
| 52 |
|
---|
| 53 | });
|
---|
| 54 |
|
---|
| 55 | if (total > 0) {
|
---|
| 56 | output += `\n${total} problem${total !== 1 ? "s" : ""}`;
|
---|
| 57 | }
|
---|
| 58 |
|
---|
| 59 | return output;
|
---|
| 60 | };
|
---|
Note:
See
TracBrowser
for help on using the repository browser.