change-case
This parser helps you change the case of names or modes over a SDTF graph.
Interface
interface parser {
name: 'change-case';
options: {
change?: 'names' | 'modes';
toCase:
| 'camelCase'
| 'capitalCase'
| 'constantCase'
| 'kebabCase'
| 'noCase'
| 'pascalCase'
| 'pascalSnakeCase'
| 'pathCase'
| 'sentenceCase'
| 'snakeCase'
| 'trainCase';
applyTo:
| { collection: string | true }
| { group: string | true }
| { token: string | true }
| SDTFQuery;
};
}Options
change
false
'names'
Change the names or the modes of the selected items.
toCase
required
The case transformation to apply. Actual transform is done by the change-case package.
applyTo
required
The selection where to apply the transformation.
collection, group, token take a Regex string or true to select anything of the kind.
An SDTFQuery can be used for advance use cases.
Basic usage
This example helps you transform in kebabCase the name all collections, groups, tokens and modes. Use this example if you want to generate CSS Custom properties with the to-css-custom-properties parser.
We change the case of the token names and the modes to kebabCase. We applyTo the collection level so we transform in kebabCase:
the collection names
the group names
the token names
the mode names
We eventually generate our transformed SDTF graph in a JSON file thanks to the to-sdtf parser.
Last updated
Was this helpful?