-
Notifications
You must be signed in to change notification settings - Fork 3
/
index.js
44 lines (37 loc) · 1.3 KB
/
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
// Generated by CoffeeScript 1.9.3
(function() {
var _, coffeelint, through;
_ = require('lodash');
through = require('through2');
coffeelint = require('coffeelint');
coffeelint.reporter = require('coffeelint-stylish').reporter;
coffeelint.configfinder = require('coffeelint/lib/configfinder');
module.exports = function(file, overrideOptions) {
var errorReport, fileOptions, options;
if (overrideOptions == null) {
overrideOptions = {};
}
errorReport = coffeelint.getErrorReport();
fileOptions = coffeelint.configfinder.getConfig() || {};
options = _.defaults(overrideOptions, fileOptions);
return through(function(buf, enc, next) {
var errors;
if (file.substr(-7) === '.coffee') {
errors = errorReport.lint(file, buf.toString(), options);
if (errors.length !== 0) {
coffeelint.reporter(file, errors);
if (options.doEmitErrors && errorReport.hasError()) {
next(new Error("coffeelint has errors"));
}
if (options.doEmitWarnings && _.any(errorReport.paths, function(p) {
return errorReport.pathHasWarning(p);
})) {
next(new Error("coffeelint has warnings"));
}
}
}
this.push(buf);
return next();
});
};
}).call(this);