Use AST traversal for challenge tests involving javascript
See original GitHub issueChallenge Name
e.g. Comparisons with the logical AND operator
Issue Description
Some challenge tests rely on Regular Expressions to make assertions about client-submitted code.
For example, in basic-javascript.json:3389 -
"assert(code.match(/if/g).length === 1, 'message: You should only have one <code>if</code> statement');",
This will match the characters “if” anywhere in the code - in single and multiline comments, strings, variable names etc.
Instead of using Regular Expressions, we should instead parse the Javascript using tools like Esprima and Estraverse.
Issue Analytics
- State:
- Created 7 years ago
- Comments:8 (5 by maintainers)
Top Results From Across the Web
Read JavaScript Source Code, Using an AST - DigitalOcean
A quick guide to automate extracting information from your JavaScript code with abstract syntax trees (AST).
Read more >Modifying JavaScript AST with Yeoman | by Robert Vogt
The babel-traverse package helps us walk the AST, with babel-types providing helpers to identify certain tokens. A good way to travel trees is ......
Read more >Linting and ESLint: Write Better Code
Based on this, AST ESLint uses another project called Estraverse which provides traversal functions for an AST. During the traversal, ESLint ...
Read more >Pure AST based linting sucks - RDambrosio
First blog post! For this blog post i would like to talk about various issues around linters which exclusively use ASTs (Abstract Syntax...
Read more >Manipulating AST with JavaScript - Tan Li Hau
Like how we use Babel to do parsing and generating JavaScript, ... realize that mixing AST manipulation code with the traversal code is...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Yes, this is planned but I don’t want to introduce more tech while we are transitioning to the new site.
Right! I’ll close this and take a look at the curriculum. Cheers 😃