-
Notifications
You must be signed in to change notification settings - Fork 16
fix(regexp): re-use common patterns #376
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
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR refactors regular expressions in the parser constants to improve maintainability by extracting common patterns into reusable variables. The goal is to prevent de-synchronization between similar RegExp patterns used by DOC_API_HEADING_TYPES
.
- Introduces reusable pattern constants (
CAMEL_CASE
,FUNCTION_CALL
,PROPERTY
) - Converts inline regex literals to
new RegExp()
constructors using the extracted patterns - Maintains the same matching behavior while improving code maintainability
Comments suppressed due to low confidence (1)
src/utils/parser/constants.mjs:21
- The pattern name
CAMEL_CASE
is misleading as it matches dotted notation (e.g., 'foo.bar.baz') which is not camelCase. Consider renaming toDOTTED_IDENTIFIER
orQUALIFIED_NAME
to better reflect what it actually matches.
const CAMEL_CASE = '\\w+(?:\\.\\w+)*';
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #376 +/- ##
==========================================
+ Coverage 74.50% 74.52% +0.02%
==========================================
Files 120 120
Lines 11067 11077 +10
Branches 694 694
==========================================
+ Hits 8245 8255 +10
Misses 2819 2819
Partials 3 3 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Co-authored-by: Copilot <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGMT we should have test for that
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! I know this is not related to the PR but could you add inline docs explaining what each regex does and what they're used for? Cheers!
I mean, what exactly is the bug this is fixing? (just OOC) I mean you already added a few doc blocks in this PR, surely you can do the remaining? But if you believe you're going to restructure this file anyways, sure do it as a follow-up ✨ |
The RegExps weren't re-used, and became inconsistent. So a class method's definition of a function call might not match a method's definition. (In this case, property definitions)
I'm going to restructure it anyway, so it's easier for me to just do it there. |
Broken out of: #366
Fixes: #356
This PR moves the common patterns used by
DOC_API_HEADING_TYPES
into there own RegExps, to prevent de-syncing between the RegExps.