Skip to content

refactor: using default handleMissingStyleName from schema #228

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 7 commits into from
7 changes: 3 additions & 4 deletions src/getClassName.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
Expand All @@ -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') {
Expand Down Expand Up @@ -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 '';
Expand Down