diff --git a/lib/rules/jsx-sort-props.js b/lib/rules/jsx-sort-props.js
index ea7aa938fc..408321b642 100755
--- a/lib/rules/jsx-sort-props.js
+++ b/lib/rules/jsx-sort-props.js
@@ -15,7 +15,11 @@ module.exports = function(context) {
return {
JSXOpeningElement: function(node) {
- node.attributes.reduce(function(memo, decl) {
+ var attributes = node.attributes.filter(function(decl) {
+ return decl.type === 'JSXAttribute';
+ });
+
+ attributes.reduce(function(memo, decl) {
var lastPropName = memo.name.name;
var currenPropName = decl.name.name;
@@ -30,7 +34,7 @@ module.exports = function(context) {
}
return decl;
- }, node.attributes[0]);
+ }, attributes[0]);
}
};
};
diff --git a/tests/lib/rules/jsx-sort-props.js b/tests/lib/rules/jsx-sort-props.js
index 69ff0b41c9..bcc30ed3f0 100755
--- a/tests/lib/rules/jsx-sort-props.js
+++ b/tests/lib/rules/jsx-sort-props.js
@@ -32,8 +32,11 @@ var features = {
eslintTester.addRuleTest('lib/rules/jsx-sort-props', {
valid: [
{code: ';', ecmaFeatures: features},
+ {code: ';', ecmaFeatures: features},
{code: ';', ecmaFeatures: features},
+ {code: ';', ecmaFeatures: features},
{code: ';', ecmaFeatures: features},
+ {code: ';', ecmaFeatures: features},
{code: ';', ecmaFeatures: features},
{code: ';', args: ignoreCaseArgs, ecmaFeatures: features},
{code: ';', args: ignoreCaseArgs, ecmaFeatures: features},
@@ -41,9 +44,11 @@ eslintTester.addRuleTest('lib/rules/jsx-sort-props', {
],
invalid: [
{code: ';', errors: [expectedError], ecmaFeatures: features},
+ {code: ';', errors: [expectedError], ecmaFeatures: features},
{code: ';', errors: [expectedError], ecmaFeatures: features},
{code: ';', args: ignoreCaseArgs, errors: [expectedError], ecmaFeatures: features},
{code: ';', args: ignoreCaseArgs, errors: [expectedError], ecmaFeatures: features},
- {code: ';', errors: 2, ecmaFeatures: features}
+ {code: ';', errors: 2, ecmaFeatures: features},
+ {code: ';', errors: 2, ecmaFeatures: features}
]
});