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

Remove deprecated @types/wordpress__editor package #2999

Merged
merged 1 commit into from
Dec 2, 2024

Conversation

acicovic
Copy link
Collaborator

@acicovic acicovic commented Nov 28, 2024

Description

The @types/wordpress__editor package is now deprecated and we're removing it in this PR. With this done, we also don't need as GutenbergFunction when using select( editorStore ).

This PR also cleans-up after the latest component updates, by running npm dedupe a couple of times.

Motivation and context

Remove unneeded code.

How has this been tested?

Builds succeed and automated testing keeps passing.

Summary by CodeRabbit

  • New Features

    • Improved user interaction in the excerpt suggestions feature with enhanced event handling.
    • Added a loading animation component for better user feedback during processing.
  • Bug Fixes

    • Refined error handling in the excerpt generation process for clearer management of different error types.
  • Refactor

    • Simplified return value types and method signatures in the excerpt suggestions component for better code clarity.

@acicovic acicovic added Type: Maintenance Component: Dependencies Pull requests that update a dependency file javascript Pull requests that update Javascript code labels Nov 28, 2024
@acicovic acicovic added this to the 3.18.0 milestone Nov 28, 2024
@acicovic acicovic self-assigned this Nov 28, 2024
Copy link
Contributor

coderabbitai bot commented Nov 28, 2024

📝 Walkthrough

Walkthrough

The pull request includes updates to the package.json file by removing the dependency on @types/wordpress__editor. Additionally, modifications to the PostExcerptSuggestions component in component-panel.tsx enhance code clarity and error handling. Key changes involve simplifying type assertions, refining error management, and improving event handling for excerpt changes. These adjustments streamline functionality without altering the core behavior of the component.

Changes

File Path Change Summary
package.json Removed dependency: "@types/wordpress__editor": "^14.3.1" in devDependencies.
src/content-helper/editor-sidebar/excerpt-suggestions/component-panel.tsx Simplified return type of select function, refined error handling in generateExcerpt, updated onChange and onKeyUp handlers, and added LoadingAnimation component.

Possibly related PRs


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ 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 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.

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.

@acicovic acicovic marked this pull request as ready for review November 28, 2024 13:29
@acicovic acicovic requested a review from a team as a code owner November 28, 2024 13:29
Copy link
Contributor

@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

🧹 Outside diff range and nitpick comments (2)
src/content-helper/editor-sidebar/excerpt-suggestions/component-panel.tsx (2)

Line range hint 164-169: Document console.error usage

The error handling is well-structured, but the console.error usage should be documented to explain why we're logging unknown errors.

-				console.error( err ); // eslint-disable-line no-console
+				// Log unknown errors to help with debugging in production
+				console.error( err ); // eslint-disable-line no-console

Line range hint 252-267: Improve keyboard shortcuts handling and documentation

The current implementation uses a flag to prevent duplicate updates, but this could be simplified. Also, the comment about keyboard shortcuts could be more descriptive.

-					onKeyUp={ () => { // Make word count work with Keyboard shortcuts.
+					onKeyUp={ () => {
+						// Handle keyboard shortcuts (e.g., Cmd+X, Cmd+V) that might not trigger onChange
						// This ensures the word count is updated correctly for all user interactions
 						if ( onChangeFired ) {
 							setOnChangeFired( false );
 							return;
 						}

 						const textarea = document.querySelector( '.editor-post-excerpt textarea' );
-						const value = textarea?.textContent ?? '';
+						const value = textarea?.value ?? '';

 						setExcerptData( { ...excerptData, currentExcerpt: value } );
 					} }
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between ce9ee44 and 6cf559f.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (2)
  • package.json (0 hunks)
  • src/content-helper/editor-sidebar/excerpt-suggestions/component-panel.tsx (1 hunks)
💤 Files with no reviewable changes (1)
  • package.json
🧰 Additional context used
📓 Path-based instructions (1)
src/content-helper/editor-sidebar/excerpt-suggestions/component-panel.tsx (1)

Pattern **/*.{js,ts,tsx,jsx}: "Perform a detailed review of the provided code with following key aspects in mind:

  • Review the code to ensure it is well-structured and adheres to best practices.
  • Verify compliance with WordPress coding standards.
  • Ensure the code is well-documented.
  • Check for security vulnerabilities and confirm the code is secure.
  • Optimize the code for performance, removing any unnecessary elements.
  • Validate JSDoc comments for accuracy, currency, and adherence to WordPress coding standards.
  • Ensure each line comment concludes with a period.
  • Confirm every JSDoc comment includes a @SInCE tag indicating the next version of the plugin to include the code.
  • Guarantee compatibility with the latest version of WordPress, avoiding deprecated functions or features."
🔇 Additional comments (2)
src/content-helper/editor-sidebar/excerpt-suggestions/component-panel.tsx (2)

99-99: LGTM: Clean type handling improvement

The removal of the explicit type assertion as GutenbergFunction aligns with the PR objective and results in cleaner code while maintaining the same functionality.


Line range hint 1-399: Verify WordPress compatibility and standards

The changes align well with the PR objectives and WordPress coding standards. Let's verify the removal of all @types/wordpress__editor dependencies.

✅ Verification successful

Let me verify the specific usage of GutenbergFunction to understand if it's still dependent on @types/wordpress__editor.


Let me check the local type definition to see if it's still dependent on @types/wordpress__editor.


The code changes are correctly implemented and the dependency is properly removed

The code has successfully moved away from @types/wordpress__editor by implementing its own type definitions in src/@types/gutenberg/types.ts. The GutenbergFunction and GutenbergCoreEditorFunction interfaces are now locally defined and only depend on official WordPress packages (@wordpress/blocks and @wordpress/data). The implementation is clean and follows WordPress coding standards.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify complete removal of @types/wordpress__editor dependencies

# Check for any remaining references to @types/wordpress__editor
rg -l "@types/wordpress__editor"

# Check for any remaining GutenbergFunction type assertions
rg -l "as GutenbergFunction"

Length of output: 641


Script:

#!/bin/bash
# Check the actual usage of GutenbergFunction in the files
rg -A 2 "GutenbergFunction" 

# Check if there's a local type definition for GutenbergFunction
ast-grep --pattern 'type GutenbergFunction'

Length of output: 8051


Script:

#!/bin/bash
# Check the content of the local types file
cat src/@types/gutenberg/types.ts

Length of output: 2310

Copy link
Contributor

@vaurdan vaurdan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, looks great!

@acicovic acicovic merged commit 1a15fab into develop Dec 2, 2024
41 checks passed
@acicovic acicovic deleted the remove/deprecated-types-wordpress-editor-package branch December 2, 2024 07:19
github-actions bot added a commit that referenced this pull request Dec 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: Dependencies Pull requests that update a dependency file javascript Pull requests that update Javascript code Type: Maintenance
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants