@@ -27,6 +27,22 @@ function getErrorData(exceptions) {
2727 return errorData . get ( exceptions ) ;
2828}
2929
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+
3046module . exports = {
3147 meta : {
3248 docs : {
@@ -69,7 +85,7 @@ module.exports = {
6985 }
7086 } ,
7187
72- create : function ( context ) {
88+ create ( context ) {
7389 const configuration = context . options [ 0 ] || NEVER ;
7490 const configObject = context . options [ 1 ] || { } ;
7591 const exceptions = new Set ( ( configuration === ALWAYS ? configObject [ NEVER ] : configObject [ ALWAYS ] ) || [ ] ) ;
@@ -81,12 +97,8 @@ module.exports = {
8197 JSXAttribute ( node ) {
8298 const propName = node . name && node . name . name ;
8399 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 ;
88100
89- if ( isAlways && value === null ) {
101+ if ( isAlways ( configuration , exceptions , propName ) && value === null ) {
90102 const data = getErrorData ( exceptions ) ;
91103 context . report ( {
92104 node : node ,
@@ -97,7 +109,7 @@ module.exports = {
97109 }
98110 } ) ;
99111 }
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 ) {
101113 const data = getErrorData ( exceptions ) ;
102114 context . report ( {
103115 node : node ,
0 commit comments