From cf38cd5d68e4d92d16c9d3a21b038a049e4c7bee Mon Sep 17 00:00:00 2001 From: Armand Abric Date: Sat, 5 Jan 2019 12:16:10 +0100 Subject: [PATCH] fix(formatting): Make the props "key" and "ref" order predictibale --- 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; }