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 unix-style formatter.
|
---|
| 3 | * @author oshi-shinobu
|
---|
| 4 | */
|
---|
| 5 | "use strict";
|
---|
| 6 |
|
---|
| 7 | //------------------------------------------------------------------------------
|
---|
| 8 | // Helper Functions
|
---|
| 9 | //------------------------------------------------------------------------------
|
---|
| 10 |
|
---|
| 11 | /**
|
---|
| 12 | * Returns a canonical error level string based upon the error message passed in.
|
---|
| 13 | * @param {Object} message Individual error message provided by eslint
|
---|
| 14 | * @returns {string} Error level string
|
---|
| 15 | */
|
---|
| 16 | function getMessageType(message) {
|
---|
| 17 | if (message.fatal || message.severity === 2) {
|
---|
| 18 | return "Error";
|
---|
| 19 | }
|
---|
| 20 | return "Warning";
|
---|
| 21 |
|
---|
| 22 | }
|
---|
| 23 |
|
---|
| 24 |
|
---|
| 25 | //------------------------------------------------------------------------------
|
---|
| 26 | // Public Interface
|
---|
| 27 | //------------------------------------------------------------------------------
|
---|
| 28 |
|
---|
| 29 | module.exports = function(results) {
|
---|
| 30 |
|
---|
| 31 | let output = "",
|
---|
| 32 | total = 0;
|
---|
| 33 |
|
---|
| 34 | results.forEach(result => {
|
---|
| 35 |
|
---|
| 36 | const messages = result.messages;
|
---|
| 37 |
|
---|
| 38 | total += messages.length;
|
---|
| 39 |
|
---|
| 40 | messages.forEach(message => {
|
---|
| 41 |
|
---|
| 42 | output += `${result.filePath}:`;
|
---|
| 43 | output += `${message.line || 0}:`;
|
---|
| 44 | output += `${message.column || 0}:`;
|
---|
| 45 | output += ` ${message.message} `;
|
---|
| 46 | output += `[${getMessageType(message)}${message.ruleId ? `/${message.ruleId}` : ""}]`;
|
---|
| 47 | output += "\n";
|
---|
| 48 |
|
---|
| 49 | });
|
---|
| 50 |
|
---|
| 51 | });
|
---|
| 52 |
|
---|
| 53 | if (total > 0) {
|
---|
| 54 | output += `\n${total} problem${total !== 1 ? "s" : ""}`;
|
---|
| 55 | }
|
---|
| 56 |
|
---|
| 57 | return output;
|
---|
| 58 | };
|
---|
Note:
See
TracBrowser
for help on using the repository browser.