@@ -14,6 +14,7 @@ var RuleTester = require('eslint').RuleTester;
1414var parserOptions = {
1515 ecmaVersion : 6 ,
1616 ecmaFeatures : {
17+ experimentalObjectRestSpread : true ,
1718 jsx : true
1819 }
1920} ;
@@ -46,11 +47,20 @@ ruleTester.run('no-danger-with-children', rule, {
4647 } ,
4748 {
4849 code : [
49- 'const props = { children: "Children" };' ,
50+ 'const moreProps = { className: "eslint" };' ,
51+ 'const props = { children: "Children", ...moreProps };' ,
5052 '<div {...props} />'
5153 ] . join ( '\n' ) ,
5254 parserOptions : parserOptions
5355 } ,
56+ {
57+ code : [
58+ 'const otherProps = { children: "Children" };' ,
59+ 'const { a, b, ...props } = otherProps;' ,
60+ '<div {...props} />' ,
61+ ] . join ( '\n' ) ,
62+ parserOptions : parserOptions
63+ } ,
5464 {
5565 code : '<Hello>Children</Hello>' ,
5666 parserOptions : parserOptions
@@ -103,7 +113,6 @@ ruleTester.run('no-danger-with-children', rule, {
103113 code : [
104114 'const props = { children: "Children", dangerouslySetInnerHTML: { __html: "HTML" } };' ,
105115 '<div {...props} />' ,
106- '//foobar'
107116 ] . join ( '\n' ) ,
108117 errors : [ { message : 'Only set one of `children` or `props.dangerouslySetInnerHTML`' } ] ,
109118 parserOptions : parserOptions
@@ -185,6 +194,16 @@ ruleTester.run('no-danger-with-children', rule, {
185194 ] . join ( '\n' ) ,
186195 errors : [ { message : 'Only set one of `children` or `props.dangerouslySetInnerHTML`' } ] ,
187196 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
188207 }
189208 ]
190209} ) ;
0 commit comments