Skip to content

Commit 14cc587

Browse files
inoway46aduh95
authored andcommitted
tools: avoid repeated subtree scans in must-call-assert
Match the promise call chain before checking for a descendant return statement, preserving the existing lint checks. Assisted-by: Codex Signed-off-by: inoway46 <inoueyuya416@gmail.com> PR-URL: #66408 Refs: #64972 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Filip Skokan <panva.ip@gmail.com>
1 parent 11c3d71 commit 14cc587

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

‎tools/eslint-rules/must-call-assert.js‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,10 +135,11 @@ module.exports = {
135135
});
136136
},
137137

138-
[`CallExpression[callee.property.name="then"][arguments.length=1]>CallExpression:matches(${[
138+
// Check the call chain before searching descendants for a return.
139+
[`:matches(CallExpression[callee.property.name="then"][arguments.length=1]>CallExpression:matches(${[
139140
'[callee.name="mustCall"]',
140141
'[callee.object.name="common"][callee.property.name="mustCall"]',
141-
].join(',')})[arguments.length=1]>:has(ReturnStatement)`]: (node) => {
142+
].join(',')})[arguments.length=1]>*):has(ReturnStatement)`]: (node) => {
142143
context.report({
143144
node,
144145
message: 'Cannot mix `common.mustCall` and return statement inside a `.then` chain',

0 commit comments

Comments
 (0)