From 38534639a106284fc5f9cd3b150bd5b364d43027 Mon Sep 17 00:00:00 2001 From: Armand Abric Date: Sat, 5 Jan 2019 12:25:29 +0100 Subject: [PATCH] fix(formatting): Make the props "key" and "ref" order predictibale (#340) --- src/formatter/propNameSorter.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/formatter/propNameSorter.js b/src/formatter/propNameSorter.js index 4a4394ee9..4cd026140 100644 --- a/src/formatter/propNameSorter.js +++ b/src/formatter/propNameSorter.js @@ -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; }