diff --git a/src/rules/no-single-variables-to-translate.ts b/src/rules/no-single-variables-to-translate.ts index 21a1f06..ac8f83a 100644 --- a/src/rules/no-single-variables-to-translate.ts +++ b/src/rules/no-single-variables-to-translate.ts @@ -52,8 +52,12 @@ const rule: RuleModule = { const identifierName = getIdentifierName(node?.openingElement?.name) if (identifierName === 'Trans') { const isSomeJSXTextWithContent = node && hasSomeJSXTextWithContent(node.children) + const hasIdProperty = + node.openingElement.attributes.find( + (attr) => attr.type === 'JSXAttribute' && attr.name.name === 'id', + ) !== undefined - if (!isSomeJSXTextWithContent) { + if (!isSomeJSXTextWithContent && !hasIdProperty) { context.report({ node, messageId: 'asJsx', diff --git a/tests/src/rules/no-single-varibles-to-translate.test.ts b/tests/src/rules/no-single-varibles-to-translate.test.ts index 4bc6112..8622185 100644 --- a/tests/src/rules/no-single-varibles-to-translate.test.ts +++ b/tests/src/rules/no-single-varibles-to-translate.test.ts @@ -60,6 +60,11 @@ ruleTester.run('no-single-varibles-to-translate', ru code: '`${hello}`', options: [], }, + + { + code: '', + options: [], + }, ], invalid: [