Skip to content

Commit 6f67b52

Browse files
committed
fix(linter): revert prefer-promise-reject-errors to old behavior (#11889)
Follow up to comment in #11766 (comment)
1 parent 87b8496 commit 6f67b52

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

crates/oxc_linter/src/rules/eslint/prefer_promise_reject_errors.rs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -181,11 +181,12 @@ fn check_reject_in_function(
181181
continue;
182182
}
183183

184-
for parent in ctx.nodes().ancestor_kinds(parent.id()) {
185-
if let AstKind::CallExpression(call_expr) = parent {
186-
check_reject_call(call_expr, ctx, allow_empty_reject);
187-
break;
188-
}
184+
let Some(node) = ctx.nodes().parent_node(parent.id()) else {
185+
continue;
186+
};
187+
188+
if let AstKind::CallExpression(call_expr) = node.kind() {
189+
check_reject_call(call_expr, ctx, allow_empty_reject);
189190
}
190191
}
191192
}
@@ -239,6 +240,8 @@ fn test() {
239240
("new Promise(function (...rest) { rest[1](new Error('')); });", None),
240241
// This is fundamentally false, but we can not recognize the value of `i`.
241242
("new Promise(function (resolve, ...rest) { rest[i](5); });", None),
243+
// TODO: This currently passes, as we only look at the immediate parent of the member expression
244+
("new Promise(function (...rest) { (rest[1])(5); });", None),
242245
];
243246

244247
let fail = vec![

0 commit comments

Comments
 (0)