@@ -10,69 +10,26 @@ function create (context) {
10
10
const options = context . options [ 0 ] || { }
11
11
const treatUndefinedAsUnspecified = ! ( options . treatUndefinedAsUnspecified === false )
12
12
13
- let funcInfo = {
14
- funcInfo : null ,
15
- codePath : null ,
16
- hasReturn : false ,
17
- hasReturnValue : false ,
18
- node : null
19
- }
20
13
const forbiddenNodes = [ ]
21
14
22
- // ----------------------------------------------------------------------
23
- // Helpers
24
- // ----------------------------------------------------------------------
25
- function isValidReturn ( ) {
26
- if ( ! funcInfo . hasReturn ) {
27
- return false
28
- }
29
- return ! treatUndefinedAsUnspecified || funcInfo . hasReturnValue
30
- }
31
-
32
15
// ----------------------------------------------------------------------
33
16
// Public
34
17
// ----------------------------------------------------------------------
35
18
36
19
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 ) ,
64
21
utils . executeOnVue ( context , properties => {
65
22
const computedProperties = utils . getComputedProperties ( properties )
66
23
67
24
computedProperties . forEach ( cp => {
68
25
forbiddenNodes . forEach ( el => {
69
26
if (
70
27
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
73
30
) {
74
31
context . report ( {
75
- node : el . node ,
32
+ node : el ,
76
33
message : 'Expected to return a value in "{{name}}" computed property.' ,
77
34
data : {
78
35
name : cp . key
0 commit comments