Skip to content

@codemod-utils/ember

Utilities for Ember

What is it? ​

@codemod-utils/ember provides methods that help you write codemods for Ember projects.

API ​

camelize ​

Converts an entity name to camel case. Used for naming the function that is associated with the entity.

ts
/**
 * @param entityName
 *
 * The name of an entity (made up of lowercase letters, hyphen,
 * and forward slash).
 *
 * @return
 *
 * The name in camel case.
 */
function camelize(entityName: string): string;
ts
import { camelize } from '@codemod-utils/ember';

const output = camelize('ui/form/generate-error-message');

// 'uiFormGenerateErrorMessage'

doubleColonize ​

Converts an entity name to double colon (::) case. Used for writing the angle bracket syntax or the signature for a component.

ts
/**
 * @param entityName
 *
 * The name of an entity (made up of lowercase letters, hyphen,
 * and forward slash).
 *
 * @return
 *
 * The name in double colon case.
 */
function doubleColonize(entityName: string): string;
ts
import { doubleColonize } from '@codemod-utils/ember';

const output = doubleColonize('ui/form/input');

// 'Ui::Form::Input'

invertDoubleColonize ​

Converts a double-colonized name back to an entity name.

ts
/**
 * @param name
 *
 * An entity's name in double colon case.
 *
 * @return
 *
 * The name of an entity (made up of lowercase letters, hyphen,
 * and forward slash).
 */
function invertDoubleColonize(entityName: string): string;
ts
import { invertDoubleColonize } from '@codemod-utils/ember';

const output = invertDoubleColonize('Ui::Form::Input');

// 'ui/form/input'

pascalize ​

Converts an entity name to Pascal case. Used for naming the class that is associated with the entity.

ts
/**
 * @param entityName
 *
 * The name of an entity (made up of lowercase letters, hyphen,
 * and forward slash).
 *
 * @return
 *
 * The name in Pascal case.
 */
function pascalize(entityName: string): string;
ts
import { pascalize } from '@codemod-utils/ember';

const output = pascalize('ui/form/input');

// 'UiFormInput'