-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathjshint-error.js
54 lines (43 loc) · 911 Bytes
/
jshint-error.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
'use strict';
const LintError = require('./lint-error');
const JSHINT_SEVERITY_MAP = {
E: 'error',
W: 'warn',
I: 'info',
};
/**
* JSHint错误对象
*
* @class JSHintError
* @extends {LintError}
*/
class JSHintError extends LintError {
/**
* Creates an instance of JSHintError.
*
* @param {any} error JSHint的原始error对象
*
* @memberOf JSHintError
*/
constructor (error) {
super({
// 文件名
fileName: error.file,
// JSHint错误等级
severity: error.code && /^[EWI]/.test(error.code) ? JSHINT_SEVERITY_MAP[error.code[0]] : JSHINT_SEVERITY_MAP.E,
// 行号
lineNumber: error.line,
// 列号
columnNumber: error.character,
// 错误信息
message: error.reason,
// 错误ID
rule: error.code,
// 源代码上下文
source: error.evidence,
// 报错插件
plugin: 'JSHint',
}, error);
}
}
module.exports = JSHintError;