Undeclared variables check

This plugin throws a compile-time error on references to undeclared variables.

示例

输入

function foo() {}
foo();
bar();

输出

ReferenceError: stdin: Line 3: Reference to undeclared variable "bar" - did you mean "foo"?
  1 | function foo() {}
  2 | foo();
> 3 | bar();
    | ^
  4 |

安装

npm install --save-dev babel-plugin-undeclared-variables-check

使用

通过 .babelrc (推荐)

.babelrc

{
  "plugins": ["undeclared-variables-check"]
}

通过 CLI

babel --plugins undeclared-variables-check script.js

通过 Node API

require("babel-core").transform("code", {
  plugins: ["undeclared-variables-check"]
});