source: imaps-frontend/node_modules/eslint/lib/cli-engine/formatters/visualstudio.js@ d565449

main
Last change on this file since d565449 was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago

Update repo after prototype presentation

  • 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 */
18function 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
31module.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.