Skip to content

Commit 622470f

Browse files
Update sort-prop-types.js
1 parent fa90fe5 commit 622470f

File tree

1 file changed

+62
-0
lines changed

1 file changed

+62
-0
lines changed

tests/lib/rules/sort-prop-types.js

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -382,6 +382,36 @@ ruleTester.run('sort-prop-types', rule, {
382382
options: [{
383383
sortShapeProp: true
384384
}]
385+
}, {
386+
code: `
387+
class Component extends React.Component {
388+
render() {
389+
return <div />;
390+
}
391+
}
392+
Component.propTypes = {
393+
a: PropTypes.any,
394+
z: PropTypes.any,
395+
};
396+
`,
397+
options: [{
398+
noSortAlphabetically: true
399+
}]
400+
}, {
401+
code: `
402+
class Component extends React.Component {
403+
render() {
404+
return <div />;
405+
}
406+
}
407+
Component.propTypes = {
408+
z: PropTypes.any,
409+
a: PropTypes.any,
410+
};
411+
`,
412+
options: [{
413+
noSortAlphabetically: true
414+
}]
385415
}],
386416

387417
invalid: [{
@@ -1471,5 +1501,37 @@ ruleTester.run('sort-prop-types', rule, {
14711501
}
14721502
}
14731503
`
1504+
}, {
1505+
code: [
1506+
'var First = createReactClass({',
1507+
' propTypes: {',
1508+
' z: PropTypes.string,',
1509+
' a: PropTypes.any',
1510+
' },',
1511+
' render: function() {',
1512+
' return <div />;',
1513+
' }',
1514+
'});'
1515+
].join('\n'),
1516+
options: [{
1517+
noSortAlphabetically: false
1518+
}],
1519+
errors: [{
1520+
message: ERROR_MESSAGE,
1521+
line: 4,
1522+
column: 5,
1523+
type: 'Property'
1524+
}],
1525+
output: [
1526+
'var First = createReactClass({',
1527+
' propTypes: {',
1528+
' a: PropTypes.any,',
1529+
' z: PropTypes.string',
1530+
' },',
1531+
' render: function() {',
1532+
' return <div />;',
1533+
' }',
1534+
'});'
1535+
].join('\n')
14741536
}]
14751537
});

0 commit comments

Comments
 (0)