Skip to content

Commit

Permalink
Remove option to lint only changed files (#1715)
Browse files Browse the repository at this point in the history
  • Loading branch information
Heniker authored Dec 30, 2021
1 parent 09f6024 commit 519795a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 18 deletions.
2 changes: 1 addition & 1 deletion .husky/pre-commit → .husky/pre-push
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npx gulp lint-pre-commit
npx gulp lint
20 changes: 3 additions & 17 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -302,31 +302,18 @@ const runPrettier = async fix => {
});
};

const findChangedFiles = async () => {
const data = await promisify(cp.exec)("git diff --name-only HEAD");
return data.stderr
? assert(false, data.stderr)
: data.stdout.replace(/\r\n/g, "\n").split("\n");
};

/**
* @typedef {{color: boolean, fix: boolean, changedOnly: boolean}} OptionsT
* @typedef {{color: boolean, fix: boolean}} OptionsT
*/

/**
* @param {OptionsT} options_
*/
const runEslint = async options_ => {
/** @type {OptionsT} */
const options = Object.assign({ color: true, fix: false, changedOnly: false }, options_);
const options = Object.assign({ color: true, fix: false }, options_);

const files = options.changedOnly
? await findChangedFiles().then(it => it.filter(it => it.startsWith("src")))
: ["src/**/*.ts"];

if (files.length === 0) {
return;
}
const files = ["src/**/*.ts"];

const args = [
...(options.color ? ["--color"] : ["--no-color"]),
Expand All @@ -353,7 +340,6 @@ gulp.task("format", gulp.series("format:prettier", "format:eslint"));
gulp.task("lint:prettier", () => runPrettier(false));
gulp.task("lint:eslint", () => runEslint({ fix: false }));
gulp.task("lint", gulp.series("lint:prettier", "lint:eslint"));
gulp.task("lint-pre-commit", () => runEslint({ fix: false, color: false, changedOnly: true }));

/** Run webpack to bundle the extension output files */
gulp.task("webpack-bundle", async () => {
Expand Down

0 comments on commit 519795a

Please sign in to comment.