Skip to content

Commit

Permalink
Try to please Sam
Browse files Browse the repository at this point in the history
  • Loading branch information
AaronMoat committed Sep 9, 2024
1 parent 6523acd commit 73e0648
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions src/cli/adapter/eslint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,18 +53,7 @@ export const runESLint = async (

const [formatter, { type, results }] = await Promise.all([
engine.loadFormatter(),
engine
.lintFiles([])
.then((r) => ({ type: 'results', results: r }) as const)
.catch((error) => {
if (
error instanceof Error &&
error.message === 'Could not find config file.'
) {
return { type: 'no-config', results: undefined } as const;
}
throw error;
}),
lintFiles(engine),
]);

if (type === 'no-config') {
Expand Down Expand Up @@ -125,3 +114,18 @@ export const runESLint = async (

return { errors, fixable, ok, output, warnings };
};

const lintFiles = async (engine: ESLint) => {
try {
const result = await engine.lintFiles([]);
return { type: 'results', results: result } as const;
} catch (error) {
if (
error instanceof Error &&
error.message === 'Could not find config file.'
) {
return { type: 'no-config', results: undefined } as const;
}
throw error;
}
};

0 comments on commit 73e0648

Please sign in to comment.