moment-to-dayjs-codemod

0.0.1 • Public • Published

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

Package Sidebar

Install

npm i moment-to-dayjs-codemod

Weekly Downloads

2

Version

0.0.1

License

MIT

Unpacked Size

43.9 kB

Total Files

39

Last publish

Collaborators

  • yanaemon