Created
April 20, 2021 05:50
-
-
Save r17x/e6ea37fc0f5ae791988b509b5d1f09e2 to your computer and use it in GitHub Desktop.
[Metaprogramming] Basic with javscript - Remove Console.log code
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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