Skip to content
Permalink
Newer
Older
100644 54 lines (40 sloc) 1.01 KB
1
function merge(source, add) {
2
'use strict';
3
4
var result = source || {};
6
if (!add) {
7
return result;
8
}
9
10
Object.keys(add).forEach(function (prop) {
11
if (!result.hasOwnProperty(prop)) {
12
result[prop] = add[prop];
15
16
return result;
17
}
18
exports.merge = merge;
19
20
function preprocessScript(script) {
21
'use strict';
23
// Fix UTF8 with BOM
24
if (script.charCodeAt(0) === 0xFEFF) {
25
script = script.slice(1);
26
}
27
28
// remove shebang: replace it with empty line
Jan 8, 2016
29
script = script.replace(/^#!.*/, "");
31
return script;
32
}
33
exports.preprocessScript = preprocessScript;
35
exports.doLint = function (jslint, script, options) {
36
'use strict';
37
var ok,
38
result;
39
40
script = preprocessScript(script);
42
ok = jslint(script, options);
44
result = jslint.data();
45
if (result.ok === undefined) {
46
result.ok = ok;
47
}
48
result.options = options;
Jan 8, 2016
49
50
// es6
51
result.errors = result.errors || result.warnings;
52
53
return result;
54
};