Skip to content

feat(eslint): add custom sort (id on top)#278

Merged
kodiakhq[bot] merged 1 commit into
mainfrom
sort-id-on-top
Jun 19, 2025
Merged

feat(eslint): add custom sort (id on top)#278
kodiakhq[bot] merged 1 commit into
mainfrom
sort-id-on-top

Conversation

@mheob
Copy link
Copy Markdown
Owner

@mheob mheob commented Jun 19, 2025

Summary by CodeRabbit

  • New Features

    • Introduced a custom sorting feature that ensures properties named "id" are placed at the top when sorting interfaces, object types, and objects.
  • Refactor

    • Updated sorting configurations for improved consistency and explicit grouping, including adjustments to array includes sorting behavior.
  • Chores

    • Added documentation for the new version update and sorting feature.

Applies a custom sorting configuration for interfaces and objects.

This configuration prioritizes certain properties ('id' in this case) and
groups methods and members, improving code readability and maintainability
by enforcing a consistent structure.
@mheob mheob added enhancement 📈 New feature or request eslint 🚨 Belongs to ESLint config labels Jun 19, 2025
@height
Copy link
Copy Markdown

height Bot commented Jun 19, 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.

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Jun 19, 2025

🦋 Changeset detected

Latest commit: 0737717

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

@vercel
Copy link
Copy Markdown

vercel Bot commented Jun 19, 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 Jun 19, 2025 8:30am

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jun 19, 2025

Walkthrough

A new changeset file was added to document a minor version update for the @mheob/eslint-config package. The ESLint perfectionist configuration was updated to introduce a custom sort feature prioritizing the id property at the top and refining the sorting rules for interfaces, object types, and objects.

Changes

File(s) Change Summary
.changeset/angry-cloths-feel.md Added changeset documenting a minor version update for @mheob/eslint-config with custom sort.
packages/eslint-config/src/configs/perfectionist.ts Introduced a customSort configuration prioritizing id at the top; updated sorting rules for interfaces, object types, and objects; adjusted array includes grouping.

Sequence Diagram(s)

sequenceDiagram
    participant ESLint
    participant perfectionistConfig
    participant customSort

    ESLint->>perfectionistConfig: Load configuration
    perfectionistConfig->>customSort: Apply custom sort rules
    customSort-->>perfectionistConfig: Return sorted configuration (id on top)
    perfectionistConfig-->>ESLint: Provide updated rules for interfaces, object types, objects
Loading

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 1, reused 0, downloaded 0, added 0
Progress: resolved 35, reused 0, downloaded 26, 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:


📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 391cb1d and 0737717.

📒 Files selected for processing (2)
  • .changeset/angry-cloths-feel.md (1 hunks)
  • packages/eslint-config/src/configs/perfectionist.ts (4 hunks)
🔇 Additional comments (8)
packages/eslint-config/src/configs/perfectionist.ts (7)

2-6: LGTM! Type imports are correctly added.

The type imports are properly structured and necessary for the type safety of the custom sort configuration.


9-12: LGTM! Union type definition is well-structured.

The PerfectionistSortCustom union type correctly combines the three imported perfectionist sort types for type safety.


74-74: LGTM! Interface sorting now uses custom sort.

The rule correctly applies the customSort configuration to prioritize id properties at the top of interfaces.


83-83: LGTM! Object type sorting now uses custom sort.

The rule correctly applies the customSort configuration to prioritize id properties at the top of object types.


84-94: LGTM! Object sorting configuration is well-structured.

The custom configuration for sort-objects correctly:

  • Reuses the customGroups from customSort
  • Defines appropriate grouping for methods and members
  • Maintains the natural sorting type

The approach of combining multiline and regular methods/members in a single group is reasonable for object sorting.


14-32: Verify the type property in customGroups configuration.

The customSort configuration looks well-structured, but there's a potential issue with the type: 'natural' property inside the customGroups object. This property might not be valid for custom group definitions in the perfectionist plugin.

Does eslint-plugin-perfectionist support the `type` property within custom group definitions in customGroups?

52-52: Verify the API change for sort-array-includes rule.

The configuration syntax has changed from { groupKind: 'literals-first', type: 'natural' } to { groups: ['literal'], type: 'natural' }. This suggests a potential breaking change in the perfectionist plugin API.

What is the correct configuration syntax for perfectionist/sort-array-includes rule in the latest version of eslint-plugin-perfectionist?
.changeset/angry-cloths-feel.md (1)

1-6: LGTM! Changeset documentation is accurate.

The changeset correctly documents a minor version bump for the @mheob/eslint-config package with an appropriate description that matches the implemented feature.

✨ 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.
    • Explain this complex logic.
    • 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 explain this code block.
    • @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 explain its main purpose.
    • @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.

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
Copy Markdown

@kodiakhq kodiakhq Bot merged commit cf4d4cf into main Jun 19, 2025
9 checks passed
@kodiakhq kodiakhq Bot deleted the sort-id-on-top branch June 19, 2025 08:32
kodiakhq Bot pushed a commit that referenced this pull request Jun 19, 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/eslint-config@8.11.0

### Minor Changes

-   [#278](#278) ([@mheob](https://github.com/mheob)): add custom sort (id on top)

### Patch Changes

-   [#280](#280) ([@mheob](https://github.com/mheob)): update all non-major dependencies

## @mheob/commitlint-config@1.2.3

### Patch Changes

-   [#280](#280) ([@mheob](https://github.com/mheob)): update all non-major dependencies
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