/
no-async-functions.js
45 lines (43 loc) · 1.36 KB
/
no-async-functions.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
/**
* @author Toru Nagashima <https://github.com/mysticatea>
* See LICENSE file in root directory for full license.
*/
"use strict"
const RuleTester = require("../../tester")
const rule = require("../../../lib/rules/no-async-functions.js")
new RuleTester().run("no-async-functions", rule, {
valid: [
"function f() {}",
"const f = function() {}",
"const f = () => {}",
"({ method() {} })",
"class A { method() {} }",
"(class { method() {} })",
],
invalid: [
{
code: "async function f() {}",
errors: ["ES2017 async function declarations are forbidden."],
},
{
code: "const f = async function() {}",
errors: ["ES2017 async function declarations are forbidden."],
},
{
code: "const f = async () => {}",
errors: ["ES2017 async function declarations are forbidden."],
},
{
code: "({ async method() {} })",
errors: ["ES2017 async function declarations are forbidden."],
},
{
code: "class A { async method() {} }",
errors: ["ES2017 async function declarations are forbidden."],
},
{
code: "(class { async method() {} })",
errors: ["ES2017 async function declarations are forbidden."],
},
],
})