|
Last change
on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 12 days ago |
|
Fix frontend appearance
|
-
Property mode
set to
100644
|
|
File size:
1.5 KB
|
| Line | |
|---|
| 1 | /**
|
|---|
| 2 | * @fileoverview Visual Studio compatible formatter
|
|---|
| 3 | * @author Ronald Pijnacker
|
|---|
| 4 | */
|
|---|
| 5 |
|
|---|
| 6 | "use strict";
|
|---|
| 7 |
|
|---|
| 8 | //------------------------------------------------------------------------------
|
|---|
| 9 | // Helper Functions
|
|---|
| 10 | //------------------------------------------------------------------------------
|
|---|
| 11 |
|
|---|
| 12 | /**
|
|---|
| 13 | * Returns the severity of warning or error
|
|---|
| 14 | * @param {Object} message message object to examine
|
|---|
| 15 | * @returns {string} severity level
|
|---|
| 16 | * @private
|
|---|
| 17 | */
|
|---|
| 18 | function getMessageType(message) {
|
|---|
| 19 | if (message.fatal || message.severity === 2) {
|
|---|
| 20 | return "error";
|
|---|
| 21 | }
|
|---|
| 22 | return "warning";
|
|---|
| 23 |
|
|---|
| 24 | }
|
|---|
| 25 |
|
|---|
| 26 |
|
|---|
| 27 | //------------------------------------------------------------------------------
|
|---|
| 28 | // Public Interface
|
|---|
| 29 | //------------------------------------------------------------------------------
|
|---|
| 30 |
|
|---|
| 31 | module.exports = function(results) {
|
|---|
| 32 |
|
|---|
| 33 | let output = "",
|
|---|
| 34 | total = 0;
|
|---|
| 35 |
|
|---|
| 36 | results.forEach(result => {
|
|---|
| 37 |
|
|---|
| 38 | const messages = result.messages;
|
|---|
| 39 |
|
|---|
| 40 | total += messages.length;
|
|---|
| 41 |
|
|---|
| 42 | messages.forEach(message => {
|
|---|
| 43 |
|
|---|
| 44 | output += result.filePath;
|
|---|
| 45 | output += `(${message.line || 0}`;
|
|---|
| 46 | output += message.column ? `,${message.column}` : "";
|
|---|
| 47 | output += `): ${getMessageType(message)}`;
|
|---|
| 48 | output += message.ruleId ? ` ${message.ruleId}` : "";
|
|---|
| 49 | output += ` : ${message.message}`;
|
|---|
| 50 | output += "\n";
|
|---|
| 51 |
|
|---|
| 52 | });
|
|---|
| 53 |
|
|---|
| 54 | });
|
|---|
| 55 |
|
|---|
| 56 | if (total === 0) {
|
|---|
| 57 | output += "no problems";
|
|---|
| 58 | } else {
|
|---|
| 59 | output += `\n${total} problem${total !== 1 ? "s" : ""}`;
|
|---|
| 60 | }
|
|---|
| 61 |
|
|---|
| 62 | return output;
|
|---|
| 63 | };
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.