UNPKG

781 BMarkdownView Raw
1# babel-plugin-undeclared-variables-check
2
3> This plugin throws a compile-time error on references to undeclared variables.
4
5## Example
6
7**In**
8
9```javascript
10function foo() {}
11foo();
12bar();
13```
14
15**Out**
16
17```
18ReferenceError: stdin: Line 3: Reference to undeclared variable "bar" - did you mean "foo"?
19 1 | function foo() {}
20 2 | foo();
21> 3 | bar();
22 | ^
23 4 |
24```
25
26## Installation
27
28```sh
29npm install --save-dev babel-plugin-undeclared-variables-check
30```
31
32## Usage
33
34### Via `.babelrc` (Recommended)
35
36**.babelrc**
37
38```json
39{
40 "plugins": ["undeclared-variables-check"]
41}
42```
43
44### Via CLI
45
46```sh
47babel --plugins undeclared-variables-check script.js
48```
49
50### Via Node API
51
52```javascript
53require("babel-core").transform("code", {
54 plugins: ["undeclared-variables-check"]
55});
56```