From ebcdea5b540be194da7e9127396670ab7bfc3cd2 Mon Sep 17 00:00:00 2001 From: Mark Dalgleish Date: Tue, 8 Jan 2019 16:00:28 +1100 Subject: [PATCH 1/2] feat: Sort types alphabetically --- index.js | 1 + .../__snapshots__/emit-declaration.test.js.snap | 4 ++-- test/verify-valid-declaration/index.css | 4 ++++ test/verify-valid-declaration/index.css.d.ts | 3 ++- 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/index.js b/index.js index dde1400..4480064 100644 --- a/index.js +++ b/index.js @@ -22,6 +22,7 @@ const getTypeMismatchError = ({ filename, expected, actual }) => { const cssModuleToNamedExports = cssModuleKeys => { return cssModuleKeys .map(key => `export const ${key}: string;`) + .sort() .join('\n') .concat('\n'); }; diff --git a/test/emit-declaration/__snapshots__/emit-declaration.test.js.snap b/test/emit-declaration/__snapshots__/emit-declaration.test.js.snap index 41d7c7d..ffd40cc 100644 --- a/test/emit-declaration/__snapshots__/emit-declaration.test.js.snap +++ b/test/emit-declaration/__snapshots__/emit-declaration.test.js.snap @@ -3,8 +3,8 @@ exports[`Can emit valid declaration 1`] = ` "// This file is automatically generated. // Please do not change this file! -export const validClass: string; -export const someClass: string; export const otherClass: string; +export const someClass: string; +export const validClass: string; " `; diff --git a/test/verify-valid-declaration/index.css b/test/verify-valid-declaration/index.css index ff76698..8bdba1f 100644 --- a/test/verify-valid-declaration/index.css +++ b/test/verify-valid-declaration/index.css @@ -1,3 +1,7 @@ +.validClass { + position: relative; +} + .someClass { position: relative; } diff --git a/test/verify-valid-declaration/index.css.d.ts b/test/verify-valid-declaration/index.css.d.ts index 0f50198..3114b85 100644 --- a/test/verify-valid-declaration/index.css.d.ts +++ b/test/verify-valid-declaration/index.css.d.ts @@ -1,4 +1,5 @@ // This file is automatically generated. // Please do not change this file! -export const someClass: string; export const otherClass: string; +export const someClass: string; +export const validClass: string; From 5dc1d4831ee92ab27ae78ab77366987708edb473 Mon Sep 17 00:00:00 2001 From: Mark Dalgleish Date: Wed, 9 Jan 2019 08:39:41 +1100 Subject: [PATCH 2/2] refactor: Sort classes before generating types --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index 4480064..ff18558 100644 --- a/index.js +++ b/index.js @@ -21,8 +21,8 @@ const getTypeMismatchError = ({ filename, expected, actual }) => { const cssModuleToNamedExports = cssModuleKeys => { return cssModuleKeys - .map(key => `export const ${key}: string;`) .sort() + .map(key => `export const ${key}: string;`) .join('\n') .concat('\n'); };