Closed ariya closed 8 years ago
@thlorenz This should be a good trade-off between redeyed processing as many files as possible (smoke testing) and avoiding any false positives.
Yeah seems great, only would bite us if the esprima parser ever wouldn't detect var
statements as then that wouldn't be caught as we're using the same parser to prove to use if they are there or not. i.e. the code we use to validate the tests is very similar to the code we are testing.
However I trust that is very unlikely, so LGTM. Please merge to master. No release will be necessary as only tests are affected.
Thanks @thlorenz, I'll merge it soon.
Note that I agree on the possibility of missing a test case. It is unlikely to happen, though, because we use Esprima tokenizer (and not the parser).
The only other alternative I can think of is to build a simplified tokenizer that skips any block comments and line comments, and then search for var
after those comments are scrubbed. However, I doubt that it will be more robust and cleaner that simply using Esprima tokenizer as is.
Skip any source file that is either syntactically invalid (e.g.
async-map-ordered.js
) or does not contain thevar
keyword (checked by tokenizing the source).