From c2c1bea884507f9ce3eeb118d8c38b6c313e61d7 Mon Sep 17 00:00:00 2001 From: inoway46 Date: Wed, 30 Sep 2026 12:35:54 +0900 Subject: [PATCH] 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 --- tools/eslint-rules/must-call-assert.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tools/eslint-rules/must-call-assert.js b/tools/eslint-rules/must-call-assert.js index b991e29063aa..6990e526ad88 100644 --- a/tools/eslint-rules/must-call-assert.js +++ b/tools/eslint-rules/must-call-assert.js @@ -135,10 +135,11 @@ module.exports = { }); }, - [`CallExpression[callee.property.name="then"][arguments.length=1]>CallExpression:matches(${[ + // Check the call chain before searching descendants for a return. + [`:matches(CallExpression[callee.property.name="then"][arguments.length=1]>CallExpression:matches(${[ '[callee.name="mustCall"]', '[callee.object.name="common"][callee.property.name="mustCall"]', - ].join(',')})[arguments.length=1]>:has(ReturnStatement)`]: (node) => { + ].join(',')})[arguments.length=1]>*):has(ReturnStatement)`]: (node) => { context.report({ node, message: 'Cannot mix `common.mustCall` and return statement inside a `.then` chain',