Skip to content

Commit 9a73ab9

Browse files
committed
refactor: fix async
1 parent 17f8029 commit 9a73ab9

File tree

2 files changed

+19
-19
lines changed

2 files changed

+19
-19
lines changed

tools/eslint-formatter-multiple-formats/src/lib/multiple-formats.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,10 @@ export const DEFAULT_CONFIG: Required<
5050
* "terminal": "stylish" // Optional: Format for terminal output (default: 'stylish')
5151
* }
5252
*/
53-
export default function multipleFormats(
53+
export default async function multipleFormats(
5454
results: ESLint.LintResult[],
5555
_args?: unknown,
56-
): string {
56+
): Promise<string> {
5757
const config = {
5858
...DEFAULT_CONFIG,
5959
...getConfigFromEnv(process.env),
@@ -68,7 +68,7 @@ export default function multipleFormats(
6868
} = config;
6969

7070
try {
71-
persistEslintReports(formats, results, {
71+
await persistEslintReports(formats, results, {
7272
outputDir,
7373
filename,
7474
verbose,

tools/eslint-formatter-multiple-formats/src/lib/utils.ts

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Import ansis for colors (similar to chalk)
22
import { bold, dim, red, reset, underline, yellow } from 'ansis';
33
import type { ESLint } from 'eslint';
4-
import { mkdirSync, writeFileSync } from 'node:fs';
4+
import { mkdir, writeFile } from 'node:fs/promises';
55
import path from 'node:path';
66
import type { FormatterConfig } from './types.js';
77

@@ -269,16 +269,14 @@ export type PersistConfig = {
269269
verbose: boolean;
270270
};
271271

272-
export function persistEslintReport(
272+
export async function persistEslintReport(
273273
results: ESLint.LintResult[],
274274
options: PersistConfig,
275-
): boolean {
275+
): Promise<boolean> {
276276
const { outputDir, filename, format, verbose = false } = options;
277277
try {
278-
// eslint-disable-next-line n/no-sync
279-
mkdirSync(outputDir, { recursive: true });
280-
// eslint-disable-next-line n/no-sync
281-
writeFileSync(
278+
await mkdir(outputDir, { recursive: true });
279+
await writeFile(
282280
path.join(outputDir, `${filename}.${getExtensionForFormat(format)}`),
283281
formatContent(results, format),
284282
);
@@ -297,19 +295,21 @@ export function persistEslintReport(
297295
}
298296
}
299297

300-
export function persistEslintReports(
298+
export async function persistEslintReports(
301299
formats: EslintFormat[],
302300
results: ESLint.LintResult[],
303301
options: Omit<PersistConfig, 'format'>,
304-
): boolean {
302+
): Promise<void> {
305303
const { outputDir, filename, verbose } = options;
306304

307-
return formats.every(format =>
308-
persistEslintReport(results, {
309-
outputDir,
310-
filename,
311-
format,
312-
verbose,
313-
}),
305+
await Promise.all(
306+
formats.map(format =>
307+
persistEslintReport(results, {
308+
outputDir,
309+
filename,
310+
format,
311+
verbose,
312+
}),
313+
),
314314
);
315315
}

0 commit comments

Comments
 (0)