1.0.1 • Published 6 years ago

babel-plugin-transform-console-helper v1.0.1

Weekly downloads
2
License
MIT
Repository
github
Last release
6 years ago

babel-plugin-transform-console-helper

A babel plugin that adds the parent function to console statements, and the name of each variable before the value. My first attempt at creating a babel plugin.

example code

Installation & Usage

npm i -S babel-plugin-transform-console-helper

.babelrc

{
  "env": {
    "development": {
      "plugins": ["transform-console-helper"]
    }
  }
}

I only load it in development because I don't have any production log statements.

Example

console.log(a);

function onChange() {
  console.log(a, b, c);
}

// BECOMES

console.log('a', a);

function onChange() {
  console.log('onChange()', 'a', a, 'b', b, 'c', c);
}

Testing

Tests are written with Jest. Snapshot tests are really nice for this. They can be run like this:

npm test