Skip to content

Commit 3853463

Browse files
authored
fix(formatting): Make the props "key" and "ref" order predictibale (#340)
1 parent bfe9a9f commit 3853463

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/formatter/propNameSorter.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
11
/* @flow */
22

3+
const isKeyOrRefProps = (propName: string) => ['key', 'ref'].includes(propName);
4+
35
export default (sortProps: boolean) => (a: string, b: string): -1 | 0 | 1 => {
46
if (a === b) {
57
return 0;
68
}
79

8-
if (['key', 'ref'].includes(a)) {
10+
if (isKeyOrRefProps(a) && isKeyOrRefProps(b)) {
11+
return 1;
12+
} else if (isKeyOrRefProps(a)) {
913
return -1;
10-
} else if (['key', 'ref'].includes(b)) {
14+
} else if (isKeyOrRefProps(b)) {
1115
return 1;
1216
}
1317

0 commit comments

Comments
 (0)