Skip to content

Commit 049d95e

Browse files
committed
[jsx-sort-props] Test reservedFirst/shorthandLast
Add tests, that surface the incorrect behavior of the combinations `reservedFirst` and `shorthandLast` for the `jsx-sort-props` rule.
1 parent b1f2b6f commit 049d95e

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

tests/lib/rules/jsx-sort-props.js

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,10 @@ const reservedFirstWithNoSortAlphabeticallyArgs = [{
8888
noSortAlphabetically: true,
8989
reservedFirst: true
9090
}];
91+
const reservedFirstWithShorthandLast = [{
92+
reservedFirst: true,
93+
shorthandLast: true
94+
}];
9195
const reservedFirstAsEmptyArrayArgs = [{
9296
reservedFirst: []
9397
}];
@@ -149,6 +153,10 @@ ruleTester.run('jsx-sort-props', rule, {
149153
{
150154
code: '<div ref="r" dangerouslySetInnerHTML={{__html: "EPR"}} key={0} children={<App />} b a c />',
151155
options: reservedFirstWithNoSortAlphabeticallyArgs
156+
},
157+
{
158+
code: '<App key="key" c="c" b />',
159+
options: reservedFirstWithShorthandLast
152160
}
153161
],
154162
invalid: [
@@ -230,6 +238,16 @@ ruleTester.run('jsx-sort-props', rule, {
230238
`,
231239
errors: 3
232240
},
241+
{
242+
code: '<App key="key" b c="c" />',
243+
errors: [expectedShorthandLastError],
244+
options: reservedFirstWithShorthandLast
245+
},
246+
{
247+
code: '<App ref="ref" key="key" isShorthand veryLastAttribute="yes" />',
248+
errors: [expectedError, expectedShorthandLastError],
249+
options: reservedFirstWithShorthandLast
250+
},
233251
{
234252
code: '<App a z onFoo onBar />;',
235253
errors: [expectedError],
@@ -293,7 +311,7 @@ ruleTester.run('jsx-sort-props', rule, {
293311
code: '<App dangerouslySetInnerHTML={{__html: "EPR"}} e key={2} b />',
294312
options: reservedFirstAsBooleanArgs,
295313
output: '<App key={2} b dangerouslySetInnerHTML={{__html: "EPR"}} e />',
296-
errors: [expectedReservedFirstError]
314+
errors: [expectedReservedFirstError, expectedError]
297315
},
298316
{
299317
code: '<App key={3} children={<App />} />',

0 commit comments

Comments
 (0)