Skip to content

Commit

Permalink
fix(formatting): Make the props "key" and "ref" order predictibale (#340
Browse files Browse the repository at this point in the history
)
  • Loading branch information
armandabric committed Jan 5, 2019
1 parent bfe9a9f commit 3853463
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/formatter/propNameSorter.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
/* @flow */

const isKeyOrRefProps = (propName: string) => ['key', 'ref'].includes(propName);

export default (sortProps: boolean) => (a: string, b: string): -1 | 0 | 1 => {
if (a === b) {
return 0;
}

if (['key', 'ref'].includes(a)) {
if (isKeyOrRefProps(a) && isKeyOrRefProps(b)) {
return 1;
} else if (isKeyOrRefProps(a)) {
return -1;
} else if (['key', 'ref'].includes(b)) {
} else if (isKeyOrRefProps(b)) {
return 1;
}

Expand Down

0 comments on commit 3853463

Please sign in to comment.