@lg-tools/codemods
v0.0.2
Published
Codemods for LeafyGreen UI
Downloads
27
Keywords
Readme
Codemods
Installation
Yarn
yarn add @lg-tools/codemods
NPM
npm install @lg-tools/codemods
Usage
yarn lg codemod <codemod> <path> [...options]
Arguments
codemod
name of codemod, see available codemods below.
path
files or directory to transform
Options
--i or --ignore
Glob patterns to ignore
yarn lg codemod <codemode> <path> --ignore **/node_modules/** **/.next/**
--d or --dry
Dry run (no changes to files are made)
yarn lg codemod <codemode> <path> --dry
--p or --print
Print transformed files to stdout and changes are also made to files
yarn lg codemod <codemode> <path> --print
--f or --force
Bypass Git safety checks and forcibly run codemods.
yarn lg codemod <codemode> <path> --force
Codemods
NOTE: These codemods are for testing purposes only
consolidate-props
This codemod consolidates two props into one.
yarn lg codemod codemode-props <path>
E.g.
In this example, the disabled
props is merged into the state
prop.
Before:
<MyComponent disabled={true} state="valid" />
After:
<MyComponent state="disabled" />
rename-component-prop
This codemod renames a component prop
yarn lg codemod codemode-component-prop <path>
E.g.
In this example, prop
is renamed to newProp
.
Before:
<MyComponent prop="hey" />
After:
<MyComponent newProp="hey" />
update-component-prop-value
This codemod updates a prop value
yarn lg codemod codemode-component-prop-value <path>
E.g.
In this example, value
is updated to new prop value
.
Before:
<MyComponent prop="value" />
After:
<MyComponent prop="new prop value" />