diff --git a/src/rules/no-expression-in-message.ts b/src/rules/no-expression-in-message.ts index 6a7ad57..9d2e9e0 100644 --- a/src/rules/no-expression-in-message.ts +++ b/src/rules/no-expression-in-message.ts @@ -29,8 +29,13 @@ export const rule = createRule({ return { 'TemplateLiteral:exit'(node: TSESTree.TemplateLiteral) { const noneIdentifierExpressions = node.expressions - ? node.expressions.filter((expression: { type: string }) => { - return expression.type !== TSESTree.AST_NODE_TYPES.Identifier + ? node.expressions.filter((expression) => { + const isIdentifier = expression.type === TSESTree.AST_NODE_TYPES.Identifier + const isCallToPluralFunction = + expression.type === TSESTree.AST_NODE_TYPES.CallExpression && + expression.callee.type === TSESTree.AST_NODE_TYPES.Identifier && + expression.callee.name === 'plural' + return !isIdentifier && !isCallToPluralFunction }) : [] diff --git a/tests/src/rules/no-expression-in-message.test.ts b/tests/src/rules/no-expression-in-message.test.ts index 849b7f4..447fec9 100644 --- a/tests/src/rules/no-expression-in-message.test.ts +++ b/tests/src/rules/no-expression-in-message.test.ts @@ -28,6 +28,9 @@ ruleTester.run(name, rule, { { code: 't`Hello ${hello}`', }, + { + code: 't`Hello ${plural()}`', + }, ], invalid: [ {