Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kgrz/babel-plugin-transform-console-log-variable-names
https://github.com/kgrz/babel-plugin-transform-console-log-variable-names
babel-plugin javascript
Last synced: about 1 month ago
JSON representation
- Host: GitHub
- URL: https://github.com/kgrz/babel-plugin-transform-console-log-variable-names
- Owner: kgrz
- Created: 2017-10-08T16:03:25.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2017-10-12T04:38:50.000Z (about 7 years ago)
- Last Synced: 2024-10-31T04:20:46.853Z (2 months ago)
- Topics: babel-plugin, javascript
- Language: JavaScript
- Size: 43.9 KB
- Stars: 14
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
babel-plugin-transform-console-log-variable-names
-------------------------------------------------__WARNING: Very very alpha code quality__
Everytime I try to `console.log` a variable's value, I forget to label
the variable and so the logged statements become unuseful and confusing,
especially when used inside a loop—case in point: React's `render`
function, or `componentWillReceiveProps`.This plugin transforms `console.log` statements that have just variable
labels as arguments and prepends a string that specifies what those
labels are. For example, for the following statements:```javascript
const a = 12;
const b = 13;
const c = 59;console.log(a);
console.log(a, b);
console.log(a, b, c);
```The output would look something like:
```
a: 12
a, b: 12 13
a, b, c: 12, 13, 59
```Checkout another plugin around `console.log` usage I wrote: https://github.com/kgrz/babel-plugin-console-groupify
Usage
-----Install the module with:
```
npm i -D babel-plugin-transform-console-log-variable-names
```Include it in your babel configuration either via `.babelrc` or webpack.
Here's a `.babelrc` example:```json
{
"presets": [...],
"plugins": [
"transform-console-log-variable-names"
]
}
```