Automated porting of mithril@0.2 code to mithril@1.0.
> 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
These transforms are pretty safe and unlikely to have many false positives.
- Replace
m.component()withm() - Rename
controller️ tooninit - Rename
m.route.modetom.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
optionswithvnode.attrs - Add
xlinknamespacing to<svg> - Replace
m.syncwithPromise.all - Remove
m.startComputation/m.endComputation - Replace
m.route.build/parseQueryStringwithm.build/parseQueryString
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
configwithoninit/onupdate - Rewrite
view(ctrl, options)asview(vnode)
There are certain classes of changes that are impossible to automatically convert.