diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index fb39fc3..e445379 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -10,7 +10,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - node: [12, 14, 16] + node: [12, 14, 16, 18, 20, 22] steps: - uses: actions/checkout@v1 - uses: actions/setup-node@v1 diff --git a/fixtures/issue-289.js b/fixtures/issue-289.js new file mode 100644 index 0000000..524961a --- /dev/null +++ b/fixtures/issue-289.js @@ -0,0 +1,4 @@ +for (let f; ; ) { + f = "0"; + () => (0 ? 1 : parseInt(f)); +} diff --git a/package.json b/package.json index 2b58513..6519163 100644 --- a/package.json +++ b/package.json @@ -16,10 +16,11 @@ "test-exclude": "^6.0.0" }, "devDependencies": { - "@babel/cli": "^7.7.5", - "@babel/core": "^7.7.5", - "@babel/plugin-transform-modules-commonjs": "^7.7.5", - "@babel/register": "^7.7.4", + "@babel/cli": "^7.24.1", + "@babel/core": "^7.24.1", + "@babel/plugin-transform-block-scoping": "^7.24.1", + "@babel/plugin-transform-modules-commonjs": "^7.24.1", + "@babel/register": "^7.23.7", "chai": "^4.2.0", "coveralls": "^3.0.9", "cross-env": "^6.0.3", diff --git a/src/index.js b/src/index.js index cb56fe9..56b636a 100644 --- a/src/index.js +++ b/src/index.js @@ -128,6 +128,7 @@ export default declare(api => { inputSourceMap }) this.__dv__.enter(path) + path.scope.crawl() }, exit (path) { if (!this.__dv__) { diff --git a/test/babel-plugin-istanbul.js b/test/babel-plugin-istanbul.js index ae22239..86d363e 100644 --- a/test/babel-plugin-istanbul.js +++ b/test/babel-plugin-istanbul.js @@ -327,5 +327,20 @@ describe('babel-plugin-istanbul', function () { result.code.should.match(/_path.*\.resolve\)\(_path\)/) result.code.should.not.match(/_path\.resolve\)\(_path\)/) }) + + // regression test for https://github.com/istanbuljs/babel-plugin-istanbul/issues/289 + it('should instrument: for (let f; ; ) { ...', function () { + var result = babel.transformFileSync('./fixtures/issue-289.js', { + babelrc: false, + configFile: false, + plugins: [ + '@babel/plugin-transform-block-scoping', + [makeVisitor, { + include: ['fixtures/issue-289.js'] + }] + ] + }) + console.log(result) + }) }) })