@@ -10,7 +10,8 @@ const docsUrl = require('../util/docsUrl');
10
10
// Constants
11
11
// ------------------------------------------------------------------------------
12
12
13
- const DEFAULTS = { html : 'enforce' , custom : 'enforce' , exceptions : [ ] } ;
13
+ const OPTIONS = { ignore : 'ignore' , enforce : 'enforce' } ;
14
+ const DEFAULTS = { html : OPTIONS . enforce , custom : OPTIONS . enforce , exceptions : [ ] } ;
14
15
15
16
// ------------------------------------------------------------------------------
16
17
// Rule Definition
@@ -25,29 +26,49 @@ module.exports = {
25
26
url : docsUrl ( 'jsx-props-no-spreading' )
26
27
} ,
27
28
schema : [ {
28
- type : 'object' ,
29
- properties : {
30
- html : {
31
- enum : [ 'enforce' , 'ignore' ]
32
- } ,
33
- custom : {
34
- enum : [ 'enforce' , 'ignore' ]
35
- } ,
36
- exceptions : {
37
- type : 'array' ,
38
- items : {
39
- type : 'string' ,
40
- uniqueItems : true
29
+ allOf : [ {
30
+ type : 'object' ,
31
+ properties : {
32
+ html : {
33
+ enum : [ OPTIONS . enforce , OPTIONS . ignore ]
34
+ } ,
35
+ custom : {
36
+ enum : [ OPTIONS . enforce , OPTIONS . ignore ]
37
+ } ,
38
+ exceptions : {
39
+ type : 'array' ,
40
+ items : {
41
+ type : 'string' ,
42
+ uniqueItems : true
43
+ }
41
44
}
42
45
}
43
- }
46
+ } , {
47
+ not : {
48
+ type : 'object' ,
49
+ required : [ 'html' , 'custom' ] ,
50
+ properties : {
51
+ html : {
52
+ enum : [ OPTIONS . ignore ]
53
+ } ,
54
+ custom : {
55
+ enum : [ OPTIONS . ignore ]
56
+ } ,
57
+ exceptions : {
58
+ type : 'array' ,
59
+ minItems : 0 ,
60
+ maxItems : 0
61
+ }
62
+ }
63
+ }
64
+ } ]
44
65
} ]
45
66
} ,
46
67
47
68
create : function ( context ) {
48
69
const configuration = context . options [ 0 ] || { } ;
49
- const ignoreHtmlTags = ( configuration . html || DEFAULTS . html ) === ' ignore' ;
50
- const ignoreCustomTags = ( configuration . custom || DEFAULTS . custom ) === ' ignore' ;
70
+ const ignoreHtmlTags = ( configuration . html || DEFAULTS . html ) === OPTIONS . ignore ;
71
+ const ignoreCustomTags = ( configuration . custom || DEFAULTS . custom ) === OPTIONS . ignore ;
51
72
const exceptions = configuration . exceptions || DEFAULTS . exceptions ;
52
73
const isException = ( tag , allExceptions ) => allExceptions . indexOf ( tag ) !== - 1 ;
53
74
return {
0 commit comments