Skip to content

Commit

Permalink
fix: container is falsy error with block scoping transform (#291)
Browse files Browse the repository at this point in the history
  • Loading branch information
jedwards1211 authored Jul 5, 2024
1 parent d58c92a commit 8e76919
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions fixtures/issue-289.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
for (let f; ; ) {
f = "0";
() => (0 ? 1 : parseInt(f));
}
9 changes: 5 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
1 change: 1 addition & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ export default declare(api => {
inputSourceMap
})
this.__dv__.enter(path)
path.scope.crawl()
},
exit (path) {
if (!this.__dv__) {
Expand Down
15 changes: 15 additions & 0 deletions test/babel-plugin-istanbul.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
})
})

0 comments on commit 8e76919

Please sign in to comment.