From 79b46417c157b19956b14c6bff8d8071cb0f76b9 Mon Sep 17 00:00:00 2001 From: JamesHenry Date: Thu, 5 Sep 2024 12:43:47 +0400 Subject: [PATCH] chore(repo): fix rule --- tools/eslint-rules/rules/valid-command-object.ts | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/tools/eslint-rules/rules/valid-command-object.ts b/tools/eslint-rules/rules/valid-command-object.ts index 718ab4a55a31c..55540e87aad44 100644 --- a/tools/eslint-rules/rules/valid-command-object.ts +++ b/tools/eslint-rules/rules/valid-command-object.ts @@ -53,19 +53,13 @@ export const rule = ESLintUtils.RuleCreator(() => __filename)({ 'Property > :matches(Identifier[name="describe"], Identifier[name="description"], TaggedTemplateExpression)': (node: TSESTree.Identifier) => { const propertyNode = node.parent as TSESTree.Property; - const simplePropertyValue = - propertyNode.value.type === 'Literal' && - typeof propertyNode.value.value !== 'boolean' + const stringToCheck = + (propertyNode.value.type === 'Literal' && + typeof propertyNode.value.value !== 'boolean') || + propertyNode.value.type === 'TemplateLiteral' ? ASTUtils.getStringIfConstant(propertyNode.value) : null; - let stringToCheck = simplePropertyValue; - if (!stringToCheck) { - if (propertyNode.value.type === 'TaggedTemplateExpression') { - stringToCheck = propertyNode.value.quasi.quasis[0].value.raw; - } - } - // String description already ends with a . character (or some other form of punctuation) if ( !stringToCheck ||