Skip to content

Commit

Permalink
Fix formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
onigoetz committed Oct 18, 2024
1 parent df9fd5b commit 45ee03b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
2 changes: 1 addition & 1 deletion packages/messageformat/src/parser.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ test.group("parse()", () => {

test("throws on missing offset number", ({ expect }) => {
expect(() => parse("{n,plural,offset: other{n}")).toThrow(
"expected offset number at position 17 but found . \"…fset:[ ]other…\"",
'expected offset number at position 17 but found . "…fset:[ ]other…"',
);
});
});
21 changes: 12 additions & 9 deletions packages/messageformat/src/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ function expected(char: string, context: Context): SyntaxError {
return new SyntaxError(
`expected ${char} at position ${index} but found ${
found || "eof"
}. ${codeFrame(context)}`
}. ${codeFrame(context)}`,
);
}

Expand Down Expand Up @@ -141,7 +141,7 @@ function skipSeparator(char: number, context: Context) {
if (char !== CHAR_SEP) {
throw expected(
`${String.fromCharCode(CHAR_SEP)} or ${String.fromCharCode(CHAR_CLOSE)}`,
context
context,
);
}
++context.i;
Expand Down Expand Up @@ -233,7 +233,7 @@ function parseText(context: Context, specialHash = false): string {
function parseSubmessage(
context: Context,
parent: VariableToken,
specialHash: boolean
specialHash: boolean,
): number {
const startAt = context.nextIndex;
skipSpace(context);
Expand Down Expand Up @@ -276,7 +276,7 @@ function parseSubmessages(
context: Context,
parent: VariableToken,
specialHash: boolean,
isPlural: boolean
isPlural: boolean,
): Submessages {
const submessages: Submessages = {} as Submessages;

Expand All @@ -290,7 +290,7 @@ function parseSubmessages(
if (isPlural && !selector.match(PLURAL)) {
throw expected(
"selector to be one of 'zero', 'one', 'two', 'few', 'many', 'other' or '=' followed by a digit",
context
context,
);
}

Expand All @@ -305,7 +305,7 @@ function parseSubmessages(
}

function isDigit(char: number): boolean {
return (char >= CHAR_0 && char <= CHAR_9) || char === CHAR_MINUS
return (char >= CHAR_0 && char <= CHAR_9) || char === CHAR_MINUS;
}

/**
Expand All @@ -325,7 +325,10 @@ function parseOffset(context: Context): number {
context.i += 7;

const start = context.i;
while (context.i < context.l && isDigit(context.msg.charCodeAt(context.i))) {
while (
context.i < context.l &&
isDigit(context.msg.charCodeAt(context.i))
) {
++context.i;
}

Expand Down Expand Up @@ -504,7 +507,7 @@ function parseElement(context: Context) {
function parseAST(
context: Context,
parent: VariableToken,
specialHash: boolean
specialHash: boolean,
): Token[] {
while (context.i < context.l) {
const start = context.i;
Expand Down Expand Up @@ -558,6 +561,6 @@ export default function parse(message: string | number): Token[] {
//eslint-disable-next-line @swissquote/swissquote/@typescript-eslint/ban-ts-comment
//@ts-ignore
null,
false
false,
);
}

0 comments on commit 45ee03b

Please sign in to comment.