Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consider using Jest's docblock parser for pragmas #1987

Open
4 tasks done
nickmccurdy opened this issue Sep 6, 2022 · 0 comments
Open
4 tasks done

Consider using Jest's docblock parser for pragmas #1987

nickmccurdy opened this issue Sep 6, 2022 · 0 comments

Comments

@nickmccurdy
Copy link
Contributor

nickmccurdy commented Sep 6, 2022

Clear and concise description of the problem

We're maintaining our own regex based docblock pragma parsing logic, which is probably slower and less reliable than it could be as it search entire files instead of just comments at the top.

Suggested solution

We could use jest-docblock's parse function instead of our custom logic. It's a relatively small package with one dependency. They already have good support with many test cases, so we'd have less maintenance burden for maintaining compatibility with Jest (for example #1962 would be easier to fix).

Alternative

Refactor our parser so it's more performant and less reliant on regexes. I don't think we need a full CFG/BNF parser as long as we can focus on comments at the top of the file and parse pragmas. This would also reduce bundle size, in exchange for increasing maintenance effort and decreasing compatibility.

Additional context

jest-docblock doesn't support plain comments (//), so we'd technically be losing support for that unless we added a patch or workaround. However, we'd have to starting dealing with edge cases around groups of comments if we weren't using docblocks exclusively.

Validations

@nickmccurdy nickmccurdy changed the title Consider using Jest's docblock parser Consider using Jest's docblock parser for pragmas Sep 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant