babel-plugin-simple-logger
Special thanks to Michael Jungo for helping me put the first version together.
This Babel plugin looks for the string literal "log"
after the opening bracket of a function and replaces it with console.log(<function name>, <arg1>, <arg2>, etc...)
.
const add = { 'log' return a + b} // becomes... const add = { console return a + b}
Installation & Usage
Install the package
yarn add babel-plugin-simple-logger --dev
Incorporate the plugin
// .babelrc..."env": "development": "presets": "react" "env" "stage-0" "plugins": "simple-logger" ...
Test it out
{ 'log' return `Hello, !`} // logs... greeter "Gus"
Note: Arrow functions with implicit returns (e.g. (a, b) => a + b
) aren't candidates for logging with this plugin's syntax.