Skip to content

Commit

Permalink
fix(linter): fix fixer panic in typescript/consistent_indexed_object_…
Browse files Browse the repository at this point in the history
…style (#4165)
  • Loading branch information
Boshen committed Jul 10, 2024
1 parent a956d2e commit 0628548
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -230,8 +230,8 @@ impl Rule for ConsistentIndexedObjectStyle {
),
|fixer| {
let key = fixer.source_range(first.span);
let params_span = Span::new(first.span.end + 2, tref.span.end - 1);
let params = fixer.source_range(params_span);
let params_span = Span::new(first.span.end + 1, tref.span.end - 1);
let params = fixer.source_range(params_span).trim();
let content = format!("{{ [key: {key}]: {params} }}");
fixer.replace(tref.span, content)
},
Expand Down Expand Up @@ -263,6 +263,11 @@ fn test() {
"type Foo<T> = { [key: string]: T };",
Some(serde_json::json!(["index-signature"])),
),
(
"export function getCookies (headers: Headers): Record<string,Østring>",
"export function getCookies (headers: Headers): { [key: string]: Østring }",
Some(serde_json::json!(["index-signature"])),
),
];

let pass = vec![
Expand Down

0 comments on commit 0628548

Please sign in to comment.