Skip to content

Commit

Permalink
chore(repo): fix rule
Browse files Browse the repository at this point in the history
  • Loading branch information
JamesHenry committed Sep 5, 2024
1 parent d085c61 commit 79b4641
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions tools/eslint-rules/rules/valid-command-object.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 ||
Expand Down

0 comments on commit 79b4641

Please sign in to comment.