Skip to content

Commit

Permalink
Add additional failure test
Browse files Browse the repository at this point in the history
  • Loading branch information
chrislaskey committed Jan 12, 2016
1 parent 4ab1b3e commit ce330d8
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 3 deletions.
4 changes: 2 additions & 2 deletions lib/rules/jsx-sort-prop-types.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ module.exports = function(context) {
}
if (!previousIsRequired && currentIsRequired) {
// Encountered a non-required prop after a required prop
context.report(prev, 'Required prop types must be listed before all other prop types');
return prev;
context.report(curr, 'Required prop types must be listed before all other prop types');
return curr;
}
}

Expand Down
25 changes: 24 additions & 1 deletion tests/lib/rules/jsx-sort-prop-types.js
Original file line number Diff line number Diff line change
Expand Up @@ -534,6 +534,29 @@ ruleTester.run('jsx-sort-prop-types', rule, {
column: 5,
type: 'Property'
}]
}, {
code: [
'var First = React.createClass({',
' propTypes: {',
' fooRequired: React.PropTypes.string.isRequired,',
' barRequired: React.PropTypes.string.isRequired,',
' a: React.PropTypes.any',
' },',
' render: function() {',
' return <div />;',
' }',
'});'
].join('\n'),
options: [{
requiredFirst: true
}],
parserOptions: parserOptions,
errors: [{
message: ERROR_MESSAGE,
line: 4,
column: 5,
type: 'Property'
}]
}, {
code: [
'var First = React.createClass({',
Expand All @@ -553,7 +576,7 @@ ruleTester.run('jsx-sort-prop-types', rule, {
parserOptions: parserOptions,
errors: [{
message: 'Required prop types must be listed before all other prop types',
line: 3,
line: 4,
column: 5,
type: 'Property'
}]
Expand Down

0 comments on commit ce330d8

Please sign in to comment.