babel-plugin-transform-property-cases
Babel plugin to transform properties into different cases.
Installation
$ yarn add -D babel-plugin-transform-property-cases
Usage
Specify which object property names should be converted to different cases by providing arrays under the following keys in the plugin config:
camelCase
kebab-case
param-case
PascalCase
snake_case
E.g.
would convert:
const o = "ultra calm": "lake" semi_calm: "horse";
into:
const o = ultraCalm: "lake" semiCalm: "horse";
Property Collections
Also available are property collections for which you can speficy global case-change behaviour. Currently only allCss
is supported, converting any standard css property name according to the specified source
and/or target
subkeys.
E.g.
Would convert any margin_top
poperty to margin-top
.
Would convert margin-top
to MarginTop
.
And
Would convert MarginTop
to marginTop
.
Example
Input file:
const yaDa = 3; const thing = blaBla: 7 yaDa paddingBottom: "1em"; { stuffblaBla += 2;} const meal = TotalSoup: "munster _vs_ cheese": "basel-Craft": "yaDa" ;
.babelrc
:
Output:
const yaDa = 3; const thing = "bla-bla": 7 "ya-da": yaDa "padding-bottom": "1em"; { stuff"bla-bla" += 2;} const meal = totalSoup: MunsterVsCheese: basel_craft: "yaDa" ;
License
This plugin is licensed under the MIT license. See LICENSE.
Thanks
This plugin relies heavily on: