forked from grofzero/lesshint-webpack-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
32 lines (29 loc) · 938 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
29
30
31
32
var LessHint = require('lesshint').Lesshint;
var glob = require('glob-all');
function LessHintPlugin(options) {
this.options = options || {};
this.lessOptions = options.configFile ? require(options.configFile) : null;
}
LessHintPlugin.prototype.apply = function (compiler) {
var self = this;
compiler.plugin('done', function () {
var reporter = self.options.reporter || require('lesshint-reporter-stylish');
var lessConfig = self.lessOptions;
var lessHint = new LessHint();
if (!lessConfig) {
lessConfig = lessHint.getConfig();
}
lessHint.configure(lessConfig);
glob(self.options.files || [], function (err, files) {
if (err) {
throw new Error('Error processing files');
}
for (var i = 0, iLen = files.length; i < iLen; i++) {
lessHint.checkFile(files[i]).then((report) => {
reporter.report(report);
});
}
});
});
};
module.exports = LessHintPlugin;