Skip to content

Commit 3749ddd

Browse files
committed
Rewrite no-danger-with-children tests with template literals
1 parent 79a4aab commit 3749ddd

File tree

1 file changed

+78
-78
lines changed

1 file changed

+78
-78
lines changed

tests/lib/rules/no-danger-with-children.js

Lines changed: 78 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -43,24 +43,24 @@ ruleTester.run('no-danger-with-children', rule, {
4343
code: '<div children="Children" />'
4444
},
4545
{
46-
code: [
47-
'const props = { dangerouslySetInnerHTML: { __html: "HTML" } };',
48-
'<div {...props} />'
49-
].join('\n')
46+
code: `
47+
const props = { dangerouslySetInnerHTML: { __html: "HTML" } };
48+
<div {...props} />
49+
`
5050
},
5151
{
52-
code: [
53-
'const moreProps = { className: "eslint" };',
54-
'const props = { children: "Children", ...moreProps };',
55-
'<div {...props} />'
56-
].join('\n')
52+
code: `
53+
const moreProps = { className: "eslint" };
54+
const props = { children: "Children", ...moreProps };
55+
<div {...props} />
56+
`
5757
},
5858
{
59-
code: [
60-
'const otherProps = { children: "Children" };',
61-
'const { a, b, ...props } = otherProps;',
62-
'<div {...props} />'
63-
].join('\n')
59+
code: `
60+
const otherProps = { children: "Children" };
61+
const { a, b, ...props } = otherProps;
62+
<div {...props} />
63+
`
6464
},
6565
{
6666
code: '<Hello>Children</Hello>'
@@ -95,37 +95,37 @@ ruleTester.run('no-danger-with-children', rule, {
9595
],
9696
invalid: [
9797
{
98-
code: [
99-
'<div dangerouslySetInnerHTML={{ __html: "HTML" }}>',
100-
' Children',
101-
'</div>'
102-
].join('\n'),
98+
code: `
99+
<div dangerouslySetInnerHTML={{ __html: "HTML" }}>
100+
Children
101+
</div>
102+
`,
103103
errors: [{message: 'Only set one of `children` or `props.dangerouslySetInnerHTML`'}]
104104
},
105105
{
106106
code: '<div dangerouslySetInnerHTML={{ __html: "HTML" }} children="Children" />',
107107
errors: [{message: 'Only set one of `children` or `props.dangerouslySetInnerHTML`'}]
108108
},
109109
{
110-
code: [
111-
'const props = { dangerouslySetInnerHTML: { __html: "HTML" } };',
112-
'<div {...props}>Children</div>'
113-
].join('\n'),
110+
code: `
111+
const props = { dangerouslySetInnerHTML: { __html: "HTML" } };
112+
<div {...props}>Children</div>
113+
`,
114114
errors: [{message: 'Only set one of `children` or `props.dangerouslySetInnerHTML`'}]
115115
},
116116
{
117-
code: [
118-
'const props = { children: "Children", dangerouslySetInnerHTML: { __html: "HTML" } };',
119-
'<div {...props} />'
120-
].join('\n'),
117+
code: `
118+
const props = { children: "Children", dangerouslySetInnerHTML: { __html: "HTML" } };
119+
<div {...props} />
120+
`,
121121
errors: [{message: 'Only set one of `children` or `props.dangerouslySetInnerHTML`'}]
122122
},
123123
{
124-
code: [
125-
'<Hello dangerouslySetInnerHTML={{ __html: "HTML" }}>',
126-
' Children',
127-
'</Hello>'
128-
].join('\n'),
124+
code: `
125+
<Hello dangerouslySetInnerHTML={{ __html: "HTML" }}>
126+
Children
127+
</Hello>
128+
`,
129129
errors: [{message: 'Only set one of `children` or `props.dangerouslySetInnerHTML`'}]
130130
},
131131
{
@@ -137,70 +137,70 @@ ruleTester.run('no-danger-with-children', rule, {
137137
errors: [{message: 'Only set one of `children` or `props.dangerouslySetInnerHTML`'}]
138138
},
139139
{
140-
code: [
141-
'React.createElement(',
142-
' "div",',
143-
' { dangerouslySetInnerHTML: { __html: "HTML" } },',
144-
' "Children"',
145-
');'
146-
].join('\n'),
140+
code: `
141+
React.createElement(
142+
"div",
143+
{ dangerouslySetInnerHTML: { __html: "HTML" } },
144+
"Children"
145+
);
146+
`,
147147
errors: [{message: 'Only set one of `children` or `props.dangerouslySetInnerHTML`'}]
148148
},
149149
{
150-
code: [
151-
'React.createElement(',
152-
' "div",',
153-
' {',
154-
' dangerouslySetInnerHTML: { __html: "HTML" },',
155-
' children: "Children",',
156-
' }',
157-
');'
158-
].join('\n'),
150+
code: `
151+
React.createElement(
152+
"div",
153+
{
154+
dangerouslySetInnerHTML: { __html: "HTML" },
155+
children: "Children",
156+
}
157+
);
158+
`,
159159
errors: [{message: 'Only set one of `children` or `props.dangerouslySetInnerHTML`'}]
160160
},
161161
{
162-
code: [
163-
'React.createElement(',
164-
' "Hello",',
165-
' { dangerouslySetInnerHTML: { __html: "HTML" } },',
166-
' "Children"',
167-
');'
168-
].join('\n'),
162+
code: `
163+
React.createElement(
164+
"Hello",
165+
{ dangerouslySetInnerHTML: { __html: "HTML" } },
166+
"Children"
167+
);
168+
`,
169169
errors: [{message: 'Only set one of `children` or `props.dangerouslySetInnerHTML`'}]
170170
},
171171
{
172-
code: [
173-
'React.createElement(',
174-
' "Hello",',
175-
' {',
176-
' dangerouslySetInnerHTML: { __html: "HTML" },',
177-
' children: "Children",',
178-
' }',
179-
');'
180-
].join('\n'),
172+
code: `
173+
React.createElement(
174+
"Hello",
175+
{
176+
dangerouslySetInnerHTML: { __html: "HTML" },
177+
children: "Children",
178+
}
179+
);
180+
`,
181181
errors: [{message: 'Only set one of `children` or `props.dangerouslySetInnerHTML`'}]
182182
},
183183
{
184-
code: [
185-
'const props = { dangerouslySetInnerHTML: { __html: "HTML" } };',
186-
'React.createElement("div", props, "Children");'
187-
].join('\n'),
184+
code: `
185+
const props = { dangerouslySetInnerHTML: { __html: "HTML" } };
186+
React.createElement("div", props, "Children");
187+
`,
188188
errors: [{message: 'Only set one of `children` or `props.dangerouslySetInnerHTML`'}]
189189
},
190190
{
191-
code: [
192-
'const props = { children: "Children", dangerouslySetInnerHTML: { __html: "HTML" } };',
193-
'React.createElement("div", props);'
194-
].join('\n'),
191+
code: `
192+
const props = { children: "Children", dangerouslySetInnerHTML: { __html: "HTML" } };
193+
React.createElement("div", props);
194+
`,
195195
errors: [{message: 'Only set one of `children` or `props.dangerouslySetInnerHTML`'}]
196196
},
197197
{
198-
code: [
199-
'const moreProps = { children: "Children" };',
200-
'const otherProps = { ...moreProps };',
201-
'const props = { ...otherProps, dangerouslySetInnerHTML: { __html: "HTML" } };',
202-
'React.createElement("div", props);'
203-
].join('\n'),
198+
code: `
199+
const moreProps = { children: "Children" };
200+
const otherProps = { ...moreProps };
201+
const props = { ...otherProps, dangerouslySetInnerHTML: { __html: "HTML" } };
202+
React.createElement("div", props);
203+
`,
204204
errors: [{message: 'Only set one of `children` or `props.dangerouslySetInnerHTML`'}]
205205
}
206206
]

0 commit comments

Comments
 (0)