From 52e77618d985ce49f6195f1b7f2a1e3dc5c4631f Mon Sep 17 00:00:00 2001 From: AlbertLucianto Date: Wed, 20 Feb 2019 15:40:19 +0800 Subject: [PATCH] refactor: using default handleMissingStyleName from schema --- src/getClassName.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/getClassName.js b/src/getClassName.js index 87e29cd..c445438 100644 --- a/src/getClassName.js +++ b/src/getClassName.js @@ -5,13 +5,12 @@ import type { StyleModuleImportMapType, HandleMissingStyleNameOptionType } from './types'; +import optionsDefaults from './schemas/optionsDefaults'; type OptionsType = {| handleMissingStyleName: HandleMissingStyleNameOptionType |}; -const DEFAULT_HANDLE_MISSING_STYLENAME_OPTION = 'throw'; - const isNamespacedStyleName = (styleName: string): boolean => { return styleName.indexOf('.') !== -1; }; @@ -28,7 +27,7 @@ const getClassNameForNamespacedStyleName = ( const importName = styleNameParts[0]; const moduleName = styleNameParts[1]; const handleMissingStyleName = handleMissingStyleNameOption || - DEFAULT_HANDLE_MISSING_STYLENAME_OPTION; + optionsDefaults.handleMissingStyleName; if (!moduleName) { if (handleMissingStyleName === 'throw') { @@ -70,7 +69,7 @@ export default (styleNameValue: string, styleModuleImportMap: StyleModuleImportM const styleModuleImportMapKeys = Object.keys(styleModuleImportMap); const handleMissingStyleName = options && options.handleMissingStyleName || - DEFAULT_HANDLE_MISSING_STYLENAME_OPTION; + optionsDefaults.handleMissingStyleName; if (!styleNameValue) { return '';