Created
September 20, 2012 07:15
-
-
Save vaab/3754379 to your computer and use it in GitHub Desktop.
JSLint/JSHint emacs reporter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*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