2 * @fileoverview Enforce props alphabetical sorting
3 * @author Ilya Volodin, Yannick Croissant
7 // ------------------------------------------------------------------------------
9 // ------------------------------------------------------------------------------
11 module.exports = function(context) {
13 var configuration = context.options[0] || {};
14 var ignoreCase = configuration.ignoreCase || false;
17 JSXOpeningElement: function(node) {
18 node.attributes.reduce(function(memo, decl, idx, attrs) {
19 if (decl.type === 'JSXSpreadAttribute') {
20 return attrs[idx + 1];
23 var lastPropName = memo.name.name;
24 var currenPropName = decl.name.name;
27 lastPropName = lastPropName.toLowerCase();
28 currenPropName = currenPropName.toLowerCase();
31 if (currenPropName < lastPropName) {
32 context.report(decl, 'Props should be sorted alphabetically');
37 }, node.attributes[0]);