babel-plugin-declarative-logging

1.0.3 • Public • Published

babel-plugin-declarative-logging

A Babel plugin that transform labels into class/object method calls

/**
 * labels inside functions won't be transformed
 */
function f () {
  log: "hehe", 13, Math.PI
}

/**
 * only labels inside class method and object method wil be transformed into method call
 */

class Log {
  log (...args) {
    console.log(...args)
  }
}

class A extends Log{
  m () {
    // last decorative underscore will be removed
    __log: 1, 2, __
  }
}

const B = {
  m () {
    // object literal should be wrapped with parenthesis
    __warn: ({name:"a"}), __;
  },
  warn (...args) {
    console.warn(...args);
  }
}

will be transformed into

/**
 * labels inside functions won't be transformed
 */
function f() {
  log: "hehe", 13, Math.PI;
}
/**
 * only labels inside class method and object method wil be transformed into method call
 */


class Log {
  log(...args) {
    console.log(...args);
  }

}

class A extends Log {
  m() {
    // last decorative underscore will be removed
    this.log(1, 2);
  }

}

const B = {
  m() {
    // object literal should be wrapped with parenthesis
    this.warn({
      name: "a"
    });
  },

  warn(...args) {
    console.warn(...args);
  }

};

Readme

Keywords

none

Package Sidebar

Install

npm i babel-plugin-declarative-logging

Weekly Downloads

0

Version

1.0.3

License

MIT

Unpacked Size

4.32 kB

Total Files

5

Last publish

Collaborators

  • aztack