Skip to content

Commit

Permalink
fix(linter): fix false positives for generics in `no-unexpected-multi…
Browse files Browse the repository at this point in the history
…line` (#6039)

- follow-up to #6031
  • Loading branch information
camchenry committed Sep 24, 2024
1 parent 1f92d61 commit 09a24cd
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion crates/oxc_linter/src/rules/eslint/no_unexpected_multiline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,13 @@ impl Rule for NoUnexpectedMultiline {
return;
}

let span = Span::new(call_expr.callee.span().end, call_expr.span.end);
let start = if let Some(generics) = &call_expr.type_parameters {
generics.span.end
} else {
call_expr.callee.span().end
};

let span = Span::new(start, call_expr.span.end);
if let Some(open_paren_pos) = has_newline_before(ctx, span, b'(') {
let paren_span = Span::sized(span.start + open_paren_pos, 1);

Expand Down Expand Up @@ -337,6 +343,13 @@ fn test() {
"class C { field1\n*gen() {} }", // { "ecmaVersion": 2022 },
"class C { field1 = () => {}\n[field2]; }", // { "ecmaVersion": 2022 },
"class C { field1 = () => {}\n*gen() {} }", // { "ecmaVersion": 2022 }
"const foo = bar<{
a: string
b: number
}>();",
"const foo = bar<{
[key: string | number]: string
}>();",
];

let fail = vec![
Expand Down

0 comments on commit 09a24cd

Please sign in to comment.