Skip to content

feat(eslint): sync recommended rules of react plugins #249

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

Merged
merged 1 commit into from
Apr 12, 2025

Conversation

mheob
Copy link
Owner

@mheob mheob commented Apr 12, 2025

Summary by CodeRabbit

  • Chores
    • Updated various development dependencies and project versions to enhance stability and compatibility.
  • New Features
    • Introduced improved code quality checks for React components with additional guidance to promote best practices.
  • Documentation
    • Refined configuration guidelines and references to align with the latest standards and clarity.

@mheob mheob added enhancement New feature or request eslint Belongs to ESLint config labels Apr 12, 2025
Copy link

height bot commented Apr 12, 2025

Link Height tasks by mentioning a task ID in the pull request title or commit messages, or description and comments with the keyword link (e.g. "Link T-123").

💡Tip: You can also use "Close T-X" to automatically close a task when the pull request is merged.

Copy link

changeset-bot bot commented Apr 12, 2025

🦋 Changeset detected

Latest commit: 9256a99

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@mheob/eslint-config Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link

vercel bot commented Apr 12, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
eslint-config ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 12, 2025 8:06am

Copy link

coderabbitai bot commented Apr 12, 2025

Walkthrough

This pull request introduces a new changeset file that records a minor version update for the @mheob/eslint-config package and includes a note on synchronizing React plugin rules. It also updates dependency versions in the root and package-specific package.json files and adjusts the ESLint configuration for React. Additionally, documentation comments and version references in type definitions have been updated for clarity and accuracy.

Changes

File(s) Change Summary
.changeset/deep-dogs-play.md Introduces a new changeset file for a minor version update of @mheob/eslint-config with a note on syncing React plugin rules.
package.json Updates development dependency versions: @types/node from ^22.14.0 to ^22.14.1 and lint-staged from ^15.5.0 to ^15.5.1.
packages/eslint-config/package.json Updates dependency versions: svelte from ^5.25.12 to ^5.26.1 and dev dependency @eslint-react/eslint-plugin from ^1.45.0 to ^1.45.3.
packages/eslint-config/src/configs/react.ts
packages/eslint-config/src/typegen.d.ts
Adds new ESLint rules (react-hooks-extra/prefer-use-state-lazy-initialization, react/no-leaked-conditional-rendering, react/no-misused-capture-owner-stack, react/no-nested-lazy-component-declarations), removes the react/no-duplicate-jsx-props rule, disables certain existing rules, and updates documentation comments and version references.

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

Scope: all 2 workspace projects
Progress: resolved 0, reused 0, downloaded 1, added 0
/tmp/eslint/packages/eslint-config:
 ERR_PNPM_WORKSPACE_PKG_NOT_FOUND  In packages/eslint-config: "@mheob/tsconfig@workspace:*" is in the dependencies but no package named "@mheob/tsconfig" is present in the workspace

This error happened while installing a direct dependency of /tmp/eslint/packages/eslint-config

Packages found in the workspace:

Tip

⚡💬 Agentic Chat (Pro Plan, General Availability)
  • We're introducing multi-step agentic chat in review comments and issue comments, within and outside of PR's. This feature enhances review and issue discussions with the CodeRabbit agentic chat by enabling advanced interactions, including the ability to create pull requests directly from comments and add commits to existing pull requests.

📜 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 b9ee947 and 9256a99.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (5)
  • .changeset/deep-dogs-play.md (1 hunks)
  • package.json (1 hunks)
  • packages/eslint-config/package.json (1 hunks)
  • packages/eslint-config/src/configs/react.ts (3 hunks)
  • packages/eslint-config/src/typegen.d.ts (9 hunks)
🔇 Additional comments (20)
.changeset/deep-dogs-play.md (2)

1-3: Changeset YAML Header Looks Correct
The header block correctly declares the update for @mheob/eslint-config with a minor version bump. Ensure this format is consistent with our changeset conventions.


5-6: Descriptive Update Note for React Plugin Rules
The note "sync recommended rules of react plugins" clearly communicates the intent. Verify that the linked documentation remains up to date with our ESLint configuration changes.

package.json (2)

36-36: Minor Version Bump for @types/node
The update to "@types/node": "^22.14.1" is a proper minor version increment. Just double-check that no breaking changes are introduced by this update in our TypeScript environments.


42-42: Updated lint-staged Dependency Version
The update to "lint-staged": "^15.5.1" reflects a minor version change. Confirm that all linting scripts operate as expected with the new version.

packages/eslint-config/package.json (2)

68-69: Svelte Version Update in Dependencies
The dependency "svelte": "^5.26.1" has been updated from the previous minor version. Ensure that this version is compatible with our ESLint rules that interact with Svelte code.


75-75: Updated @eslint-react/eslint-plugin for React Rules Sync
The dev dependency update for "@eslint-react/eslint-plugin": "^1.45.3" is in line with our objective to sync recommended React plugin rules. This minor bump should enhance linting capabilities—verify that no regressions occur in our ESLint configuration tests.

packages/eslint-config/src/typegen.d.ts (9)

640-640: Documentation URLs updated to reference the latest version

All the documentation URLs for eslint-plugin-import-x rules have been updated from v4.10.0 to v4.10.2, ensuring that the documentation references point to the latest version of the plugin.

Also applies to: 645-645, 650-650, 655-655, 660-660, 665-665, 670-670, 675-675, 680-680, 685-685, 690-690, 695-695, 700-700, 705-705, 710-710, 715-715, 720-720, 725-725, 730-730, 735-735, 740-740, 745-745, 750-750, 755-755, 760-760, 765-765, 770-770, 775-775, 780-780, 785-785, 790-790, 795-795, 800-800, 805-805, 810-810, 815-815, 820-820, 825-825, 830-830, 835-835, 840-840, 845-845, 850-850, 855-855, 860-860, 865-865


3012-3012: Documentation comment improved for clarity

The description for react/jsx-uses-react has been improved to more clearly explain that the rule marks React variables as used when JSX is used.


3062-3062: Rule description clarified with exception

The documentation for react/no-class-component has been updated to clarify that class components are disallowed except for error boundaries.


3161-3165: New React rule added: no-misused-capture-owner-stack

A new rule has been added to prevent incorrect usage of captureOwnerStack. This aligns with the PR objective of synchronizing recommended rules from React plugins.


3176-3180: New React rule added: no-nested-lazy-component-declarations

A new rule has been added to disallow nesting lazy component declarations inside other components, which is a recommended practice for React applications.


3197-3197: Improved description precision for setState restriction

The documentation for react/no-set-state-in-component-did-update has been updated to be more specific about when setState is disallowed, clarifying that it's specifically about direct calls outside of functions like callbacks.


3207-3207: Clarified purpose of no-string-refs rule

The documentation for react/no-string-refs has been updated to more clearly indicate that the rule is about replacing string refs with callback refs.


4373-4377: New test rule added: prefer-describe-function-title

A new rule has been added for testing to enforce using a function as a describe title over an equivalent string, which improves test maintainability and readability.


7577-7578: New options added for class-methods-use-this rule

Two new options have been added to the ClassMethodsUseThis type:

  1. ignoreOverrideMethods - Likely to ignore methods that override parent class methods
  2. ignoreClassesWithImplements - For classes that implement interfaces, with options for "all" or "public-fields"

These additions provide more flexibility in configuring the rule's behavior.

packages/eslint-config/src/configs/react.ts (5)

100-100: Good addition of the lazy initialization rule!

Adding the react-hooks-extra/prefer-use-state-lazy-initialization rule as a warning is beneficial. This rule encourages developers to wrap expensive initial state computations in a function, which is a useful performance optimization recommended in the React documentation.


142-146: Appropriate configuration for modern React development.

Turning off these rules makes sense as they're either:

  1. Redundant with TypeScript's own checks
  2. No longer needed with the new JSX transform in React 17+
  3. Better handled by other parts of your configuration

This change aligns well with modern React development practices.


166-166: Good addition for safer conditional rendering!

The react/no-leaked-conditional-rendering rule helps prevent subtle bugs that can occur when falsy values (like 0, empty strings, or undefined) are used in conditional rendering scenarios. Setting this to 'warn' is appropriate as it guides developers without being too restrictive.


168-168: Appropriate error rule for debugging quality.

The react/no-misused-capture-owner-stack rule enforces correct usage of React's component stack capture mechanism, which is important for proper error reporting and debugging. Setting this to 'error' is suitable since misusing this feature can lead to misleading error messages.


170-170: Good performance-oriented rule addition.

The react/no-nested-lazy-component-declarations rule discourages defining React.lazy components inside other components, which can lead to performance degradation as these would be recreated on each render. Setting this to 'warn' provides helpful guidance without being overly strict.

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

@kodiakhq kodiakhq bot merged commit 4f1254a into main Apr 12, 2025
10 checks passed
@kodiakhq kodiakhq bot deleted the sync-react-rules branch April 12, 2025 08:09
kodiakhq bot pushed a commit that referenced this pull request Apr 13, 2025
This PR was opened by the [Changesets release](https://github.com/changesets/action) GitHub action. When you're ready to do a release, you can merge this and the packages will be published to npm automatically. If you're not ready to do a release yet, that's fine, whenever you add more changesets to main, this PR will be updated.


# Releases
## @mheob/[email protected]

### Minor Changes

-   [#253](#253) ([@mheob](https://github.com/mheob)): add cli for initial configuration

-   [#249](#249) ([@mheob](https://github.com/mheob)): sync recommended rules of [react plugins](https://eslint-react.xyz/)

-   [#251](#251) ([@mheob](https://github.com/mheob)): allow `svelte` to overrides rules

### Patch Changes

-   [#254](#254) ([@mheob](https://github.com/mheob)): update dependencies




## Summary by CodeRabbit

- **New Features**
  - Introduced a command-line tool to simplify initial ESLint configuration.
  - Enhanced linting support with updated recommended rules for React and added flexibility for Svelte projects.

- **Maintenance**
  - Upgraded the ESLint configuration package to version 8.7.0 with improved dependency management.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request eslint Belongs to ESLint config
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant