test(linter): add class method test cases for oxc/no-async-await (#5550)

Adds tests for class and object methods. Diagnostics for the former have incorrect spans.

```javascript
class Foo {
   // span covers `() {}`
  async foo() {}
}
```
This commit is contained in:
DonIsaac 2024-09-08 03:15:01 +00:00
parent bac03e3b6c
commit 8e79f8d72d
2 changed files with 44 additions and 0 deletions

View file

@ -82,6 +82,23 @@ fn test() {
async test() {}
};
",
// FIXME: diagnostics on method `foo` have incorrect spans
"
class Foo {
async foo() {}
}
",
"
class Foo {
public async foo() {}
}
",
// this one is fine
"
const obj = {
async foo() {}
}
",
];
Tester::new(NoAsyncAwait::NAME, pass, fail).test_and_snapshot();

View file

@ -37,3 +37,30 @@ source: crates/oxc_linter/src/tester.rs
4 │ };
╰────
help: Async/await is not allowed
⚠ oxc(no-async-await): Unexpected async/await
╭─[no_async_await.tsx:3:22]
2 │ class Foo {
3 │ async foo() {}
· ─────
4 │ }
╰────
help: Async/await is not allowed
⚠ oxc(no-async-await): Unexpected async/await
╭─[no_async_await.tsx:3:29]
2 │ class Foo {
3 │ public async foo() {}
· ─────
4 │ }
╰────
help: Async/await is not allowed
⚠ oxc(no-async-await): Unexpected async/await
╭─[no_async_await.tsx:3:13]
2 │ const obj = {
3 │ async foo() {}
· ─────
4 │ }
╰────
help: Async/await is not allowed