@@ -31,29 +31,33 @@ function checkRedundantAccess(node, err) {
31
31
access = tag . id === 'access' ? tag . name . value : tag . id ;
32
32
} ) ;
33
33
34
- if ( access !== 'public' && ( enforceLeadingUnderscore || enforceTrailingUnderscore ) ) {
35
- // fetch name from variable, property or function
36
- var name ;
37
- var nameLocation ;
38
- switch ( node . parentNode . type ) {
39
- case 'VariableDeclarator' :
40
- name = node . parentNode . id . name ;
41
- nameLocation = node . parentNode . id . loc ;
42
- break ;
43
- case 'Property' :
44
- name = node . parentNode . key . name ;
45
- nameLocation = node . parentNode . key . loc ;
46
- break ;
47
- default : // try to use func name itself (if not anonymous)
48
- name = ( node . id || { } ) . name ;
49
- nameLocation = ( node . id || { } ) . loc ;
50
- break ;
51
- }
34
+ // skip unknown and don't check if no forcing
35
+ if ( typeof access === 'undefined' || access === 'public' ||
36
+ ! ( enforceLeadingUnderscore || enforceTrailingUnderscore ) ) {
37
+ return ;
38
+ }
52
39
53
- // skip anonymous and names without underscores at begin
54
- if ( name && name [ enforceLeadingUnderscore ? 0 : ( name . length - 1 ) ] !== '_' ) {
55
- err ( 'Missing ' + ( enforceLeadingUnderscore ? 'leading' : 'trailing' ) +
56
- ' underscore for ' + name , ( nameLocation || node . loc ) . start ) ;
57
- }
40
+ // fetch name from variable, property or function
41
+ var name ;
42
+ var nameLocation ;
43
+ switch ( node . parentNode . type ) {
44
+ case 'VariableDeclarator' :
45
+ name = node . parentNode . id . name ;
46
+ nameLocation = node . parentNode . id . loc ;
47
+ break ;
48
+ case 'Property' :
49
+ name = node . parentNode . key . name ;
50
+ nameLocation = node . parentNode . key . loc ;
51
+ break ;
52
+ default : // try to use func name itself (if not anonymous)
53
+ name = ( node . id || { } ) . name ;
54
+ nameLocation = ( node . id || { } ) . loc ;
55
+ break ;
56
+ }
57
+
58
+ // skip anonymous and names without underscores at begin
59
+ if ( name && name [ enforceLeadingUnderscore ? 0 : ( name . length - 1 ) ] !== '_' ) {
60
+ err ( 'Missing ' + ( enforceLeadingUnderscore ? 'leading' : 'trailing' ) +
61
+ ' underscore for ' + name , ( nameLocation || node . loc ) . start ) ;
58
62
}
59
63
}
0 commit comments