This plugin throws a compile-time error on references to undeclared variables.
In
function foo() {}
foo();
bar();
Out
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
{
"plugins": ["undeclared-variables-check"]
}
babel --plugins undeclared-variables-check script.js
require("babel-core").transform("code", {
plugins: ["undeclared-variables-check"]
});