This file contains hidden or 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
| module.exports = function () { | |
| const SimpleVisitor = { | |
| StringLiteral(path, state) { | |
| if (path.node.value === "We'll never survive!") { | |
| path.node.value = "Nonsense. You're only saying that because no one ever has."; | |
| } | |
| }, | |
| }; | |
| return { visitor: SimpleVisitor }; |
This file contains hidden or 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
| module.exports = function ({ types: t }) { | |
| const GrandmaVisitorInitiator = { | |
| Program(path) { | |
| const commentLineTokens = path.parent.comments.filter( | |
| (token) => token.type === "CommentLine" | |
| ); | |
| const commentBlockTokens = path.parent.comments.filter( | |
| (token) => token.type === "CommentBlock" | |
| ); |
This file contains hidden or 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
| module.exports = function ({ types: t }) { | |
| const GrandmaVisitor = { | |
| StringLiteral(path, state) { | |
| if (path.node.value === "👵") { | |
| const recipeRef = state.grandmasRecipes[path.node.loc.start.line]; | |
| const recipeMatches = recipeRef && recipeRef.start > path.node.start; | |
| if (recipeMatches) { | |
| const recipe = recipeRef.value; | |
| const domStruc = cookRecipe(recipe, state.grandmasReference); |
This file contains hidden or 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
| module.exports = function ({ types: t }) { | |
| const genTypeExpression = (node) => { | |
| return t.callExpression( | |
| t.memberExpression(t.identifier("React"), t.identifier("createElement")), | |
| [ | |
| /^[A-Z]/.test(node.type[0]) | |
| ? t.identifier(node.type) | |
| : t.stringLiteral(node.type), | |
| t.objectExpression(node.args), | |
| ...node.children.map(genTypeExpression), |
OlderNewer