Open threepointone opened 4 years ago
Hey @threepointone, I wanted to share CodeshiftCommunity, which could help side-step some of these issues.
It allows you to publish codemods as packages to NPM, the CLI will pull it down and run it in an isolated context.
$ npx @codeshift/cli -p react#error-boundaries path/to/src
Meaning:
Codeshift allows developers to publish codemods as their own NPM packages or as part of an existing NPM package. We provide a standardized CLI tool that can download and run the latest codemods from any location. This approach has the added benefit of allowing codemods to be published with dependencies, which is not currently possible with most JSCodeshift CLI implementations.
To integrate with this repo, you just need to add a codeshift.config.js
.
module.exports = {
maintainers: ['threepointone'],
targets: ['react'],
presets: {
'React-DOM-to-react-dom-factories': require.resolve('./transforms/React-DOM-to-react-dom-factories.js'),
'React-PropTypes-to-prop-types': require.resolve('./transforms/React-PropTypes-to-prop-types.js'),
'ReactNative-View-propTypes': require.resolve('./transforms/ReactNative-View-propTypes.js'),
'create-element-to-jsx': require.resolve('./transforms/create-element-to-jsx.js'),
'error-boundaries': require.resolve('./transforms/error-boundaries.js'),
...
},
};
Obviously, no pressure here, thought it might help in the future 👍
This would avoid issues like https://github.com/reactjs/react-codemod/issues/249