moment2dayjs

0.0.1 • Public • Published

moment2dayjs

https://github.com/yanaemon/moment-to-dayjs-codemod

inspired by moment-dayjs-codemod

A collection of codemods for migrating from moment.js to day.js

使用@typescript-eslint/parser()处理jsx|tsx,其遵循estree标准, typescript并不遵循estree规范, 而@babel/parser会将注释解析成node导致问题

Usage

Config

  • strict:
    • true -> replace method only the caller is moment(...),
    • false -> replace method as the method is belong to moment

Feature

  • replace moment to dayjs latest version in package.json
  • work in js|ts|jsx|tsx
  • api use transform
  • ts type transform
    • import type
    • asset type
    • 泛型

Code Transform

  • All listed in You-Dont-Need-Momentjs
  • import / require
  • mutable to immutable
  • api transform
    • moment() -> dayjs()
    • moment.isMoment() -> dayjs.isDayjs
  • ts type transform
    • import type -Moment type asset

Installation

  • clone the repo
  • change into the repo directory
  • pnpm i

Running tests

  • yarn test

References

Package Sidebar

Install

npm i moment2dayjs

Weekly Downloads

0

Version

0.0.1

License

MIT

Unpacked Size

78.3 kB

Total Files

42

Last publish

Collaborators

  • cheapcoder