-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
28 lines (26 loc) · 832 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
module.exports = function tapeStandard (options) {
if (!options) options = {}
var standard = options.using || require('standard')
var files = options.files || []
var sOptions = options.options || {}
return function (t) {
standard.lintFiles(files, sOptions, function (err, res) {
if (err) return t.fail(err)
if (res.errorCount === 0 && res.warningCount === 0) t.pass('passed standard')
errorify(t, res)
t.end()
})
}
}
function errorify (t, res) {
res.results.forEach(function (result) {
if (result.errorCount || result.warningCount) {
result.messages.forEach(function (msg) {
t.fail('' +
result.filePath.replace(process.cwd(), '') +
':' + msg.line + ':' + msg.column + ': ' +
msg.message + ' (' + msg.ruleId + ')')
})
}
})
}