How can I parse tokens but ignore some occurrences? #11961
-
I am using the @babel/parser to find the testing framework keywords and add VSCode codelens on them. However, it gives a false positive when the code contains a regex test method. I would like to find the word "test" for the Jest and Mocha frameworks, but not for a regex test method. Here's the code where do the parsing: Testify: code parser |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 6 replies
-
In the context of tokens, you could potentially check the previous token to see if it's a |
Beta Was this translation helpful? Give feedback.
In the context of tokens, you could potentially check the previous token to see if it's a
.
or not. Otherwise, I think this would be easier in the context of the AST, as you can specifically check if the call is aMemberExpression
or not.