-
-
Notifications
You must be signed in to change notification settings - Fork 508
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(linter): fix diagnostic spans for
oxc/no-async-await
(#8721)
Fixes broken diagnostic spans for async functions that did not correctly report on the `async` keyword. I changed the diagnostic reporting to look for the `async` keyword itself within a given span which is a little slower but worth it for accuracy I think. I also updated the diagnostic to be async-specific as we don't report on await yet.
- Loading branch information
Showing
2 changed files
with
112 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,66 +1,93 @@ | ||
--- | ||
source: crates/oxc_linter/src/tester.rs | ||
--- | ||
⚠ oxc(no-async-await): Unexpected async/await | ||
⚠ oxc(no-async-await): async is not allowed | ||
╭─[no_async_await.tsx:1:1] | ||
1 │ async function foo() {} | ||
· ───── | ||
╰──── | ||
help: Async/await is not allowed | ||
help: Remove the `async` keyword | ||
|
||
⚠ oxc(no-async-await): Unexpected async/await | ||
⚠ oxc(no-async-await): async is not allowed | ||
╭─[no_async_await.tsx:1:13] | ||
1 │ const foo = async () => {} | ||
· ───── | ||
╰──── | ||
help: Async/await is not allowed | ||
help: Remove the `async` keyword | ||
|
||
⚠ oxc(no-async-await): Unexpected async/await | ||
⚠ oxc(no-async-await): async is not allowed | ||
╭─[no_async_await.tsx:1:1] | ||
1 │ async () => {} | ||
· ───── | ||
╰──── | ||
help: Async/await is not allowed | ||
help: Remove the `async` keyword | ||
|
||
⚠ oxc(no-async-await): Unexpected async/await | ||
⚠ oxc(no-async-await): async is not allowed | ||
╭─[no_async_await.tsx:1:14] | ||
1 │ const test = async () => {}; | ||
· ───── | ||
╰──── | ||
help: Async/await is not allowed | ||
help: Remove the `async` keyword | ||
|
||
⚠ oxc(no-async-await): Unexpected async/await | ||
⚠ oxc(no-async-await): async is not allowed | ||
╭─[no_async_await.tsx:3:17] | ||
2 │ const test = { | ||
3 │ async test() {} | ||
· ───── | ||
4 │ }; | ||
╰──── | ||
help: Async/await is not allowed | ||
help: Remove the `async` keyword | ||
|
||
⚠ oxc(no-async-await): Unexpected async/await | ||
╭─[no_async_await.tsx:3:22] | ||
⚠ oxc(no-async-await): async is not allowed | ||
╭─[no_async_await.tsx:3:13] | ||
2 │ class Foo { | ||
3 │ async foo() {} | ||
· ───── | ||
· ───── | ||
4 │ } | ||
╰──── | ||
help: Async/await is not allowed | ||
help: Remove the `async` keyword | ||
|
||
⚠ oxc(no-async-await): Unexpected async/await | ||
╭─[no_async_await.tsx:3:29] | ||
⚠ oxc(no-async-await): async is not allowed | ||
╭─[no_async_await.tsx:3:20] | ||
2 │ class Foo { | ||
3 │ public async foo() {} | ||
· ───── | ||
· ───── | ||
4 │ } | ||
╰──── | ||
help: Async/await is not allowed | ||
help: Remove the `async` keyword | ||
|
||
⚠ oxc(no-async-await): Unexpected async/await | ||
⚠ oxc(no-async-await): async is not allowed | ||
╭─[no_async_await.tsx:3:13] | ||
2 │ const obj = { | ||
3 │ async foo() {} | ||
· ───── | ||
4 │ } | ||
╰──── | ||
help: Async/await is not allowed | ||
help: Remove the `async` keyword | ||
|
||
⚠ oxc(no-async-await): async is not allowed | ||
╭─[no_async_await.tsx:3:13] | ||
2 │ class async { | ||
3 │ async async() { | ||
· ───── | ||
4 │ async(); | ||
╰──── | ||
help: Remove the `async` keyword | ||
|
||
⚠ oxc(no-async-await): async is not allowed | ||
╭─[no_async_await.tsx:3:13] | ||
2 │ class async { | ||
3 │ async async() { | ||
· ───── | ||
4 │ function async() { | ||
╰──── | ||
help: Remove the `async` keyword | ||
|
||
⚠ oxc(no-async-await): async is not allowed | ||
╭─[no_async_await.tsx:6:32] | ||
5 │ const async = { | ||
6 │ async: async () => {}, | ||
· ───── | ||
7 │ } | ||
╰──── | ||
help: Remove the `async` keyword |