forked from yhat/rodeo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlint.js
45 lines (38 loc) · 1.12 KB
/
lint.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
'use strict';
const eslint = require('eslint/lib/cli'),
globby = require('globby'),
gulpUtil = require('gulp-util');
/**
* @param {Array} glob
* @param {string} config
* @returns {Promise}
*/
function runESLint(glob, config) {
return globby(glob).then(function (paths) {
let code = eslint.execute(['--config="' + config + '"', '--no-eslintrc'].concat(paths).join(' '));
if (code) {
// eslint output already written, wrap up with a short message
throw new gulpUtil.PluginError('lint', new Error('ESLint error'));
}
});
}
module.exports.importTasks = function (gulp) {
gulp.task('lint:browser', function () {
return runESLint([
'src/browser/**/*.jsx',
'src/browser/**/*.js',
'!**/lib/*', // ignore everything in a lib folder, because that's third party (not us)
'!src/browser/ace/**/*'
], '.eslintrc');
});
gulp.task('lint:node', function () {
return runESLint([
'src/node/**/*.js',
'karma*.conf.js',
'gulpfile.js',
'Gruntfile.js',
'scripts/**/*.js'
], '.eslintrc-node');
});
gulp.task('lint', ['lint:browser', 'lint:node']);
};