-
-
Save cef62/2576bf05d09c8a96971662153354cf9b to your computer and use it in GitHub Desktop.
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
import createBabelFile from 'babel-file'; | |
import createBabylonOptions from 'babel-options'; | |
import {buildCodeFrameError} from 'babel-errors'; | |
let code = ` | |
console.log('hello world'); | |
`; | |
let file = createBabelFile(code, { | |
filename: 'hello-world.js', | |
parserOpts: createBabylonOptions({ | |
stage: 2, | |
jsx: true, | |
flow: true, | |
}), | |
}); | |
file.path.traverse({ | |
StringLiteral(path) { | |
if (path.node.value !== 'hello world') { | |
throw buildCodeFrameError(path, 'Must be "hello-world"'); | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment