Skip to content
Snippets Groups Projects
Commit 872848bc authored by Frankly George's avatar Frankly George
Browse files

Fixed ESLint issue count

parent 5bea6f6d
Branches
Tags
1 merge request!11833Fixed ESLint issue count
...@@ -73,6 +73,7 @@ let customProblems = []; ...@@ -73,6 +73,7 @@ let customProblems = [];
let spellingProblems = []; let spellingProblems = [];
/** @type {Array<object>} */ /** @type {Array<object>} */
let eslintProblems = []; let eslintProblems = [];
let eslintProblemCount = 0;
/** @type {Array<string>} */ /** @type {Array<string>} */
let typescriptProblems = []; let typescriptProblems = [];
...@@ -111,6 +112,9 @@ if (settings.checksEnableSpelling === true) { ...@@ -111,6 +112,9 @@ if (settings.checksEnableSpelling === true) {
if (settings.checksEnableESLint === true) { if (settings.checksEnableESLint === true) {
// @ts-ignore // @ts-ignore
eslintProblems = await eslintChecks(settings.checksOnlyChangedESLint, stagedFiles, parser); eslintProblems = await eslintChecks(settings.checksOnlyChangedESLint, stagedFiles, parser);
eslintProblems.forEach(problem => {
eslintProblemCount += problem.messages.length;
});
} }
if (settings.checksEnableTypescript === true) { if (settings.checksEnableTypescript === true) {
// @ts-ignore // @ts-ignore
...@@ -164,8 +168,8 @@ if (spellingProblems.length > 0) { ...@@ -164,8 +168,8 @@ if (spellingProblems.length > 0) {
skippedChecks += 1; skippedChecks += 1;
} }
if (eslintProblems.length > 0) { if (eslintProblemCount > 0) {
log(c.bold.red(`ESLint found ${eslintProblems.length} linting issues.`)); log(c.bold.red(`ESLint found ${eslintProblemCount} linting issues.`));
} else if (settings.checksEnableESLint === true) { } else if (settings.checksEnableESLint === true) {
log(c.green(`ESLint found no linting issues.`)); log(c.green(`ESLint found no linting issues.`));
} else { } else {
...@@ -182,7 +186,7 @@ if (typescriptProblems.length > 0) { ...@@ -182,7 +186,7 @@ if (typescriptProblems.length > 0) {
skippedChecks += 1; skippedChecks += 1;
} }
const issueCount = customProblems.length + spellingProblems.length + eslintProblems.length + typescriptProblems.length; const issueCount = customProblems.length + spellingProblems.length + eslintProblemCount + typescriptProblems.length;
log(""); log("");
let finalMessage = ""; let finalMessage = "";
...@@ -202,7 +206,7 @@ log("=".repeat(60)); ...@@ -202,7 +206,7 @@ log("=".repeat(60));
// exclude eslint and typescript problems from making git pre-commit hook fail // exclude eslint and typescript problems from making git pre-commit hook fail
// we may change this in the future // we may change this in the future
if ((issueCount - (eslintProblems.length + typescriptProblems.length)) > 0) { if ((issueCount - (eslintProblemCount + typescriptProblems.length)) > 0) {
if (args.staged === true) { if (args.staged === true) {
log(`You can temporarily disable the pre-commit hook by changing 'Edit Sanity Check Settings' -> 'Running sanity checks before commiting' in "setup.${process.platform === "win32" ? "bat": "sh"}" to 'Sanity checks are temporarily disabled...'`); log(`You can temporarily disable the pre-commit hook by changing 'Edit Sanity Check Settings' -> 'Running sanity checks before commiting' in "setup.${process.platform === "win32" ? "bat": "sh"}" to 'Sanity checks are temporarily disabled...'`);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment