question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Use AST traversal for challenge tests involving javascript

See original GitHub issue

Challenge 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:closed
  • Created 7 years ago
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
BerkeleyTruecommented, Oct 31, 2016

Yes, this is planned but I don’t want to introduce more tech while we are transitioning to the new site.

0reactions
sammoorhousecommented, Oct 31, 2016

Right! I’ll close this and take a look at the curriculum. Cheers 😃

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found