Skip to content

Commit

Permalink
Added first codemod (for renamed components)
Browse files Browse the repository at this point in the history
  • Loading branch information
bvaughn committed Sep 14, 2016
1 parent a0fa887 commit 5e7f11f
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Upgrade instructions and [jscodeshift](https://github.com/facebook/jscodeshift)

To run a code mod, check out react-virtualized (or download the codemod) and then...
```
jscodeshift -t /path/to/react-virtualized/codemods/7-to-8/TODO.js source
jscodeshift -t /path/to/react-virtualized/codemods/7-to-8/rename-components.js source
```

##### 7.24.1
Expand Down
19 changes: 19 additions & 0 deletions codemods/7-to-8/rename-components.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
const renameMap = {
FlexColumn: 'Column',
FlexTable: 'Table',
VirtualScroll: 'List'
}

module.exports = function transformer (file, api) {
const j = api.jscodeshift

return j(file.source)
.find(j.Identifier)
.filter(
identifier => !!renameMap[identifier.value.name]
)
.replaceWith(
identifier => j.identifier(renameMap[identifier.node.name])
)
.toSource()
}

0 comments on commit 5e7f11f

Please sign in to comment.