Skip to content

Commit e260376

Browse files
committed
test: 100% code coverage
1 parent 57de2b3 commit e260376

File tree

1 file changed

+16
-24
lines changed

1 file changed

+16
-24
lines changed

lib/rules/no-promise-in-fire-event.ts

+16-24
Original file line numberDiff line numberDiff line change
@@ -49,31 +49,23 @@ export default ESLintUtils.RuleCreator(getDocsUrl)<Options, MessageIds>({
4949

5050
for (const reference of references) {
5151
const referenceNode = reference.identifier;
52-
if (
53-
isMemberExpression(referenceNode.parent) &&
54-
isCallExpression(referenceNode.parent.parent)
55-
) {
56-
const [element] = referenceNode.parent.parent
57-
.arguments as TSESTree.Node[];
58-
if (element) {
59-
if (isCallExpression(element) || isNewExpression(element)) {
60-
const methodName = isIdentifier(element.callee)
61-
? element.callee.name
62-
: isMemberExpression(element.callee) &&
63-
isIdentifier(element.callee.property)
64-
? element.callee.property.name
65-
: '';
52+
const callExpression = referenceNode.parent
53+
.parent as TSESTree.CallExpression;
54+
const [element] = callExpression.arguments as TSESTree.Node[];
55+
if (isCallExpression(element) || isNewExpression(element)) {
56+
const methodName = isIdentifier(element.callee)
57+
? element.callee.name
58+
: ((element.callee as TSESTree.MemberExpression)
59+
.property as TSESTree.Identifier).name;
6660

67-
if (
68-
ASYNC_QUERIES_VARIANTS.some(q => methodName.startsWith(q)) ||
69-
methodName === 'Promise'
70-
) {
71-
context.report({
72-
node: element,
73-
messageId: 'noPromiseInFireEvent',
74-
});
75-
}
76-
}
61+
if (
62+
ASYNC_QUERIES_VARIANTS.some(q => methodName.startsWith(q)) ||
63+
methodName === 'Promise'
64+
) {
65+
context.report({
66+
node: element,
67+
messageId: 'noPromiseInFireEvent',
68+
});
7769
}
7870
}
7971
}

0 commit comments

Comments
 (0)