@@ -10,69 +10,26 @@ function create (context) {
1010 const options = context . options [ 0 ] || { }
1111 const treatUndefinedAsUnspecified = ! ( options . treatUndefinedAsUnspecified === false )
1212
13- let funcInfo = {
14- funcInfo : null ,
15- codePath : null ,
16- hasReturn : false ,
17- hasReturnValue : false ,
18- node : null
19- }
2013 const forbiddenNodes = [ ]
2114
22- // ----------------------------------------------------------------------
23- // Helpers
24- // ----------------------------------------------------------------------
25- function isValidReturn ( ) {
26- if ( ! funcInfo . hasReturn ) {
27- return false
28- }
29- return ! treatUndefinedAsUnspecified || funcInfo . hasReturnValue
30- }
31-
3215 // ----------------------------------------------------------------------
3316 // Public
3417 // ----------------------------------------------------------------------
3518
3619 return Object . assign ( { } ,
37- {
38- onCodePathStart ( codePath , node ) {
39- funcInfo = {
40- codePath,
41- funcInfo : funcInfo ,
42- hasReturn : false ,
43- hasReturnValue : false ,
44- node
45- }
46- } ,
47- onCodePathEnd ( ) {
48- funcInfo = funcInfo . funcInfo
49- } ,
50- ReturnStatement ( node ) {
51- funcInfo . hasReturn = true
52- funcInfo . hasReturnValue = Boolean ( node . argument )
53- } ,
54- 'FunctionExpression:exit' ( node ) {
55- if ( ! isValidReturn ( ) ) {
56- forbiddenNodes . push ( {
57- hasReturn : funcInfo . hasReturn ,
58- node : funcInfo . node ,
59- type : 'return'
60- } )
61- }
62- }
63- } ,
20+ utils . findMissingReturns ( forbiddenNodes , treatUndefinedAsUnspecified ) ,
6421 utils . executeOnVue ( context , properties => {
6522 const computedProperties = utils . getComputedProperties ( properties )
6623
6724 computedProperties . forEach ( cp => {
6825 forbiddenNodes . forEach ( el => {
6926 if (
7027 cp . value &&
71- el . node . loc . start . line >= cp . value . loc . start . line &&
72- el . node . loc . end . line <= cp . value . loc . end . line
28+ el . loc . start . line >= cp . value . loc . start . line &&
29+ el . loc . end . line <= cp . value . loc . end . line
7330 ) {
7431 context . report ( {
75- node : el . node ,
32+ node : el ,
7633 message : 'Expected to return a value in "{{name}}" computed property.' ,
7734 data : {
7835 name : cp . key
0 commit comments