@@ -12,6 +12,11 @@ const rule = require('../../../lib/rules/return-in-computed-property')
1212
1313const RuleTester = require ( 'eslint' ) . RuleTester
1414
15+ const parserOptions = {
16+ ecmaVersion : 6 ,
17+ sourceType : 'module'
18+ }
19+
1520// ------------------------------------------------------------------------------
1621// Tests
1722// ------------------------------------------------------------------------------
@@ -49,7 +54,41 @@ ruleTester.run('return-in-computed-property', rule, {
4954 }
5055 }
5156 ` ,
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
5392 } ,
5493 {
5594 filename : 'test.vue' ,
@@ -64,7 +103,7 @@ ruleTester.run('return-in-computed-property', rule, {
64103 }
65104 }
66105 ` ,
67- parserOptions : { ecmaVersion : 8 , sourceType : 'module' } ,
106+ parserOptions,
68107 options : [ { treatUndefinedAsUnspecified : false } ]
69108 }
70109 ] ,
@@ -80,7 +119,7 @@ ruleTester.run('return-in-computed-property', rule, {
80119 }
81120 }
82121 ` ,
83- parserOptions : { ecmaVersion : 8 , sourceType : 'module' } ,
122+ parserOptions,
84123 errors : [ {
85124 message : 'Expected to return a value in "foo" computed property.' ,
86125 line : 4
@@ -135,7 +174,7 @@ ruleTester.run('return-in-computed-property', rule, {
135174 }
136175 }
137176 ` ,
138- parserOptions : { ecmaVersion : 8 , sourceType : 'module' } ,
177+ parserOptions,
139178 errors : [ {
140179 message : 'Expected to return a value in "foo" computed property.' ,
141180 line : 7
@@ -155,7 +194,7 @@ ruleTester.run('return-in-computed-property', rule, {
155194 }
156195 }
157196 ` ,
158- parserOptions : { ecmaVersion : 8 , sourceType : 'module' } ,
197+ parserOptions,
159198 errors : [ {
160199 message : 'Expected to return a value in "foo" computed property.' ,
161200 line : 4
@@ -174,7 +213,7 @@ ruleTester.run('return-in-computed-property', rule, {
174213 }
175214 }
176215 ` ,
177- parserOptions : { ecmaVersion : 8 , sourceType : 'module' } ,
216+ parserOptions,
178217 options : [ { treatUndefinedAsUnspecified : false } ] ,
179218 errors : [ {
180219 message : 'Expected to return a value in "foo" computed property.' ,
@@ -192,7 +231,7 @@ ruleTester.run('return-in-computed-property', rule, {
192231 }
193232 }
194233 ` ,
195- parserOptions : { ecmaVersion : 8 , sourceType : 'module' } ,
234+ parserOptions,
196235 options : [ { treatUndefinedAsUnspecified : true } ] ,
197236 errors : [ {
198237 message : 'Expected to return a value in "foo" computed property.' ,
0 commit comments