Skip to content

Commit c220074

Browse files
committed
refactor(valid-expect-in-promise): inline reporting function
We only call it in one place, and so it lets us also remove some minor types that can be otherwise inferred
1 parent afb81a9 commit c220074

File tree

1 file changed

+5
-20
lines changed

1 file changed

+5
-20
lines changed

src/rules/valid-expect-in-promise.ts

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import {
22
AST_NODE_TYPES,
3-
TSESLint,
43
TSESTree,
54
} from '@typescript-eslint/experimental-utils';
65
import {
@@ -15,9 +14,6 @@ import {
1514
isTestCaseCall,
1615
} from './utils';
1716

18-
type MessageIds = 'returnPromise';
19-
type RuleContext = TSESLint.RuleContext<MessageIds, unknown[]>;
20-
2117
type PromiseChainCallExpression = KnownCallExpression<
2218
'then' | 'catch' | 'finally'
2319
>;
@@ -47,20 +43,6 @@ const isPromiseChainCall = (
4743
return false;
4844
};
4945

50-
const reportReturnRequired = (context: RuleContext, node: TSESTree.Node) => {
51-
context.report({
52-
loc: {
53-
end: {
54-
column: node.loc.end.column,
55-
line: node.loc.end.line,
56-
},
57-
start: node.loc.start,
58-
},
59-
messageId: 'returnPromise',
60-
node,
61-
});
62-
};
63-
6446
const findTopMostCallExpression = (
6547
node: TSESTree.CallExpression,
6648
): TSESTree.CallExpression => {
@@ -232,7 +214,7 @@ const isVariableAwaitedOrReturned = (
232214
return isValueAwaitedOrReturned(variable.id, body);
233215
};
234216

235-
export default createRule<unknown[], MessageIds>({
217+
export default createRule({
236218
name: __filename,
237219
meta: {
238220
docs: {
@@ -327,7 +309,10 @@ export default createRule<unknown[], MessageIds>({
327309
return;
328310
}
329311

330-
reportReturnRequired(context, parent);
312+
context.report({
313+
messageId: 'returnPromise',
314+
node: parent,
315+
});
331316
},
332317
};
333318
},

0 commit comments

Comments
 (0)