Skip to content

Conversation

@tbouffard
Copy link
Member

@tbouffard tbouffard commented May 3, 2025

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.

Notes

Covers #378

Summary by CodeRabbit

  • Chores

    • Updated naming conventions for node type constants throughout the application for improved consistency.
    • Updated documentation to reflect changes in constant names.
    • Adjusted build configuration thresholds for chunk size warnings in example projects.
  • Style

    • Improved code comments and examples to match updated constant names.

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`.
@tbouffard tbouffard added the refactor Code refactoring label May 3, 2025
@coderabbitai
Copy link

coderabbitai bot commented May 3, 2025

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 @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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.

📥 Commits

Reviewing files that changed from the base of the PR and between 81a028a and db3d698.

📒 Files selected for processing (1)
  • packages/core/src/util/domUtils.ts (2 hunks)

Walkthrough

The changes replace the NODETYPE enum with a new NODE_TYPE constant object throughout the codebase, updating all corresponding imports and usages to reflect the new naming. The enum member DOCUMENTTYPE is renamed to DOCUMENT_TYPE. All references, checks, and documentation examples are updated for consistency. Additionally, minor adjustments are made to Vite configuration files, slightly lowering the chunkSizeWarningLimit values. The changelog is updated to document these changes.

Changes

File(s) Change Summary
packages/core/src/util/Constants.ts Removed exported enum NODETYPE; added exported constant object NODE_TYPE with renamed key DOCUMENT_TYPE.
packages/core/src/gui/MaxWindow.ts
packages/core/src/internal/utils.ts
packages/core/src/util/StringUtils.ts
packages/core/src/util/domUtils.ts
packages/core/src/util/xmlUtils.ts
Updated imports and usages from NODETYPE to NODE_TYPE; updated all internal references and checks accordingly.
packages/core/src/view/geometry/stencil/StencilShapeRegistry.ts Updated code comment example to use constants.NODE_TYPE.ELEMENT instead of constants.NODETYPE.ELEMENT.
packages/html/stories/shared/utils.ts Corrected constant reference from constants.NODETYPE.ELEMENT to constants.NODE_TYPE.ELEMENT in the isElement function.
packages/ts-example-selected-features/vite.config.js Decreased chunkSizeWarningLimit from 378 to 377 in Vite build options.
packages/ts-example/vite.config.js Decreased chunkSizeWarningLimit from 436 to 435 in Vite build options.
CHANGELOG.md Updated to document the removal of NODETYPE, addition of NODE_TYPE, and renaming of DOCUMENTTYPE to DOCUMENT_TYPE.

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
Loading
✨ Finishing Touches
  • 📝 Generate Docstrings

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.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need 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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a 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 line nodeType = 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

📥 Commits

Reviewing files that changed from the base of the PR and between 4d7448d and 81a028a.

📒 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 chunkSizeWarningLimit has been decreased from 378 to 377, likely reflecting the reduced bundle size from replacing the NODETYPE enum with the NODE_TYPE value object.

packages/ts-example/vite.config.js (1)

30-30: Adjusted chunk size warning threshold to match new bundle size.

The chunkSizeWarningLimit has been decreased from 436 to 435, corresponding to the reduced bundle size achieved by replacing the NODETYPE enum with the NODE_TYPE value 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_TYPE constant object properly replaces the previous NODETYPE enum, providing the same functionality with better tree-shaking potential. The use of as const ensures type safety and immutability, while the naming convention using uppercase with underscores is consistent with other constants in the file.

The renaming of DOCUMENTTYPE to DOCUMENT_TYPE improves 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 ts

Length of output: 1440


All old NODETYPE references removed – changes approved.

I searched the codebase and found no lingering references to the old NODETYPE enum, and confirmed that all usages now reference the new NODE_TYPE constant. 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:

  1. The constants.NODETYPE enum has been removed and replaced by the constants.NODE_TYPE value object
  2. The enum member DOCUMENTTYPE has been renamed to DOCUMENT_TYPE

This 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.ELEMENT instead of the old constants.NODETYPE.ELEMENT enum, 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_TYPE constant object instead of the deprecated NODETYPE enum.


34-34: Node type check correctly updated.

The node type check in the isElement function has been properly updated to use NODE_TYPE.ELEMENT instead of NODETYPE.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_TYPE constant object instead of the deprecated NODETYPE enum.


119-119: Node type check correctly updated.

The node type check in the removeWhitespace function has been properly updated to use NODE_TYPE.TEXT instead of NODETYPE.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_TYPE constant object instead of the deprecated NODETYPE enum.


150-150: All node type comparisons correctly updated.

All node type comparisons in the getPrettyXml function have been properly updated to use the new NODE_TYPE constant object instead of the deprecated NODETYPE enum. 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_TYPE constant object instead of the deprecated NODETYPE enum.


374-374: Node type check correctly updated.

The node type check in the setTitle method has been properly updated to use NODE_TYPE.TEXT instead of NODETYPE.TEXT, consistent with the codebase-wide refactoring.

packages/html/stories/shared/utils.ts (1)

20-20: Replace NODETYPE reference with new NODE_TYPE constant
The condition now correctly checks constants.NODE_TYPE.ELEMENT against node.nodeType, aligning with the refactored value object in Constants.ts.

packages/core/src/util/domUtils.ts (3)

17-17: Update import to use NODE_TYPE
The import has been updated from the deprecated NODETYPE enum to the new readonly NODE_TYPE object, ensuring consistency with the definition in Constants.ts.


265-265: Correct JSDoc to reference NODE_TYPE
The @param annotation now links to NODE_TYPE.ELEMENT instead of the old enum, keeping the documentation accurate and in sync with the code.


269-269: Set default parameter to NODE_TYPE.ELEMENT
Defining nodeType: number = NODE_TYPE.ELEMENT simplifies the function signature and removes ambiguity when callers omit this argument.

…ault value already managed in function signature)
@sonarqubecloud
Copy link

sonarqubecloud bot commented May 3, 2025

@tbouffard tbouffard merged commit 7b2efb4 into main May 3, 2025
7 checks passed
@tbouffard tbouffard deleted the refactor/378-replace_NODETYPE_enum_by_NODE_TYPE_value branch May 3, 2025 19:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

refactor Code refactoring

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant