mirror of
https://github.com/danbulant/oxc
synced 2026-05-19 12:19:15 +00:00
fix(linter): fix false positives for generics in no-unexpected-multiline (#6039)
- follow-up to https://github.com/oxc-project/oxc/pull/6031
This commit is contained in:
parent
1f92d61097
commit
09a24cd9f1
1 changed files with 14 additions and 1 deletions
|
|
@ -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);
|
||||
|
||||
|
|
@ -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![
|
||||
|
|
|
|||
Loading…
Reference in a new issue