[tools:feat] add lint-fix gulp task

apply eslint fixes to source files in-place
This commit is contained in:
Maddison Hellstrom 2019-09-11 04:50:18 -07:00
parent 66fb720b04
commit 58e21d12ca
1 changed files with 12 additions and 4 deletions

View File

@ -14,6 +14,7 @@ const platforms = require("platform-folders")
const fs = require("fs").promises const fs = require("fs").promises
const fetch = require("node-fetch") const fetch = require("node-fetch")
const http = require("http") const http = require("http")
const gulpIf = require("gulp-if")
const { COPYFILE_EXCL } = require("fs").constants const { COPYFILE_EXCL } = require("fs").constants
const { URL } = require("url") const { URL } = require("url")
@ -64,10 +65,17 @@ task("clean", () => del(["build", ".cache", ".tmp-gulp-compile-*"]))
task("clean-favicons", () => del([paths.favicons])) task("clean-favicons", () => del([paths.favicons]))
task("lint", () => gulp const lint = (globs, opts = {}) => gulp.src(globs)
.src([...paths.scripts, paths.gulpfile]) .pipe(eslint(opts))
.pipe(eslint()) .pipe(eslint.format())
.pipe(eslint.format()))
task("lint", () => lint([...paths.scripts, paths.gulpfile]))
task("lint-fix", () => lint([...paths.scripts, paths.gulpfile], { fix: true })
.pipe(gulpIf(
(f) => f.eslint !== undefined && f.eslint.fixed === true,
gulp.dest((f) => f.base),
)))
task("check-priv", async () => { task("check-priv", async () => {
try { try {