Skip to content

Commit a6e39d0

Browse files
committed
Failing tests for jsx-child-element-spacing proposal
1 parent baa939c commit a6e39d0

File tree

2 files changed

+92
-0
lines changed

2 files changed

+92
-0
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
'use strict';
2+
3+
// TODO(pfhayes): Just a stub for now to get tests working
4+
module.exports = {
5+
meta: {
6+
docs: {},
7+
schema: [
8+
{
9+
type: 'object',
10+
properties: {},
11+
default: {},
12+
additionalProperties: false
13+
}
14+
]
15+
},
16+
create: function (/* context */) {
17+
return {};
18+
}
19+
};
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
'use strict';
2+
3+
const rule = require('../../../lib/rules/jsx-child-element-spacing');
4+
const RuleTester = require('eslint').RuleTester;
5+
const parserOptions = {
6+
sourceType: 'module',
7+
ecmaFeatures: {
8+
jsx: true
9+
}
10+
};
11+
12+
const ERROR_MESSAGE = [{message: 'Ambiguous spacing between child elements.'}];
13+
14+
const ruleTester = new RuleTester({parserOptions});
15+
ruleTester.run('jsx-child-element-spacing', rule, {
16+
valid: [{
17+
code: `
18+
<App>
19+
foo
20+
bar
21+
</App>
22+
`
23+
}, {
24+
code: `
25+
<App>
26+
<a>foo</a>
27+
<a>bar</a>
28+
</App>
29+
`
30+
}, {
31+
code: `
32+
<App>
33+
foo<a>bar</a>baz
34+
</App>
35+
`
36+
}, {
37+
code: `
38+
<App>
39+
foo
40+
{' '}
41+
<a>bar</a>
42+
{' '}
43+
baz
44+
</App>
45+
`
46+
}, {
47+
code: `
48+
<App>
49+
foo{/*
50+
*/}<a>bar</a>{/*
51+
*/}baz
52+
</App>
53+
`
54+
}],
55+
56+
invalid: [{
57+
code: `
58+
<App>
59+
foo
60+
<a>bar</a>
61+
</App>
62+
`,
63+
errors: ERROR_MESSAGE
64+
}, {
65+
code: `
66+
<App>
67+
<a>bar</a>
68+
baz
69+
</App>
70+
`,
71+
errors: ERROR_MESSAGE
72+
}]
73+
});

0 commit comments

Comments
 (0)