@@ -15,34 +15,30 @@ const rule = require('../../../lib/rules/no-async-in-computed-properties')
15
15
// Tests
16
16
// ------------------------------------------------------------------------------
17
17
18
- const ruleTester = new RuleTester ( {
19
- parser : 'vue-eslint-parser' ,
20
- parserOptions : { ecmaVersion : 2015 , sourceType : 'module' }
21
- } )
18
+ const ruleTester = new RuleTester ( )
22
19
23
20
ruleTester . run ( 'no-async-in-computed-properties' , rule , {
24
21
25
22
valid : [
26
- {
27
- filename : 'test.vue' ,
28
- code : 'computed: { foo: function () { return this.aaa } }'
29
- } ,
30
23
{
31
24
filename : 'test.vue' ,
32
25
code : `
33
- computed: {
34
- foo: function () {
35
- var bar = 0
36
- try {
37
- bar = bar / 0
38
- } catch (e) {
39
- return e
40
- } finally {
41
- return bar
26
+ export default {
27
+ computed: {
28
+ foo: function () {
29
+ var bar = 0
30
+ try {
31
+ bar = bar / 0
32
+ } catch (e) {
33
+ return e
34
+ } finally {
35
+ return bar
36
+ }
42
37
}
43
38
}
44
39
}
45
- `
40
+ ` ,
41
+ parserOptions : { ecmaVersion : 6 , sourceType : 'module' }
46
42
}
47
43
] ,
48
44
@@ -58,7 +54,11 @@ ruleTester.run('no-async-in-computed-properties', rule, {
58
54
}
59
55
}
60
56
` ,
61
- errors : [ 'Computed properies cannot have side effect.' ]
57
+ parserOptions : { ecmaVersion : 6 , sourceType : 'module' } ,
58
+ errors : [
59
+ 'Unexpected await in "foo" computed property.' ,
60
+ 'Unexpected async in "foo" computed property.'
61
+ ]
62
62
} ,
63
63
{
64
64
filename : 'test.vue' ,
@@ -71,7 +71,11 @@ ruleTester.run('no-async-in-computed-properties', rule, {
71
71
}
72
72
}
73
73
` ,
74
- errors : [ 'Computed properies cannot have side effect.' ]
74
+ parserOptions : { ecmaVersion : 6 , sourceType : 'module' } ,
75
+ errors : [
76
+ 'Unexpected asynchronous action in "foo" computed property.' ,
77
+ 'Unexpected async in "foo" computed property.'
78
+ ]
75
79
} ,
76
80
{
77
81
filename : 'test.vue' ,
@@ -84,7 +88,8 @@ ruleTester.run('no-async-in-computed-properties', rule, {
84
88
}
85
89
}
86
90
` ,
87
- errors : [ 'Computed properies cannot have side effect.' ]
91
+ parserOptions : { ecmaVersion : 6 , sourceType : 'module' } ,
92
+ errors : [ 'Unexpected asynchronous action in "foo" computed property.' ]
88
93
} ,
89
94
{
90
95
filename : 'test.vue' ,
@@ -97,7 +102,8 @@ ruleTester.run('no-async-in-computed-properties', rule, {
97
102
}
98
103
}
99
104
` ,
100
- errors : [ 'Computed properies cannot have side effect.' ]
105
+ parserOptions : { ecmaVersion : 6 , sourceType : 'module' } ,
106
+ errors : [ 'Unexpected asynchronous action in "foo" computed property.' ]
101
107
} ,
102
108
{
103
109
filename : 'test.vue' ,
@@ -110,7 +116,8 @@ ruleTester.run('no-async-in-computed-properties', rule, {
110
116
}
111
117
}
112
118
` ,
113
- errors : [ 'Computed properies cannot have side effect.' ]
119
+ parserOptions : { ecmaVersion : 6 , sourceType : 'module' } ,
120
+ errors : [ 'Unexpected asynchronous action in "foo" computed property.' ]
114
121
} ,
115
122
{
116
123
filename : 'test.vue' ,
@@ -123,7 +130,8 @@ ruleTester.run('no-async-in-computed-properties', rule, {
123
130
}
124
131
}
125
132
` ,
126
- errors : [ 'Computed properies cannot have side effect.' ]
133
+ parserOptions : { ecmaVersion : 6 , sourceType : 'module' } ,
134
+ errors : [ 'Unexpected asynchronous action in "foo" computed property.' ]
127
135
} ,
128
136
{
129
137
filename : 'test.vue' ,
@@ -136,7 +144,8 @@ ruleTester.run('no-async-in-computed-properties', rule, {
136
144
}
137
145
}
138
146
` ,
139
- errors : [ 'Computed properies cannot have side effect.' ]
147
+ parserOptions : { ecmaVersion : 6 , sourceType : 'module' } ,
148
+ errors : [ 'Unexpected asynchronous action in "foo" computed property.' ]
140
149
} ,
141
150
{
142
151
filename : 'test.vue' ,
@@ -149,7 +158,8 @@ ruleTester.run('no-async-in-computed-properties', rule, {
149
158
}
150
159
}
151
160
` ,
152
- errors : [ 'Computed properies cannot have side effect.' ]
161
+ parserOptions : { ecmaVersion : 6 , sourceType : 'module' } ,
162
+ errors : [ 'Unexpected asynchronous action in "foo" computed property.' ]
153
163
} ,
154
164
{
155
165
filename : 'test.vue' ,
@@ -162,7 +172,8 @@ ruleTester.run('no-async-in-computed-properties', rule, {
162
172
}
163
173
}
164
174
` ,
165
- errors : [ 'Computed properies cannot have side effect.' ]
175
+ parserOptions : { ecmaVersion : 6 , sourceType : 'module' } ,
176
+ errors : [ 'Unexpected asynchronous action in "foo" computed property.' ]
166
177
} ,
167
178
{
168
179
filename : 'test.vue' ,
@@ -177,7 +188,8 @@ ruleTester.run('no-async-in-computed-properties', rule, {
177
188
}
178
189
}
179
190
` ,
180
- errors : [ 'Computed properies cannot have side effect.' ]
191
+ parserOptions : { ecmaVersion : 6 , sourceType : 'module' } ,
192
+ errors : [ 'Unexpected asynchronous action in "foo" computed property.' ]
181
193
}
182
194
]
183
195
} )
0 commit comments