0.0.1 • Published 3 years ago
moment-to-dayjs-codemod v0.0.1
moment-to-dayjs-codemod
A jscodeshift tranformer for migrating moment to dayjs.
How to use
$ npm install -g jscodeshift
$ git clone https://github.com/yanaemon/moment-to-dayjs-codemod.git
$ jscodeshift -t transform.ts --parser tsx path/to/file.ts
Supported dayjs plugins
Warning
This lib cannot detect and don't replace below case. Please check whether there is no such a case.
destructive use
Because moment.js is mutable but dayjs is immutable.
ex.
for (const d = moment(); d.add(1, 'date'); d++) {
console.log(d.toDate());
}
variable assign
ex.
const d = moment();
// error unless you use objectSupport plugin
console.log(d.add({ date: 1 }).toDate());
I recommend to use ObjectSupport plugin
Test
$ yarn jest
0.0.1
3 years ago