Skip to content

Commit

Permalink
Exit with success under normal conditions.
Browse files Browse the repository at this point in the history
  • Loading branch information
iclanton committed Mar 29, 2024
1 parent d7fb39a commit 11d0146
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@rushstack/eslint-patch",
"comment": "Exit with success under normal conditions.",
"type": "patch"
}
],
"packageName": "@rushstack/eslint-patch"
}
21 changes: 11 additions & 10 deletions eslint/eslint-patch/src/eslint-bulk-suppressions/cli/runEslint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@ import type { ESLint } from 'eslint';
import { getEslintPath } from './utils/get-eslint-cli';

export async function runEslintAsync(files: string[], mode: 'suppress' | 'prune'): Promise<void> {
const eslintPath: string = getEslintPath(process.cwd());
const cwd: string = process.cwd();
const eslintPath: string = getEslintPath(cwd);
const { ESLint }: typeof import('eslint') = require(eslintPath);
const eslint: ESLint = new ESLint({
useEslintrc: true,
cwd: process.cwd()
cwd
});

let results: ESLint.LintResult[];
Expand All @@ -32,14 +33,14 @@ export async function runEslintAsync(files: string[], mode: 'suppress' | 'prune'
}
}

const stylishFormatter: ESLint.Formatter = await eslint.loadFormatter();
const formattedResults: string = stylishFormatter.format(results);
if (formattedResults) {
if (results.length > 0) {
const stylishFormatter: ESLint.Formatter = await eslint.loadFormatter();
const formattedResults: string = stylishFormatter.format(results);
console.log(formattedResults);
throw new Error(`@rushstack/eslint-bulk ESLint errors`);
} else {
console.log(
`@rushstack/eslint-bulk: Successfully pruned unused suppressions in all .eslint-bulk-suppressions.json files under directory ${process.cwd()}`
);
}

console.log(
'@rushstack/eslint-bulk: Successfully pruned unused suppressions in all .eslint-bulk-suppressions.json ' +
`files under directory ${cwd}`
);
}

0 comments on commit 11d0146

Please sign in to comment.