-
Notifications
You must be signed in to change notification settings - Fork 199
refactor!: replace NODETYPE enum by NODE_TYPE value object #802
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
refactor!: replace NODETYPE enum by NODE_TYPE value object #802
Conversation
BREAKING CHANGES: The `constants.NODETYPE` enum has been removed and replaced by the `constants.NODE_TYPE` value object. The former `DOCUMENTTYPE` enum member has been renamed to `DOCUMENT_TYPE`.
|
Warning Rate limit exceeded@tbouffard has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 1 minutes and 58 seconds before requesting another review. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. 📒 Files selected for processing (1)
WalkthroughThe changes replace the Changes
Sequence Diagram(s)sequenceDiagram
participant Code as Codebase
participant Constants as Constants Module
Code->>Constants: Import NODE_TYPE
Code->>Code: Use NODE_TYPE.ELEMENT, NODE_TYPE.TEXT, etc. for node type checks
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
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.
Actionable comments posted: 0
🧹 Nitpick comments (1)
packages/core/src/util/domUtils.ts (1)
271-271: Remove redundant fallback assignment
The linenodeType = nodeType || NODE_TYPE.ELEMENT;is no longer necessary due to the default parameter. It also risks overriding valid falsy values (e.g.,0). Consider removing this to streamline the logic.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (11)
CHANGELOG.md(1 hunks)packages/core/src/gui/MaxWindow.ts(2 hunks)packages/core/src/internal/utils.ts(2 hunks)packages/core/src/util/Constants.ts(1 hunks)packages/core/src/util/StringUtils.ts(2 hunks)packages/core/src/util/domUtils.ts(2 hunks)packages/core/src/util/xmlUtils.ts(4 hunks)packages/core/src/view/geometry/stencil/StencilShapeRegistry.ts(1 hunks)packages/html/stories/shared/utils.ts(1 hunks)packages/ts-example-selected-features/vite.config.js(1 hunks)packages/ts-example/vite.config.js(1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (5)
packages/core/src/internal/utils.ts (1)
packages/core/src/util/Constants.ts (1)
NODE_TYPE(430-443)
packages/core/src/util/StringUtils.ts (1)
packages/core/src/util/Constants.ts (1)
NODE_TYPE(430-443)
packages/core/src/util/xmlUtils.ts (3)
packages/core/src/util/Constants.ts (1)
NODE_TYPE(430-443)packages/core/src/util/domUtils.ts (1)
getTextContent(87-89)packages/core/src/util/StringUtils.ts (2)
trim(62-63)htmlEntities(138-151)
packages/core/src/util/domUtils.ts (1)
packages/core/src/util/Constants.ts (1)
NODE_TYPE(430-443)
packages/core/src/gui/MaxWindow.ts (1)
packages/core/src/util/Constants.ts (1)
NODE_TYPE(430-443)
⏰ Context from checks skipped due to timeout of 90000ms (4)
- GitHub Check: build
- GitHub Check: build (macos-14)
- GitHub Check: build (windows-2022)
- GitHub Check: build (ubuntu-22.04)
🔇 Additional comments (17)
packages/ts-example-selected-features/vite.config.js (1)
30-30: Adjusted chunk size warning threshold to match new bundle size.The
chunkSizeWarningLimithas been decreased from 378 to 377, likely reflecting the reduced bundle size from replacing theNODETYPEenum with theNODE_TYPEvalue object.packages/ts-example/vite.config.js (1)
30-30: Adjusted chunk size warning threshold to match new bundle size.The
chunkSizeWarningLimithas been decreased from 436 to 435, corresponding to the reduced bundle size achieved by replacing theNODETYPEenum with theNODE_TYPEvalue object.packages/core/src/util/Constants.ts (1)
426-443:Details
✅ Verification successful
New NODE_TYPE constant object follows modern TypeScript patterns.
The new
NODE_TYPEconstant object properly replaces the previousNODETYPEenum, providing the same functionality with better tree-shaking potential. The use ofas constensures type safety and immutability, while the naming convention using uppercase with underscores is consistent with other constants in the file.The renaming of
DOCUMENTTYPEtoDOCUMENT_TYPEimproves naming consistency.Let's verify that all references to the old enum have been properly updated:
🏁 Script executed:
#!/bin/bash # Check for any remaining references to the old NODETYPE enum echo "Checking for remaining references to NODETYPE..." rg "NODETYPE" --type ts # Check for proper usage of the new NODE_TYPE constant echo "Checking usage of new NODE_TYPE constant..." rg "NODE_TYPE\." --type tsLength of output: 1440
All old
NODETYPEreferences removed – changes approved.I searched the codebase and found no lingering references to the old
NODETYPEenum, and confirmed that all usages now reference the newNODE_TYPEconstant. No further action is required.CHANGELOG.md (1)
24-25: Well-documented breaking change in the changelog.The breaking change has been properly documented in the changelog, clearly stating that:
- The
constants.NODETYPEenum has been removed and replaced by theconstants.NODE_TYPEvalue object- The enum member
DOCUMENTTYPEhas been renamed toDOCUMENT_TYPEThis provides users with clear migration instructions when updating to the new version.
packages/core/src/view/geometry/stencil/StencilShapeRegistry.ts (1)
35-35: Code example correctly updated to use new naming convention.The example in the documentation comment has been properly updated to use
constants.NODE_TYPE.ELEMENTinstead of the oldconstants.NODETYPE.ELEMENTenum, aligning with the codebase-wide refactoring.packages/core/src/internal/utils.ts (2)
17-17: Import statement correctly updated.The import statement has been properly updated to use the new
NODE_TYPEconstant object instead of the deprecatedNODETYPEenum.
34-34: Node type check correctly updated.The node type check in the
isElementfunction has been properly updated to useNODE_TYPE.ELEMENTinstead ofNODETYPE.ELEMENT, consistent with the codebase-wide refactoring.packages/core/src/util/StringUtils.ts (2)
17-17: Import statement correctly updated.The import statement has been properly updated to use the new
NODE_TYPEconstant object instead of the deprecatedNODETYPEenum.
119-119: Node type check correctly updated.The node type check in the
removeWhitespacefunction has been properly updated to useNODE_TYPE.TEXTinstead ofNODETYPE.TEXT, consistent with the codebase-wide refactoring.packages/core/src/util/xmlUtils.ts (2)
19-19: Import statement correctly updated.The import statement has been properly updated to use the new
NODE_TYPEconstant object instead of the deprecatedNODETYPEenum.
150-150: All node type comparisons correctly updated.All node type comparisons in the
getPrettyXmlfunction have been properly updated to use the newNODE_TYPEconstant object instead of the deprecatedNODETYPEenum. This includes checks for document, document fragment, comment, text, and CDATA node types.Also applies to: 160-160, 169-169, 175-175, 181-181
packages/core/src/gui/MaxWindow.ts (2)
25-25: Import statement correctly updated.The import statement has been properly updated to use the new
NODE_TYPEconstant object instead of the deprecatedNODETYPEenum.
374-374: Node type check correctly updated.The node type check in the
setTitlemethod has been properly updated to useNODE_TYPE.TEXTinstead ofNODETYPE.TEXT, consistent with the codebase-wide refactoring.packages/html/stories/shared/utils.ts (1)
20-20: ReplaceNODETYPEreference with newNODE_TYPEconstant
The condition now correctly checksconstants.NODE_TYPE.ELEMENTagainstnode.nodeType, aligning with the refactored value object inConstants.ts.packages/core/src/util/domUtils.ts (3)
17-17: Update import to useNODE_TYPE
The import has been updated from the deprecatedNODETYPEenum to the new readonlyNODE_TYPEobject, ensuring consistency with the definition inConstants.ts.
265-265: Correct JSDoc to referenceNODE_TYPE
The@paramannotation now links toNODE_TYPE.ELEMENTinstead of the old enum, keeping the documentation accurate and in sync with the code.
269-269: Set default parameter toNODE_TYPE.ELEMENT
DefiningnodeType: number = NODE_TYPE.ELEMENTsimplifies the function signature and removes ambiguity when callers omit this argument.
…ault value already managed in function signature)
|



BREAKING CHANGES: The
constants.NODETYPEenum has been removed and replaced by theconstants.NODE_TYPEvalue object.The former
DOCUMENTTYPEenum member has been renamed toDOCUMENT_TYPE.Notes
Covers #378
Summary by CodeRabbit
Chores
Style