Babel Plugin Console Groupify Versions Save

A small babel plugin that wraps console.logs inside a console.group with surrounding function name

v0.0.9

5 years ago

Before this change, code like the following would output a nested group titles with empty log statement (since it won't actually get hit).

    function something() {
        if (somecondition) return null;
        console.log('wut');
    }

    for (var i = 0; i < 10; ++i) {
        something();
    }

Compiled output:

    function something() {
                console.group('something');
                return null;
                console.log('wut');
                console.groupEnd();
    }

    for (var i = 0; i < 10; ++i) {
                something();
    }

When executed:

    something
      something
        something
          something
                something
                  something
                        something
                          something
                                something
                                  something

This fix adds an extra check for this state.