Skip to content
This repository was archived by the owner on Feb 21, 2025. It is now read-only.

Commit 408710d

Browse files
committed
fix(all): fix gulp and add Webpack ESLint
1 parent 1cc4ea4 commit 408710d

File tree

3 files changed

+41
-1
lines changed

3 files changed

+41
-1
lines changed

index.js

+22
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,28 @@ module.exports = (gulp, userConfig, tasks) => {
3737

3838
/* eslint-enable global-require */
3939

40+
// This is a fix fo Gulp, because series and paparallel needs at least one task
41+
gulp.task('nothing-to-do', function (done) { return done(); });
42+
43+
if (!tasks.clean.length) {
44+
tasks.clean.push('nothing-to-do');
45+
}
46+
if (!tasks.compile.length) {
47+
tasks.compile.push('nothing-to-do');
48+
}
49+
if (!tasks.validate.length) {
50+
tasks.validate.push('nothing-to-do');
51+
}
52+
if (!tasks.test.length) {
53+
tasks.test.push('nothing-to-do');
54+
}
55+
if (!tasks.watch.length) {
56+
tasks.watch.push('nothing-to-do');
57+
}
58+
if (!tasks.default.length) {
59+
tasks.default.push('nothing-to-do');
60+
}
61+
4062
// Instead of `gulp.parallel`, which is what is set in Pattern Lab Starter's `gulpfile.js`, this
4163
// uses `gulp.series`. Needed to help with the Gulp task dependencies lost going from v3 to v4.
4264
// We basically need icons compiled before CSS & CSS/JS compiled before inject:pl before pl

lib/webpack.js

+18
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
'use strict';
22

3+
const eslint = require('gulp-eslint');
4+
const cached = require('gulp-cached');
35
const webpack = require('webpack');
46
const browserSync = require('browser-sync');
57
const core = require('./core');
@@ -17,6 +19,22 @@ Note: you can copy the template from templates/webpack.config.js.
1719
process.exit(1);
1820
}
1921

22+
function validateJs() {
23+
return gulp.src(config.webpack.eslint.src)
24+
.pipe(cached('validate:webpack'))
25+
.pipe(eslint())
26+
.pipe(eslint.format());
27+
}
28+
29+
validateJs.description = 'Lint Webpack.';
30+
31+
if (config.webpack.eslint.enabled) {
32+
gulp.task('validate:webpack', () => validateJs().pipe(eslint.failAfterError()));
33+
tasks.validate.push('validate:webpack');
34+
gulp.task('watch:validate:webpack', () => gulp.watch(config.webpack.eslint.src, validateJs));
35+
tasks.watch.push('watch:validate:webpack');
36+
}
37+
2038
function compileWebpack() {
2139
return gulp.src(config.webpack.config)
2240
.pipe(function runCompileWebpack() {

templates/gulpfile.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ gulp.task('compile', gulp.series(
2424
'clean',
2525
gulp.series(tasks.compile)
2626
));
27-
gulp.task('build', ['compile']); // alias
27+
gulp.task('build', gulp.series(['compile'])); // alias
2828
gulp.task('validate', gulp.parallel(tasks.validate));
2929
gulp.task('test', gulp.parallel(tasks.test));
3030
gulp.task('watch', gulp.parallel(tasks.watch));

0 commit comments

Comments
 (0)