Skip to content

Commit 8e79f8d

Browse files
committedSep 8, 2024·
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() {} } ```
1 parent bac03e3 commit 8e79f8d

File tree

2 files changed

+44
-0
lines changed

2 files changed

+44
-0
lines changed
 

‎crates/oxc_linter/src/rules/oxc/no_async_await.rs

+17
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,23 @@ fn test() {
8282
async test() {}
8383
};
8484
",
85+
// FIXME: diagnostics on method `foo` have incorrect spans
86+
"
87+
class Foo {
88+
async foo() {}
89+
}
90+
",
91+
"
92+
class Foo {
93+
public async foo() {}
94+
}
95+
",
96+
// this one is fine
97+
"
98+
const obj = {
99+
async foo() {}
100+
}
101+
",
85102
];
86103

87104
Tester::new(NoAsyncAwait::NAME, pass, fail).test_and_snapshot();

‎crates/oxc_linter/src/snapshots/no_async_await.snap

+27
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,30 @@ source: crates/oxc_linter/src/tester.rs
3737
4 │ };
3838
╰────
3939
help: Async/await is not allowed
40+
41+
oxc(no-async-await): Unexpected async/await
42+
╭─[no_async_await.tsx:3:22]
43+
2class Foo {
44+
3async foo() {}
45+
· ─────
46+
4 │ }
47+
╰────
48+
help: Async/await is not allowed
49+
50+
oxc(no-async-await): Unexpected async/await
51+
╭─[no_async_await.tsx:3:29]
52+
2class Foo {
53+
3public async foo() {}
54+
· ─────
55+
4 │ }
56+
╰────
57+
help: Async/await is not allowed
58+
59+
oxc(no-async-await): Unexpected async/await
60+
╭─[no_async_await.tsx:3:13]
61+
2const obj = {
62+
3 │ async foo() {}
63+
· ─────
64+
4 │ }
65+
╰────
66+
help: Async/await is not allowed

0 commit comments

Comments
 (0)
Please sign in to comment.