mirror of
https://github.com/oxc-project/oxc.git
synced 2026-11-04 10:29:58 +00:00
fix(linter/typescript/prefer-namespace-keyword): bound token lookup (#25322)
## Summary Bound the `prefer-namespace-keyword` token lookup to the module span. ## Details - Use `find_next_token_within` when locating the `module` keyword. - Preserve the existing replacement span and fix behavior.
This commit is contained in:
1 parent
4745b4e2f9
commit
4266037874
1 file changed
+2
-1
@@ -79,7 +79,8 @@ impl Rule for PreferNamespaceKeyword {
|
||||
|
||||
ctx.diagnostic_with_fix(prefer_namespace_keyword_diagnostic(module.span), |fixer| {
|
||||
let mut span_start = module.span.start;
|
||||
span_start += ctx.find_next_token_from(span_start, "module").unwrap();
|
||||
span_start +=
|
||||
ctx.find_next_token_within(span_start, module.span.end, "module").unwrap();
|
||||
fixer.replace(Span::sized(span_start, 6), "namespace")
|
||||
});
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user