- A tool for large-scale codebase refactors. In this case, it's a script that is run against the files you wish to change
- When regex/find and replace isn't enough. Needing the context of the surrounding code and its meaning
- How? Abstract Syntax Trees!
Converts factory-style React to React.createElement style. This can then be fed to react-codemod's create-element-to-jsx. Along the way, it'll also add a React import when needed and remove react-dom-factories imports.
Run using jscodeshift like so:
jscodeshift -t /path/to/factory-to-create-element.js /directory/to/transform/**/*.js
|# Your init script|
|# Atom will evaluate this file each time a new window is opened. It is run|
|# after packages are loaded/activated and after the previous editor state|
|# has been restored.|
|# An example hack to log to the console when each text editor is saved.|
|# atom.workspace.observeTextEditors (editor) ->|
|# editor.onDidSave ->|