@@ -12,6 +12,11 @@ const rule = require('../../../lib/rules/return-in-computed-property')
12
12
13
13
const RuleTester = require ( 'eslint' ) . RuleTester
14
14
15
+ const parserOptions = {
16
+ ecmaVersion : 6 ,
17
+ sourceType : 'module'
18
+ }
19
+
15
20
// ------------------------------------------------------------------------------
16
21
// Tests
17
22
// ------------------------------------------------------------------------------
@@ -49,7 +54,41 @@ ruleTester.run('return-in-computed-property', rule, {
49
54
}
50
55
}
51
56
` ,
52
- parserOptions : { ecmaVersion : 8 , sourceType : 'module' }
57
+ parserOptions
58
+ } ,
59
+ {
60
+ filename : 'test.vue' ,
61
+ code : `
62
+ export default {
63
+ computed: {
64
+ foo () {
65
+ const options = []
66
+ this.matches.forEach((match) => {
67
+ options.push(match)
68
+ })
69
+ return options
70
+ }
71
+ }
72
+ }
73
+ ` ,
74
+ parserOptions
75
+ } ,
76
+ {
77
+ filename : 'test.vue' ,
78
+ code : `
79
+ export default {
80
+ computed: {
81
+ foo () {
82
+ const options = []
83
+ this.matches.forEach(function (match) {
84
+ options.push(match)
85
+ })
86
+ return options
87
+ }
88
+ }
89
+ }
90
+ ` ,
91
+ parserOptions
53
92
} ,
54
93
{
55
94
filename : 'test.vue' ,
@@ -64,7 +103,7 @@ ruleTester.run('return-in-computed-property', rule, {
64
103
}
65
104
}
66
105
` ,
67
- parserOptions : { ecmaVersion : 8 , sourceType : 'module' } ,
106
+ parserOptions,
68
107
options : [ { treatUndefinedAsUnspecified : false } ]
69
108
}
70
109
] ,
@@ -80,7 +119,7 @@ ruleTester.run('return-in-computed-property', rule, {
80
119
}
81
120
}
82
121
` ,
83
- parserOptions : { ecmaVersion : 8 , sourceType : 'module' } ,
122
+ parserOptions,
84
123
errors : [ {
85
124
message : 'Expected to return a value in "foo" computed property.' ,
86
125
line : 4
@@ -135,7 +174,7 @@ ruleTester.run('return-in-computed-property', rule, {
135
174
}
136
175
}
137
176
` ,
138
- parserOptions : { ecmaVersion : 8 , sourceType : 'module' } ,
177
+ parserOptions,
139
178
errors : [ {
140
179
message : 'Expected to return a value in "foo" computed property.' ,
141
180
line : 7
@@ -155,7 +194,7 @@ ruleTester.run('return-in-computed-property', rule, {
155
194
}
156
195
}
157
196
` ,
158
- parserOptions : { ecmaVersion : 8 , sourceType : 'module' } ,
197
+ parserOptions,
159
198
errors : [ {
160
199
message : 'Expected to return a value in "foo" computed property.' ,
161
200
line : 4
@@ -174,7 +213,7 @@ ruleTester.run('return-in-computed-property', rule, {
174
213
}
175
214
}
176
215
` ,
177
- parserOptions : { ecmaVersion : 8 , sourceType : 'module' } ,
216
+ parserOptions,
178
217
options : [ { treatUndefinedAsUnspecified : false } ] ,
179
218
errors : [ {
180
219
message : 'Expected to return a value in "foo" computed property.' ,
@@ -192,7 +231,7 @@ ruleTester.run('return-in-computed-property', rule, {
192
231
}
193
232
}
194
233
` ,
195
- parserOptions : { ecmaVersion : 8 , sourceType : 'module' } ,
234
+ parserOptions,
196
235
options : [ { treatUndefinedAsUnspecified : true } ] ,
197
236
errors : [ {
198
237
message : 'Expected to return a value in "foo" computed property.' ,
0 commit comments