1.0.4 • Published 8 years ago

babel-plugin-check-jsapi-in-es5 v1.0.4

Weekly downloads
3
License
ISC
Repository
github
Last release
8 years ago

babel-plugin-check-jsapi-in-es5

Installation

npm install babel-plugin-check-jsapi-in-es5 --save-dev

Why?

Check whether the use of non es5 js api and give you a warning or error. One case, js in mobile system can not support es5+ well, so I use this before commit.

Usage

babel.transformFileSync(path.join(src_fe_dir, check_file), {
    babelrc: false,
    compact: false,
    plugins: [
        ['check-is-es5',
        {
            log: 2
        }]
    ]
});

Options

log

  • 0: eigher error or warning can exit your code and throw error.
  • 1: only error can exit your code and throw error. (default)
  • 2: just warning.

CheckList

bind

var a = Array.prototype.findIndex.bind(c);
a(123); // error

call/apply

var a = Array.prototype.findIndex;
a.call(c, 123); // error

super scope reference

var a = [],
    b = Array.prototype,
    c,
    d = 'hah',
    e = Uint8Array();

c = a;
c = d;
c = e;

b.findIndex(); // error
c.findIndex(); // error
function cc() {
    return c.findIndex(123); // error
}