Skip to content

Commit

Permalink
Revert "fix: Ensure correct scope references after traversal (#192)"
Browse files Browse the repository at this point in the history
This reverts commit 201a933.
  • Loading branch information
coreyfarrell committed Apr 23, 2019
1 parent 1a274e2 commit cf748dc
Show file tree
Hide file tree
Showing 5 changed files with 0 additions and 76 deletions.
2 changes: 0 additions & 2 deletions fixtures/with-changed-scope.js

This file was deleted.

19 changes: 0 additions & 19 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion package.json
Expand Up @@ -18,7 +18,6 @@
"@babel/core": "^7.4.3",
"@babel/preset-env": "^7.4.3",
"@babel/register": "^7.4.0",
"babel-plugin-lodash": "^3.3.4",
"chai": "^4.2.0",
"coveralls": "^3.0.3",
"cross-env": "^5.2.0",
Expand Down
3 changes: 0 additions & 3 deletions src/index.js
Expand Up @@ -70,9 +70,6 @@ function makeVisitor ({ types: t }) {
inputSourceMap
})
this.__dv__.enter(path)
// Istanbul visitor may replace Identifiers and require re-crawling
// scope before continuing with other babel plugins.
path.scope.crawl()
},
exit (path) {
if (!this.__dv__) {
Expand Down
51 changes: 0 additions & 51 deletions test/babel-plugin-istanbul.js
Expand Up @@ -171,55 +171,4 @@ describe('babel-plugin-istanbul', function () {
resultAfter.code.should.match(/statementMap/)
})
})

describe('should leave scope with correct references', function () {
it('leaves scope references as Identifiers', function () {
// This is a unit test which inspects the root cause of the problem:
// scope references that are replaced to no longer be Identifiers
babel.transformFileSync('./fixtures/with-changed-scope.js', {
babelrc: false,
configFile: false,
plugins: [
[makeVisitor({ types: babel.types }), {
include: ['fixtures/with-changed-scope.js']
}],
function testScope (t) {
return {
visitor: {
ImportSpecifier (path) {
const fileScope = path.hub.file.scope
const localBinding = fileScope.getBinding(path.node.local.name)
for (const localReference of localBinding.referencePaths) {
localReference.type.should.equal('Identifier')
}
}
}
}
}
]
})
})

it('creates valid syntax with other transforming plugins', function () {
// This is a minimal end-to-end test which illustrates how scope
// reference alteration impacts the assumptions of other plugins
const result = babel.transformFileSync(
'./fixtures/with-changed-scope.js', {
babelrc: false,
configFile: false,
plugins: [
[makeVisitor({ types: babel.types }), {
include: ['fixtures/with-changed-scope.js']
}],
'babel-plugin-lodash'
]
})

function testSyntaxError () {
babel.parse(result.code)
}

testSyntaxError.should.not.throw()
})
})
})

0 comments on commit cf748dc

Please sign in to comment.