Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
JSLint/JSHint emacs reporter
/*jshint node: true */
var reporter_name = "jhlint";
module.exports = {
reporter: function (results, data) {
"use strict";
var str = '',
errors = [];
data.forEach(function (data) {
var file = data.file;
if (data.errors) {
data.errors.forEach(function (error) {
// completing error
error.file = file;
errors.push(error);
});
}
if (data.implieds) {
data.implieds.forEach(function (error) {
// completing global
error.id = '(warning)';
error.reason = 'Implied global \'' + error.name + '\'';
error.file = file;
errors.push(error);
});
}
if (data.unused) {
data.unused.forEach(function (error) {
error.id = '(warning)';
error.reason = 'Unused variable \'' + error.name + '\'';
error.file = file;
errors.push(error);
});
}
});
errors.forEach(function (error) {
var file = error.file,
error_id;
if (error.id === '(error)') {
error_id = 'ERROR';
} else {
error_id = 'WARNING';
}
str += file + ':' + error.line + ': ' + error_id +
': (' + reporter_name + ') ' + error.reason + '\n';
});
if (str) {
process.stdout.write(str + "\n");
}
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.