Skip to content

chore(types): enforce usage of explicit override keyword in examples#739

Merged
tbouffard merged 1 commit intomainfrom
chore/enforce_override_keyword_in_examples
Mar 30, 2025
Merged

chore(types): enforce usage of explicit override keyword in examples#739
tbouffard merged 1 commit intomainfrom
chore/enforce_override_keyword_in_examples

Conversation

@tbouffard
Copy link
Member

@tbouffard tbouffard commented Mar 29, 2025

A lot of refactoring involving methods move are planned in the near future, mainly to improve the tree shaking.
Enabling this check will detect errors early while doing such refactoring.

Do not enable it for now in the code of the lib, as we want maxGraph to support TS 3.8 and this feature requires TS 4.3.

In addition, decrease the chunk size warning limit in the "vite.config.js" file in examples (relates to a previous commit).

Summary by CodeRabbit

  • Chores

    • Updated build and configuration settings to enhance consistency and diagnostic feedback.
  • Refactor

    • Streamlined internal code by explicitly marking overridden methods, improving clarity and maintainability without affecting end-user functionality.

A lot of refactoring involving methods move are planned in the near future, mainly to improve the tree shaking.
Enabling this check will detect errors early while doing such refactoring.

Do not enable it for now in the code of the lib, as we want maxGraph to support TS 3.8 and this feature requires TS 4.3.

In addition, decrease the chunk size warning limit in the "vite.config.js" file in examples (relates to a previous commit).
@tbouffard tbouffard added the chore Build, CI/CD or repository tasks (issues/PR maintenance, environments, ...) label Mar 29, 2025
@coderabbitai
Copy link

coderabbitai bot commented Mar 29, 2025

Walkthrough

This pull request introduces multiple non-functional updates across TypeScript configuration files and various story and example source files. The majority of the changes add the override keyword to method and property declarations in several classes, clarifying inheritance and ensuring stricter TypeScript checks. In addition, new compiler options have been added to tsconfig files, and the Vite configuration files have updated chunkSizeWarningLimit values. These modifications are purely syntactical and configuration-related, with no changes to the underlying logic or control flow.

Changes

File(s) Change Summary
packages/html/stories/[Anchors, AutoLayout, ContextIcons, Handles, Markers, MenuStyle, Overlays, PerimeterOnLabelBounds, ShowRegion, Stencils].ts,
packages/ts-example/…/custom-shapes.ts
Added override keyword to multiple method and property declarations to explicitly indicate overrides in extended classes.
packages/core/tsconfig.json,
tsconfig.json
Added new compiler option noImplicitOverride (set to false in core and true in root) to enforce stricter override checking based on TypeScript version compatibility.
packages/ts-example-without-defaults/vite.config.js,
packages/ts-example/vite.config.js
Decreased chunkSizeWarningLimit values (from 441 to 436 and from 445 to 440) to adjust build warning thresholds.

Suggested labels

documentation


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between bd3b85f and fd4b5e0.

📒 Files selected for processing (15)
  • packages/core/tsconfig.json (1 hunks)
  • packages/html/stories/Anchors.stories.ts (2 hunks)
  • packages/html/stories/AutoLayout.stories.ts (3 hunks)
  • packages/html/stories/ContextIcons.stories.ts (3 hunks)
  • packages/html/stories/Handles.stories.ts (4 hunks)
  • packages/html/stories/Markers.stories.ts (2 hunks)
  • packages/html/stories/MenuStyle.stories.ts (2 hunks)
  • packages/html/stories/Overlays.stories.ts (3 hunks)
  • packages/html/stories/PerimeterOnLabelBounds.stories.ts (3 hunks)
  • packages/html/stories/ShowRegion.stories.ts (2 hunks)
  • packages/html/stories/Stencils.stories.ts (2 hunks)
  • packages/ts-example-without-defaults/vite.config.js (1 hunks)
  • packages/ts-example/src/custom-shapes.ts (2 hunks)
  • packages/ts-example/vite.config.js (1 hunks)
  • tsconfig.json (1 hunks)
🧰 Additional context used
🧬 Code Definitions (1)
packages/html/stories/PerimeterOnLabelBounds.stories.ts (1)
packages/core/src/view/GraphView.ts (1)
  • GraphView (94-2399)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: build (windows-2022)
🔇 Additional comments (38)
tsconfig.json (1)

10-11: LGTM: Adding noImplicitOverride option to enforce explicit overrides.

This change aligns perfectly with the PR objective of enforcing the explicit override keyword in TypeScript examples. Setting noImplicitOverride to true in the root tsconfig will help catch potential refactoring issues early.

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

30-30: LGTM: Decrease in chunk size warning limit.

The reduction of chunkSizeWarningLimit to 436 for the @maxgraph/core package aligns with the PR objectives of decreasing this limit in the examples' vite.config.js file.

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

30-30: LGTM: Consistent decrease in chunk size warning limit.

The reduction of chunkSizeWarningLimit to 440 matches the similar change in the other example configuration, maintaining consistency across example configurations.

packages/core/tsconfig.json (1)

12-14: LGTM: Explicitly disabling noImplicitOverride in core package.

The change correctly implements the PR objective of not enabling the override keyword check in the library code. The comment clearly explains the reasoning - maintaining compatibility with TypeScript 3.8 while the feature requires TS 4.3+.

packages/html/stories/Markers.stories.ts (2)

78-78: LGTM: Adding explicit override keyword.

The addition of the override keyword to the redrawPath method properly indicates that this method overrides its parent class implementation, which improves code clarity and aligns with the PR objective.


104-104: LGTM: Adding explicit override keyword.

The addition of the override keyword to the paintEdgeShape method properly indicates that this method overrides its parent class implementation, which improves code clarity and aligns with the PR objective.

packages/html/stories/Anchors.stories.ts (2)

61-61: LGTM: Good addition of the override keyword

The addition of the override keyword to the createEdgeState method properly indicates that this method is overriding functionality from the parent ConnectionHandler class, improving code clarity.


82-85: Appropriate use of override and improved formatting

The addition of the override keyword and the reformatting of the method signature enhance readability and explicitly indicate that this method overrides the parent Graph class method.

packages/html/stories/PerimeterOnLabelBounds.stories.ts (2)

61-66: LGTM: Correctly added override keyword to method declaration

The override keyword appropriately indicates that this method provides a specialized implementation of the getPerimeterPoint method from the parent GraphView class.


95-95: LGTM: Good use of the override keyword

The addition of override to the createGraphView method properly indicates its intention to override the parent class implementation.

packages/html/stories/Stencils.stories.ts (4)

92-92: LGTM: Appropriate addition of override keyword

The override keyword properly indicates that this method overrides the parent class implementation, enhancing code clarity.


97-97: LGTM: Good use of the override keyword

The addition of override clarifies that this method overrides functionality defined in the parent VertexHandler class.


127-127: LGTM: Appropriate use of override keyword

The override keyword correctly indicates that this method overrides the implementation from the parent Graph class.


134-140: Improved method signature with proper override keyword

The addition of the override keyword and the reformatting of the method parameters across multiple lines improves both code clarity and readability.

packages/html/stories/MenuStyle.stories.ts (2)

77-81: Improved method signature with proper override keyword

The override keyword has been correctly added, and the method parameters have been nicely reformatted across multiple lines for better readability.


150-150: LGTM: Good use of the override keyword

The addition of the override keyword properly indicates that this method is implementing a specialized version of the method from the parent class.

packages/html/stories/ContextIcons.stories.ts (3)

161-164: Well structured override implementation

The addition of the override keyword here correctly indicates that this method is overriding the parent class implementation, making the inheritance relationship explicit. This is good practice for TypeScript code and follows the PR's objective of enforcing explicit override keywords.


174-181: Proper resource cleanup in overridden method

The addition of the override keyword here clearly indicates the method is overriding its parent. The implementation properly calls the parent method with super.onDestroy() before performing its own cleanup, which ensures resources are properly managed.


189-194: Correctly implemented factory method override

The addition of the override keyword properly indicates this method is overriding the parent class implementation. The method correctly implements the factory pattern by returning a custom handler for vertices while delegating to the parent for other cases.

🧰 Tools
🪛 Biome (1.9.4)

[error] 190-190: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)

packages/html/stories/ShowRegion.stories.ts (3)

82-84: Good use of override with super call

The addition of the override keyword here correctly indicates that this method is extending the parent class implementation. The method properly preserves the parent behavior while adding the popup trigger check, which is a clean extension pattern.


102-105: Properly ordered operations in overridden method

The addition of the override keyword clearly marks this method as overriding its parent. The implementation correctly hides the popup menu before calling the parent method, maintaining a proper sequence of operations.


107-122: Well-structured conditional override implementation

The addition of the override keyword here properly marks this method as overriding its parent. The implementation correctly handles the popup trigger case separately before delegating to the parent for other cases, which is a good pattern for extending behavior.

packages/html/stories/Overlays.stories.ts (3)

71-85: Improved method signature with override keyword

The addition of the override keyword properly marks this method as overriding its parent. The reformatted parameter layout improves readability. The implementation has a clean switch pattern that handles custom cases while falling back to the parent implementation when appropriate.


87-97: Good use of override with parent enhancement

The addition of the override keyword clearly indicates this method extends the parent implementation. The method correctly calls the parent implementation first before adding its own enhancements, which is a good pattern for extending behavior.


100-102: Clean factory method override

The addition of the override keyword properly indicates this method is overriding its parent. This is a good example of using the factory method pattern to customize component creation while maintaining the expected interface.

packages/ts-example/src/custom-shapes.ts (3)

33-42: Improved method signature with override keyword

The addition of the override keyword properly marks this method as overriding its parent. The reformatted parameter layout with one parameter per line improves readability. The implementation correctly sets a custom fill color before calling the parent method.


44-53: Enhanced method signature readability with override

The addition of the override keyword clearly indicates this method is overriding the parent implementation. The reformatted parameter layout improves readability. The method correctly sets a custom stroke color before delegating to the parent implementation.


61-71: Clear method override with improved formatting

The addition of the override keyword properly marks this method as overriding its parent. The reformatted parameter layout with one parameter per line improves readability. The implementation appropriately sets custom colors before calling the parent method.

packages/html/stories/Handles.stories.ts (5)

70-80: Properly marked method override.

The addition of the override keyword clarifies that this method is intentionally overriding the parent class implementation, improving code readability and enabling TypeScript to detect if the method signature changes in the parent class.


82-107: Correctly applied override keyword to redrawPath method.

The override keyword has been appropriately added to the redrawPath method, making it explicit that this method overrides behavior from its parent class. This is a good practice for better code maintainability.


121-121: Property correctly marked as override.

The livePreview property is properly marked with the override keyword, indicating it intentionally overrides a property from the parent class.


123-189: Properly marked method override in handler class.

The createCustomHandles method is now correctly marked with override, which clarifies its relationship to the parent class implementation and improves TypeScript's ability to catch potential errors during refactoring.


197-199: Correctly applied override keyword to createVertexHandler.

The override keyword has been appropriately added to the createVertexHandler method, making the inheritance relationship clearer and helping catch potential breaking changes in the parent class.

packages/html/stories/AutoLayout.stories.ts (5)

77-101: Properly marked method override with parameter annotations.

The installCellOverlayListeners method is correctly marked with override and includes type annotations for all parameters, which enhances both readability and type safety.


105-115: Correctly applied override keyword to connect method.

The override keyword has been appropriately added to the connect method in the MyCustomEdgeHandler class, which helps clarify inheritance relationships and improves maintainability during refactoring.


123-128: Properly marked createEdgeHandler method with override.

The createEdgeHandler method is now correctly marked with the override keyword, making it explicit that this method is intended to override the parent class implementation.


130-132: Correctly applied override to createCellRenderer method.

The override keyword has been appropriately added to the createCellRenderer method, which improves code clarity and helps with refactoring safety.


134-138: Properly marked arrow function property with override.

The resizeCell method (implemented as an arrow function property) is correctly marked with the override keyword. This is particularly important for properties that override methods, as it helps ensure type compatibility.

✨ 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.

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 resolve resolve all the CodeRabbit review comments.
  • @coderabbitai plan to trigger planning for file edits and PR creation.
  • @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.

@sonarqubecloud
Copy link

@tbouffard tbouffard merged commit 5a9f70a into main Mar 30, 2025
7 checks passed
@tbouffard tbouffard deleted the chore/enforce_override_keyword_in_examples branch March 30, 2025 14:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

chore Build, CI/CD or repository tasks (issues/PR maintenance, environments, ...)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant