mirror of
https://github.com/oxc-project/oxc.git
synced 2026-11-04 10:29:58 +00:00
fix(linter/typescript/consistent-generic-constructors): bound token lookup (#25258)
## Summary Bound computed-property token lookup to the property span. ## Details - Use `find_next_token_within` to find the closing bracket only within the current property. - Preserve the existing insertion-point calculation for the closing bracket.
This commit is contained in:
1 parent
e23dccf338
commit
1501ccf9e6
1 file changed
+4
-3
@@ -393,8 +393,8 @@ impl ConsistentGenericConstructors {
|
||||
if prop_def.computed {
|
||||
// Find the closing bracket after the key
|
||||
let key_end = prop_def.key.span().end;
|
||||
// find_next_token_from returns offset from key_end, add 1 for position after ']'
|
||||
ctx.find_next_token_from(key_end, "]").map(|offset| key_end + offset + 1)
|
||||
ctx.find_next_token_within(key_end, prop_def.span.end, "]")
|
||||
.map(|offset| key_end + offset + 1)
|
||||
} else {
|
||||
// Insert after the property key
|
||||
Some(prop_def.key.span().end)
|
||||
@@ -403,7 +403,8 @@ impl ConsistentGenericConstructors {
|
||||
AstKind::AccessorProperty(accessor) => {
|
||||
if accessor.computed {
|
||||
let key_end = accessor.key.span().end;
|
||||
ctx.find_next_token_from(key_end, "]").map(|offset| key_end + offset + 1)
|
||||
ctx.find_next_token_within(key_end, accessor.span.end, "]")
|
||||
.map(|offset| key_end + offset + 1)
|
||||
} else {
|
||||
Some(accessor.key.span().end)
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user