Skip to content

Commit 11e0a43

Browse files
committed
fix(linter/prefer-dom-node-remove): panic when callee is ts non null expression (oxc-project#11949)
fixes oxc-project#11948
1 parent 4903e39 commit 11e0a43

File tree

3 files changed

+9
-1
lines changed

3 files changed

+9
-1
lines changed

crates/oxc_linter/src/ast_util.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,7 @@ pub fn is_new_expression<'a>(
399399
pub fn call_expr_method_callee_info<'a>(
400400
call_expr: &'a CallExpression<'a>,
401401
) -> Option<(Span, &'a str)> {
402-
let member_expr = call_expr.callee.without_parentheses().as_member_expression()?;
402+
let member_expr = call_expr.callee.get_inner_expression().as_member_expression()?;
403403
member_expr.static_property_info()
404404
}
405405

crates/oxc_linter/src/rules/unicorn/prefer_dom_node_remove.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,7 @@ fn test() {
187187
r"a.b?.c.parentNode.removeChild(foo)",
188188
r"a[b?.c].parentNode.removeChild(foo)",
189189
r"a?.b.parentNode.removeChild(a.b)",
190+
r"a.removeChild!(k)",
190191
];
191192

192193
Tester::new(PreferDomNodeRemove::NAME, PreferDomNodeRemove::PLUGIN, pass, fail)

crates/oxc_linter/src/snapshots/unicorn_prefer_dom_node_remove.snap

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,3 +294,10 @@ source: crates/oxc_linter/src/tester.rs
294294
· ───────────
295295
╰────
296296
help: Replace `parentNode.removeChild(childNode)` with `childNode{dotOrQuestionDot}remove()`.
297+
298+
eslint-plugin-unicorn(prefer-dom-node-remove): Prefer `childNode.remove()` over `parentNode.removeChild(childNode)`.
299+
╭─[prefer_dom_node_remove.tsx:1:3]
300+
1a.removeChild!(k)
301+
· ───────────
302+
╰────
303+
help: Replace `parentNode.removeChild(childNode)` with `childNode{dotOrQuestionDot}remove()`.

0 commit comments

Comments
 (0)