-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
/
no-unused-expressions.js
37 lines (36 loc) 路 1.09 KB
/
no-unused-expressions.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
import rule from "../../lib/rules/no-unused-expressions.js";
import RuleTester from "../../../babel-eslint-shared-fixtures/utils/RuleTester.js";
const ruleTester = new RuleTester();
ruleTester.run("@babel/no-unused-expressions", rule, {
valid: [
"let a = do { if (foo) { foo.bar; } }",
"let a = do { foo; }",
"let a = do { let b = 2; foo; }",
"let a = do { (foo + 1); }",
"let a = do { if (foo) { if (foo.bar) { foo.bar; } } }",
"let a = do { if (foo) { if (foo.bar) { foo.bar; } else if (foo.baz) { foo.baz; } } }",
"foo.bar?.();",
],
invalid: [
{
code: "let a = do { foo; let b = 2; }",
errors: [
{
message:
"Expected an assignment or function call and instead saw an expression.",
type: "ExpressionStatement",
},
],
},
{
code: "let a = do { if (foo) { foo.bar } else { a; bar.foo } }",
errors: [
{
message:
"Expected an assignment or function call and instead saw an expression.",
type: "ExpressionStatement",
},
],
},
],
});