Skip to content

Commit

Permalink
Merge cd0ca8d into 752de70
Browse files Browse the repository at this point in the history
  • Loading branch information
VincentLanglet committed Mar 13, 2019
2 parents 752de70 + cd0ca8d commit 2792426
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/rules/jsx-sort-default-props.js
Expand Up @@ -96,7 +96,7 @@ module.exports = {
*/
function checkSorted(declarations) {
declarations.reduce((prev, curr, idx, decls) => {
if (/SpreadProperty$/.test(curr.type)) {
if (/Spread(?:Property|Element)$/.test(curr.type)) {
return decls[idx + 1];
}

Expand Down
19 changes: 19 additions & 0 deletions tests/lib/rules/jsx-sort-default-props.js
Expand Up @@ -326,6 +326,25 @@ ruleTester.run('jsx-sort-default-props', rule, {
'First.propTypes = propTypes;',
'First.defaultProps = defaultProps;'
].join('\n')
}, {
code: [
'const defaults = {',
' b: "b"',
'};',
'const First = (props) => <div />;',
'export const propTypes = {',
' a: PropTypes.string,',
' b: PropTypes.string,',
' z: PropTypes.string,',
'};',
'export const defaultProps = {',
' ...defaults,',
' a: "a",',
' z: "z",',
'};',
'First.propTypes = propTypes;',
'First.defaultProps = defaultProps;'
].join('\n')
}],

invalid: [{
Expand Down

0 comments on commit 2792426

Please sign in to comment.