Skip to content

Commit b52f3b8

Browse files
committed
jsx-max-props-per-line: Add additional test cases
Make sure it works when a prop is on the same line as the start line of the tag, as well as with spread props that spans multiple lines.
1 parent b485e28 commit b52f3b8

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

tests/lib/rules/jsx-max-props-per-line.js

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ ruleTester.run('jsx-max-props-per-line', rule, {
3838
code: '<App foo bar />',
3939
options: [{when: 'multiline'}],
4040
parserOptions: parserOptions
41+
}, {
42+
code: '<App foo {...this.props} />',
43+
options: [{when: 'multiline'}],
44+
parserOptions: parserOptions
4145
}, {
4246
code: '<App foo bar baz />',
4347
options: [{maximum: 2, when: 'multiline'}],
@@ -109,6 +113,46 @@ ruleTester.run('jsx-max-props-per-line', rule, {
109113
].join('\n'),
110114
errors: [{message: 'Prop `bar` must be placed on a new line'}],
111115
parserOptions: parserOptions
116+
}, {
117+
code: [
118+
'<App foo={{',
119+
'}} bar />'
120+
].join('\n'),
121+
errors: [{message: 'Prop `bar` must be placed on a new line'}],
122+
parserOptions: parserOptions
123+
}, {
124+
code: [
125+
'<App foo bar={{',
126+
'}} baz />'
127+
].join('\n'),
128+
options: [{maximum: 2}],
129+
errors: [{message: 'Prop `baz` must be placed on a new line'}],
130+
parserOptions: parserOptions
131+
}, {
132+
code: [
133+
'<App foo={{',
134+
'}} {...rest} />'
135+
].join('\n'),
136+
errors: [{message: 'Prop `rest` must be placed on a new line'}],
137+
parserOptions: parserOptions
138+
}, {
139+
code: [
140+
'<App {',
141+
' ...this.props',
142+
'} bar />'
143+
].join('\n'),
144+
errors: [{message: 'Prop `bar` must be placed on a new line'}],
145+
parserOptions: parserOptions
146+
}, {
147+
code: [
148+
'<App {',
149+
' ...this.props',
150+
'} {',
151+
' ...rest',
152+
'} />'
153+
].join('\n'),
154+
errors: [{message: 'Prop `rest` must be placed on a new line'}],
155+
parserOptions: parserOptions
112156
}, {
113157
code: [
114158
'<App',

0 commit comments

Comments
 (0)