-
Notifications
You must be signed in to change notification settings - Fork 7
/
alex.js
37 lines (31 loc) 路 893 Bytes
/
alex.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
29
30
31
32
33
34
35
36
37
const alex = require('alex')
class Alex {
/**
* @constructor
* @param {Map<string, string>} contentMap
*/
constructor (contentMap) {
this.contentMap = contentMap
}
/**
* Serialize the provider lib's response into a { line, reason } object
* @param {object[]} reasons
*/
serializeReasons (reasons) {
return reasons.map(reason => ({ line: reason.line, reason: reason.message, annotation_level: reason.fatal ? 'failing' : 'warning' }))
}
/**
* Returns the results of all the write-good checks
* @param {Map<string, string>} fileMap
* @returns {Map<string, object[]>}
*/
buildResults () {
const results = new Map()
for (const [filename, contents] of this.contentMap) {
const res = alex.markdown(contents).messages
results.set(filename, this.serializeReasons(res))
}
return results
}
}
module.exports = Alex