@@ -27,6 +27,22 @@ function getErrorData(exceptions) {
27
27
return errorData . get ( exceptions ) ;
28
28
}
29
29
30
+ function isAlways ( configuration , exceptions , propName ) {
31
+ const isException = exceptions . has ( propName ) ;
32
+ if ( configuration === ALWAYS ) {
33
+ return ! isException ;
34
+ }
35
+ return isException ;
36
+ }
37
+
38
+ function isNever ( configuration , exceptions , propName ) {
39
+ const isException = exceptions . has ( propName ) ;
40
+ if ( configuration === NEVER ) {
41
+ return ! isException ;
42
+ }
43
+ return isException ;
44
+ }
45
+
30
46
module . exports = {
31
47
meta : {
32
48
docs : {
@@ -69,7 +85,7 @@ module.exports = {
69
85
}
70
86
} ,
71
87
72
- create : function ( context ) {
88
+ create ( context ) {
73
89
const configuration = context . options [ 0 ] || NEVER ;
74
90
const configObject = context . options [ 1 ] || { } ;
75
91
const exceptions = new Set ( ( configuration === ALWAYS ? configObject [ NEVER ] : configObject [ ALWAYS ] ) || [ ] ) ;
@@ -81,12 +97,8 @@ module.exports = {
81
97
JSXAttribute ( node ) {
82
98
const propName = node . name && node . name . name ;
83
99
const value = node . value ;
84
- const isException = exceptions . has ( propName ) ;
85
-
86
- const isAlways = configuration === ALWAYS ? ! isException : isException ;
87
- const isNever = configuration === NEVER ? ! isException : isException ;
88
100
89
- if ( isAlways && value === null ) {
101
+ if ( isAlways ( configuration , exceptions , propName ) && value === null ) {
90
102
const data = getErrorData ( exceptions ) ;
91
103
context . report ( {
92
104
node : node ,
@@ -97,7 +109,7 @@ module.exports = {
97
109
}
98
110
} ) ;
99
111
}
100
- if ( isNever && value && value . type === 'JSXExpressionContainer' && value . expression . value === true ) {
112
+ if ( isNever ( configuration , exceptions , propName ) && value && value . type === 'JSXExpressionContainer' && value . expression . value === true ) {
101
113
const data = getErrorData ( exceptions ) ;
102
114
context . report ( {
103
115
node : node ,
0 commit comments