@@ -14,6 +14,7 @@ var RuleTester = require('eslint').RuleTester;
14
14
var parserOptions = {
15
15
ecmaVersion : 6 ,
16
16
ecmaFeatures : {
17
+ experimentalObjectRestSpread : true ,
17
18
jsx : true
18
19
}
19
20
} ;
@@ -46,11 +47,20 @@ ruleTester.run('no-danger-with-children', rule, {
46
47
} ,
47
48
{
48
49
code : [
49
- 'const props = { children: "Children" };' ,
50
+ 'const moreProps = { className: "eslint" };' ,
51
+ 'const props = { children: "Children", ...moreProps };' ,
50
52
'<div {...props} />'
51
53
] . join ( '\n' ) ,
52
54
parserOptions : parserOptions
53
55
} ,
56
+ {
57
+ code : [
58
+ 'const otherProps = { children: "Children" };' ,
59
+ 'const { a, b, ...props } = otherProps;' ,
60
+ '<div {...props} />' ,
61
+ ] . join ( '\n' ) ,
62
+ parserOptions : parserOptions
63
+ } ,
54
64
{
55
65
code : '<Hello>Children</Hello>' ,
56
66
parserOptions : parserOptions
@@ -103,7 +113,6 @@ ruleTester.run('no-danger-with-children', rule, {
103
113
code : [
104
114
'const props = { children: "Children", dangerouslySetInnerHTML: { __html: "HTML" } };' ,
105
115
'<div {...props} />' ,
106
- '//foobar'
107
116
] . join ( '\n' ) ,
108
117
errors : [ { message : 'Only set one of `children` or `props.dangerouslySetInnerHTML`' } ] ,
109
118
parserOptions : parserOptions
@@ -185,6 +194,16 @@ ruleTester.run('no-danger-with-children', rule, {
185
194
] . join ( '\n' ) ,
186
195
errors : [ { message : 'Only set one of `children` or `props.dangerouslySetInnerHTML`' } ] ,
187
196
parserOptions : parserOptions
197
+ } ,
198
+ {
199
+ code : [
200
+ 'const moreProps = { children: "Children" };' ,
201
+ 'const otherProps = { ...moreProps };' ,
202
+ 'const props = { ...otherProps, dangerouslySetInnerHTML: { __html: "HTML" } };' ,
203
+ 'React.createElement("div", props);'
204
+ ] . join ( '\n' ) ,
205
+ errors : [ { message : 'Only set one of `children` or `props.dangerouslySetInnerHTML`' } ] ,
206
+ parserOptions : parserOptions
188
207
}
189
208
]
190
209
} ) ;
0 commit comments