Skip to content

feat(eslint): sorts id to the top of objects in JSON files#286

Merged
kodiakhq[bot] merged 2 commits into
mainfrom
jsonc-sort-id
Jul 25, 2025
Merged

feat(eslint): sorts id to the top of objects in JSON files#286
kodiakhq[bot] merged 2 commits into
mainfrom
jsonc-sort-id

Conversation

@mheob
Copy link
Copy Markdown
Owner

@mheob mheob commented Jul 25, 2025

Summary by CodeRabbit

  • New Features
    • Added a rule to enforce sorting of keys in JSON files, ensuring the "id" property appears first in nested objects, with other keys sorted in natural ascending order.
  • Chores
    • Updated documentation to reflect the new sorting rule in the ESLint config package.

@mheob mheob added enhancement 📈 New feature or request eslint 🚨 Belongs to ESLint config labels Jul 25, 2025
@height
Copy link
Copy Markdown

height Bot commented Jul 25, 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 Jul 25, 2025

🦋 Changeset detected

Latest commit: dddb129

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 Jul 25, 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 Jul 25, 2025 6:17am

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jul 25, 2025

Walkthrough

A new changeset file documents a minor update to the @mheob/eslint-config package. The update adds a configuration to the JSONC ESLint ruleset, enforcing key sorting in JSON files so that the id property appears first, followed by other keys in natural ascending order.

Changes

File(s) Change Summary
.changeset/shy-bobcats-visit.md Added a changeset file documenting the minor update to the ESLint config package regarding JSON key sorting.
packages/eslint-config/src/configs/jsonc.ts Added a new ESLint rule for JSONC: enforces id as the first key, then others sorted naturally in objects with ≥2 keys.

Sequence Diagram(s)

sequenceDiagram
    participant Developer
    participant ESLint
    participant JSONC Config

    Developer->>ESLint: Lint JSON file
    ESLint->>JSONC Config: Apply jsonc/sort-keys rule
    JSONC Config->>ESLint: Enforce "id" first, then natural order
    ESLint->>Developer: Report errors if key order is incorrect
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~7 minutes

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:

Note

⚡️ Unit Test Generation is now available in beta!

Learn more here, or try it out under "Finishing Touches" below.


📜 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 bf13a58 and 3ad8f7d.

📒 Files selected for processing (2)
  • .changeset/shy-bobcats-visit.md (1 hunks)
  • packages/eslint-config/src/configs/jsonc.ts (1 hunks)
🔇 Additional comments (2)
packages/eslint-config/src/configs/jsonc.ts (1)

52-64: LGTM! Well-structured jsonc/sort-keys configuration.

The rule configuration correctly implements the objective of sorting id to the top of objects:

  1. Root level objects (pathPattern: ^$) use natural ascending order
  2. All nested objects (pathPattern: .*) prioritize id first, then natural ascending order
  3. Both configurations apply only when there are at least 2 keys (minKeys: 2)

The syntax and logic are correct for the jsonc/sort-keys rule.

.changeset/shy-bobcats-visit.md (1)

1-6: LGTM! Proper changeset format and accurate description.

The changeset correctly documents this as a minor version bump for @mheob/eslint-config with an accurate description that matches the PR objective and implementation.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch jsonc-sort-id

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 generate unit tests to generate unit tests for 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 93608f4 into main Jul 25, 2025
9 checks passed
@kodiakhq kodiakhq Bot deleted the jsonc-sort-id branch July 25, 2025 06:17
kodiakhq Bot pushed a commit that referenced this pull request Jul 25, 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.12.0

### Minor Changes

-   [#286](#286) ([@mheob](https://github.com/mheob)): sorts `id` to the top of objects in JSON files

-   [#285](#285) ([@mheob](https://github.com/mheob)): add nextjs config

-   [#281](#281) ([@mheob](https://github.com/mheob)): update allowed exports for `react-router`

### Patch Changes

-   [#287](#287) ([@renovate](https://github.com/apps/renovate)): update all non-major deoendencies

## @mheob/commitlint-config@1.2.4

### Patch Changes

-   [#287](#287) ([@renovate](https://github.com/apps/renovate)): update all non-major deoendencies

## @mheob/prettier-config@3.3.4

### Patch Changes

-   [#287](#287) ([@renovate](https://github.com/apps/renovate)): update all non-major deoendencies
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