Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
$ jscodeshift -t renameDefaultStory.js **/*.story.js
export const defaultStory = () => <StatusDot />;
export const Default = () => <StatusDot />;
/**
* @param {import('@types/jscodeshift').FileInfo} fileInfo
* @param {import('@types/jscodeshift').API} api
*/
module.exports = function(fileInfo, api) {
return api
.jscodeshift(fileInfo.source)
.find(api.jscodeshift.VariableDeclarator, {
id: {
name: 'defaultStory'
}
})
.forEach(path => {
path.value.id.name = 'Default';
})
.toSource({ quote: 'single' });
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment