rename dirname
This repository contains a collection of codemod scripts based for use with JSCodeshift that help update antd APIs.
antd
npm install -g jscodeshift
git clone https://github.com/ant-design/antd-codemod.git
https://github.com/ant-design/antd-codemod/archive/master.zip
npm install
jscodeshift -t <codemod-script> <path>
-d
-p
getFieldProps-to-getFieldDecorator
Replace deprecated getFieldProps with newer getFieldDecorator:
getFieldProps
getFieldDecorator
- <Input placeholder="text" {...getFieldProps('userName', { ... })} /> + {getFieldDecorator('userName', { ... })( + <Input placeholder="text" /> + )}
Popover-overlay-to-content
Popover[overlay] is removed, so we need to replace it with Popover[content]:
Popover[overlay]
Popover[content]
- <Popover overlay={...} /> + <Popover content={...} />
time-related-value-to-moment
Update value defaultValue and format of DatePicker TimePicker Calendar MonthPicker(not support RangePicker now):
value
defaultValue
format
DatePicker
TimePicker
Calendar
MonthPicker
RangePicker
+ import moment from 'moment'; <DatePicker - defaultValue="2016-11-24 00:00:00" + defaultValue={moment('2016-11-24 00:00:00', 'YYYY-MM-DD HH:mm:ss')} showTime - format="yyyy-MM-dd HH:mm:ss" + format="YYYY-MM-DD HH:mm:ss" />
GergorianCalendar-to-moment
Update GregorianCalendar’s APIs to moment’s APIs.
function disabledDate(date) { - console.log(date.getTime()); + console.log(date.valueOf()); }
MIT
antd-codemod
This repository contains a collection of codemod scripts based for use with JSCodeshift that help update
antdAPIs.Setup & Run
npm install -g jscodeshiftgit clone https://github.com/ant-design/antd-codemod.gitor download a zip file fromhttps://github.com/ant-design/antd-codemod/archive/master.zipnpm installin the antd-codemod directoryjscodeshift -t <codemod-script> <path>-doption for a dry-run and use-pto print the output for comparisonIncluded Scripts
1.x-2.x
getFieldProps-to-getFieldDecoratorReplace deprecated
getFieldPropswith newergetFieldDecorator:Popover-overlay-to-contentPopover[overlay]is removed, so we need to replace it withPopover[content]:time-related-value-to-momentUpdate
valuedefaultValueandformatofDatePickerTimePickerCalendarMonthPicker(not supportRangePickernow):GergorianCalendar-to-momentUpdate GregorianCalendar’s APIs to moment’s APIs.
License
MIT