mirror of
https://github.com/mozilla/pdf.js.git
synced 2026-07-30 19:07:22 +02:00
Merge pull request #21169 from calixteman/speedup_lint
Improve the performances of "gulp lint"
This commit is contained in:
commit
a1b7d0feb5
55
gulpfile.mjs
55
gulpfile.mjs
@ -2293,6 +2293,7 @@ gulp.task("lint", function (done) {
|
|||||||
"node_modules/eslint/bin/eslint",
|
"node_modules/eslint/bin/eslint",
|
||||||
".",
|
".",
|
||||||
"--report-unused-disable-directives",
|
"--report-unused-disable-directives",
|
||||||
|
"--concurrency=auto",
|
||||||
];
|
];
|
||||||
if (process.argv.includes("--fix")) {
|
if (process.argv.includes("--fix")) {
|
||||||
esLintOptions.push("--fix");
|
esLintOptions.push("--fix");
|
||||||
@ -2307,9 +2308,11 @@ gulp.task("lint", function (done) {
|
|||||||
styleLintOptions.push("--fix");
|
styleLintOptions.push("--fix");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// JSON files are intentionally not passed to Prettier here: ESLint already
|
||||||
|
// formats them via its prettier/prettier rule (with identical output), and
|
||||||
|
// running both in parallel would race on writes in --fix mode.
|
||||||
const prettierOptions = [
|
const prettierOptions = [
|
||||||
"node_modules/prettier/bin/prettier.cjs",
|
"node_modules/prettier/bin/prettier.cjs",
|
||||||
"**/*.json",
|
|
||||||
"**/*.html",
|
"**/*.html",
|
||||||
];
|
];
|
||||||
if (process.argv.includes("--fix")) {
|
if (process.argv.includes("--fix")) {
|
||||||
@ -2325,40 +2328,28 @@ gulp.task("lint", function (done) {
|
|||||||
"--no-summary",
|
"--no-summary",
|
||||||
];
|
];
|
||||||
|
|
||||||
const esLintProcess = startNode(esLintOptions, { stdio: "inherit" });
|
function runLinter(name, options) {
|
||||||
esLintProcess.on("close", function (esLintCode) {
|
return new Promise(resolve => {
|
||||||
if (esLintCode !== 0) {
|
const proc = startNode(options, { stdio: "inherit" });
|
||||||
done(new Error("ESLint failed."));
|
proc.on("close", code => {
|
||||||
|
resolve(code === 0 ? null : name);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
Promise.all([
|
||||||
|
runLinter("ESLint", esLintOptions),
|
||||||
|
runLinter("Stylelint", styleLintOptions),
|
||||||
|
runLinter("Prettier", prettierOptions),
|
||||||
|
runLinter("svglint", svgLintOptions),
|
||||||
|
]).then(results => {
|
||||||
|
const failures = results.filter(Boolean);
|
||||||
|
if (failures.length) {
|
||||||
|
done(new Error(`${failures.join(", ")} failed.`));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const styleLintProcess = startNode(styleLintOptions, { stdio: "inherit" });
|
gulp.task("lint-licenses")(done);
|
||||||
styleLintProcess.on("close", function (styleLintCode) {
|
|
||||||
if (styleLintCode !== 0) {
|
|
||||||
done(new Error("Stylelint failed."));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const prettierProcess = startNode(prettierOptions, { stdio: "inherit" });
|
|
||||||
prettierProcess.on("close", function (prettierCode) {
|
|
||||||
if (prettierCode !== 0) {
|
|
||||||
done(new Error("Prettier failed."));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const svgLintProcess = startNode(svgLintOptions, {
|
|
||||||
stdio: "inherit",
|
|
||||||
});
|
|
||||||
svgLintProcess.on("close", function (svgLintCode) {
|
|
||||||
if (svgLintCode !== 0) {
|
|
||||||
done(new Error("svglint failed."));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
gulp.task("lint-licenses")(done);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user