mithril-codemods
v3.5.2
Published
Transform [email protected] code into [email protected] using jscodeshift
Downloads
8
Readme
mithril-codemods
Automated porting of [email protected]
code to [email protected]
.
Usage
> npm i -g mithril-codemods
> mithril-codemods --help
Usage
$ mithril-codemods [<file|glob> ...]
Options
--unsafe, -u Use unsafe transforms
--apply, -a Apply transforms (instead of a dry run)
Examples
mithril-codemods **/*.js
mithril-codemods --apply **/*.js
mithril-codemods -ua some/specific/file.js
Transforms
Safe
These transforms are pretty safe and unlikely to have many false positives.
- Replace
m.component()
withm()
- Rename
controller
️ tooninit
- Rename
m.route.mode
tom.route.prefix()
and adjust args - Rename
m.route()
tom.route.get()
andm.route("route")
tom.route.set("route")
- Replace
config: m.route
️w️i️t️h️oncreate: m.route.link
- Wrap raw vnodes in
m.mount()
/m.route()
- Replace
options
withvnode.attrs
- Add
xlink
namespacing to<svg>
- Replace
m.sync
withPromise.all
- Remove
m.startComputation
/m.endComputation
- Replace
m.route.build/parseQueryString
withm.build/parseQueryString
⚠️️️ Unsafe ⚠️
These transform are usually fine, but not applied by default since they can have unfortunate side-effects.
- Convert
m.redraw.strategy("none")
toe.redraw = false
- Wrap unwrapped components
- Replace
config
withoninit
/onupdate
- Rewrite
view(ctrl, options)
asview(vnode)
Warnings
There are certain classes of changes that are impossible to automatically convert.