Skip to content

Commit 2cb9498

Browse files
committed
CCM-11438 Lint fix
1 parent 91dd3ec commit 2cb9498

File tree

1 file changed

+14
-11
lines changed

1 file changed

+14
-11
lines changed

frontend/src/utils/interpolate.ts

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,24 +26,27 @@
2626
*/
2727

2828
// eslint-disable-next-line security/detect-unsafe-regex, sonarjs/slow-regex
29-
const interpolationPattern = /{{\s*([^}|]+)(?:\|([^}|]+)\|([^}]+))?\s*}}/g;
29+
const interpolationPattern = /{{\s*([^|}]+)(?:\|([^|}]+)\|([^}]+))?\s*}}/g;
3030

3131
export function interpolate(
3232
template: string,
3333
variables: Record<string, string | number> = {}
3434
): string {
3535
// eslint-disable-next-line unicorn/prefer-string-replace-all
36-
return template.replace(interpolationPattern, (_match, variable, singular, plural) => {
37-
const key = variable.trim();
38-
const value = variables[key];
36+
return template.replace(
37+
interpolationPattern,
38+
(_match, variable, singular, plural) => {
39+
const key = variable.trim();
40+
const value = variables[key];
3941

40-
if (singular !== undefined && plural !== undefined) {
41-
const count = Number(value);
42+
if (singular !== undefined && plural !== undefined) {
43+
const count = Number(value);
4244

43-
if (Number.isNaN(count)) return plural;
44-
return count === 1 ? singular : plural;
45-
}
45+
if (Number.isNaN(count)) return plural;
46+
return count === 1 ? singular : plural;
47+
}
4648

47-
return value == null ? '' : String(value);
48-
});
49+
return value == null ? '' : String(value);
50+
}
51+
);
4952
}

0 commit comments

Comments
 (0)