-
Notifications
You must be signed in to change notification settings - Fork 135
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: problems with other plugins' path replacement (#64)
* Add a test case for the issue * Add changes related to failed linting before * Fix the original issue with path replacement
- Loading branch information
Showing
7 changed files
with
78 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
const types = require('babel-types') | ||
|
||
const problematicVisitor = { | ||
VariableDeclarator: { | ||
enter(path) { | ||
const initPath = path.get('init') | ||
|
||
initPath.replaceWith( | ||
types.sequenceExpression([ | ||
types.stringLiteral('foobar'), | ||
initPath.node, | ||
]), | ||
) | ||
}, | ||
}, | ||
} | ||
|
||
module.exports = () => ({ | ||
visitor: { | ||
Program: { | ||
enter(path) { | ||
path.traverse(problematicVisitor) | ||
}, | ||
}, | ||
}, | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"plugins": ["path-replace"] | ||
} |
5 changes: 5 additions & 0 deletions
5
src/__tests__/fixtures/path-replace-issue/variable-assignment.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import myEval from '../eval.macro' | ||
|
||
const result = myEval`+('4' + '2')` | ||
|
||
global.result = result |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters