Files
node/tools/eslint/lib/formatters/visualstudio.js
T
Rich Trott 05b566a5ef tools: update ESLint to 3.3.0 and enable rules
Update ESLint 3.3.0 and update .eslintrc:

* replace deprecated no-negated-in-lhs rule with no-unsafe-negation
  * http://eslint.org/docs/rules/no-negated-in-lhs
  * http://eslint.org/docs/rules/no-unsafe-negation
* enable no-template-curly-in-string
  * http://eslint.org/docs/rules/no-template-curly-in-string
* enable no-global-assign
  * http://eslint.org/docs/rules/no-global-assign
* enable func-call-spacing
  * http://eslint.org/docs/rules/func-call-spacing

PR-URL: https://github.com/nodejs/node/pull/8097
Reviewed-By: targos - Michaël Zasso <mic.besace@gmail.com>
Reviewed-By: jasnell - James M Snell <jasnell@gmail.com>
Reviewed-By: Roman Reiss <me@silverwind.io>
2016-08-16 15:16:10 -07:00

64 lines
1.5 KiB
JavaScript

/**
* @fileoverview Visual Studio compatible formatter
* @author Ronald Pijnacker
*/
"use strict";
//------------------------------------------------------------------------------
// Helper Functions
//------------------------------------------------------------------------------
/**
* Returns the severity of warning or error
* @param {Object} message message object to examine
* @returns {string} severity level
* @private
*/
function getMessageType(message) {
if (message.fatal || message.severity === 2) {
return "error";
} else {
return "warning";
}
}
//------------------------------------------------------------------------------
// Public Interface
//------------------------------------------------------------------------------
module.exports = function(results) {
let output = "",
total = 0;
results.forEach(function(result) {
const messages = result.messages;
total += messages.length;
messages.forEach(function(message) {
output += result.filePath;
output += "(" + (message.line || 0);
output += message.column ? "," + message.column : "";
output += "): " + getMessageType(message);
output += message.ruleId ? " " + message.ruleId : "";
output += " : " + message.message;
output += "\n";
});
});
if (total === 0) {
output += "no problems";
} else {
output += "\n" + total + " problem" + (total !== 1 ? "s" : "");
}
return output;
};