Skip to content

refactor: using default handleMissingStyleName from schema #229

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

Merged
merged 1 commit into from
Feb 20, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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