Skip to content

Commit 8715216

Browse files
author
Andreas Opferkuch
committed
Added tests for jsx-curly-spacing that deal with comments in children.
See also: #648 (comment)
1 parent f1e86b5 commit 8715216

File tree

1 file changed

+76
-0
lines changed

1 file changed

+76
-0
lines changed

tests/lib/rules/jsx-curly-spacing.js

+76
Original file line numberDiff line numberDiff line change
@@ -2118,5 +2118,81 @@ ruleTester.run('jsx-curly-spacing', rule, {
21182118
}, {
21192119
message: 'A space is required before \'}\''
21202120
}]
2121+
}, {
2122+
code: [
2123+
'<App>',
2124+
'{ /* comment */ }',
2125+
'</App>;'
2126+
].join('\n'),
2127+
output: [
2128+
'<App>',
2129+
'{/* comment */}',
2130+
'</App>;'
2131+
].join('\n'),
2132+
options: [{when: 'never', children: true}],
2133+
errors: [{
2134+
message: 'There should be no space after \'{\''
2135+
}, {
2136+
message: 'There should be no space before \'}\''
2137+
}]
2138+
}, {
2139+
code: [
2140+
'<App>',
2141+
'{/* comment */}',
2142+
'</App>;'
2143+
].join('\n'),
2144+
output: [
2145+
'<App>',
2146+
'{ /* comment */ }',
2147+
'</App>;'
2148+
].join('\n'),
2149+
options: [{when: 'always', children: true}],
2150+
errors: [{
2151+
message: 'A space is required after \'{\''
2152+
}, {
2153+
message: 'A space is required before \'}\''
2154+
}]
2155+
}, {
2156+
code: [
2157+
'<App>{ /* comment */',
2158+
'bar',
2159+
'} {',
2160+
'baz',
2161+
'/* comment */ }</App>;'
2162+
].join('\n'),
2163+
output: [
2164+
'<App>{/* comment */',
2165+
'bar',
2166+
'} {',
2167+
'baz',
2168+
'/* comment */}</App>;'
2169+
].join('\n'),
2170+
options: [{when: 'never', children: true}],
2171+
errors: [{
2172+
message: 'There should be no space after \'{\''
2173+
}, {
2174+
message: 'There should be no space before \'}\''
2175+
}]
2176+
}, {
2177+
code: [
2178+
'<App>{/* comment */',
2179+
'bar',
2180+
'} {',
2181+
'baz',
2182+
'/* comment */}</App>;'
2183+
].join('\n'),
2184+
output: [
2185+
'<App>{ /* comment */',
2186+
'bar',
2187+
'} {',
2188+
'baz',
2189+
'/* comment */ }</App>;'
2190+
].join('\n'),
2191+
options: [{when: 'always', children: true}],
2192+
errors: [{
2193+
message: 'A space is required after \'{\''
2194+
}, {
2195+
message: 'A space is required before \'}\''
2196+
}]
21212197
}]
21222198
});

0 commit comments

Comments
 (0)