Skip to content

Commit 4e7c3a3

Browse files
author
Sean Kenneth Doherty
authored
hoist prettifier rule construction (#211)
1 parent cb8a3d3 commit 4e7c3a3

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

packages/formatter/src/errorMessagePrettifier.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@ export type CodeBlockFn = (
99
export function createErrorMessagePrettifier(
1010
codeBlock: CodeBlockFn
1111
): (message: string) => Promise<string> {
12+
const rules = getRules(codeBlock);
13+
1214
return async (message: string) => {
13-
const rules = await getRules(codeBlock);
1415
let output = message;
1516

1617
for (const { pattern, replacer } of rules) {
@@ -35,7 +36,7 @@ type Rule = {
3536
replacer: (...args: any[]) => string | Promise<string>;
3637
};
3738

38-
async function getRules(codeBlock: CodeBlockFn): Promise<Rule[]> {
39+
function getRules(codeBlock: CodeBlockFn): Rule[] {
3940
const formatTypeScriptBlock = (code: string) => codeBlock(code, "typescript");
4041

4142
const formatSimpleTypeBlock = (code: string) => codeBlock(code, "type");

0 commit comments

Comments
 (0)