Debian Codegraph @

packages/babel-plugin-transform-block-scoping/test/fixtures/exec/scope-bindings.js

raw symbols SCIP
1 var code = `var foo = 1;
2 if (x) {
3 const bar = 1;
4 }`;
5
6 var expected = `var foo = 1;
7 if (x) {
8 var bar = 1;
9 }`;
10
11 var innerScope = true;
12 return transformAsync(code, {
13 configFile: false,
14 plugins: opts.plugins.concat([
15 function ({ types: t }) {
16 return {
17 visitor: {
18 Scope: {
19 exit: function (path) {
20 if (innerScope) {
21 expect(Object.keys(path.scope.bindings)).toHaveLength(0);
22 innerScope = false;
23 return;
24 }
25
26 expect(Object.keys(path.scope.bindings)).toHaveLength(2);
27 },
28 },
29 },
30 };
31 },
32 ]),
33 }).then(res => {
34 expect(res.code).toBe(expected);
35 expect(innerScope).toBe(false);
36 });