Skip to content

Instantly share code, notes, and snippets.

@r17x
Created April 20, 2021 05:50
Show Gist options
  • Save r17x/e6ea37fc0f5ae791988b509b5d1f09e2 to your computer and use it in GitHub Desktop.
Save r17x/e6ea37fc0f5ae791988b509b5d1f09e2 to your computer and use it in GitHub Desktop.
[Metaprogramming] Basic with javscript - Remove Console.log code
// remove-consoles.js
// run with command jscodeshift -t remove-consoles.js src/**/*.js
export default (fileInfo, api) => {
const j = api.jscodeshift;
return j(fileInfo.source)
.find(j.CallExpression, {
callee: {
type: 'MemberExpression',
object: { type: 'Identifier', name: 'console' },
},
}
)
.remove()
.toSource();
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment