8000 feat(pkg): add option packageIgnoreSort by Shinigami92 · Pull Request #472 · un-ts/prettier · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

feat(pkg): add option packageIgnoreSort #472

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 3 commits into from
Jun 7, 2025
Merged

Conversation

Shinigami92
Copy link
Member
@Shinigami92 Shinigami92 commented Jun 6, 2025

closes #466


Important

Add packageIgnoreSort option to prettier-plugin-pkg to ignore sorting specified package.json properties.

  • Feature:
    • Add packageIgnoreSort option in index.ts to specify properties in package.json to ignore during sorting.
    • Update process() in object.ts to skip sorting for keys in packageIgnoreSort.
  • Types:
    • Add packageIgnoreSort to FormatOptions in types.ts.
  • Tests:
    • Add ignore-sort.spec.ts to test packageIgnoreSort functionality with a snapshot test.

This description was created by Ellipsis for fb938a5. You can customize this summary. It will automatically update as commits are pushed.

Summary by CodeRabbit

  • New Features
    • Added a new option to ignore sorting for specified properties in package.json files.
  • Tests
    • Introduced tests to verify that ignored properties are not sorted when the new option is used.

@Shinigami92 Shinigami92 self-assigned this Jun 6, 2025
Copy link
changeset-bot bot commented Jun 6, 2025

🦋 Changeset detected

Latest commit: 29f75b1

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

This PR includes changesets to release 1 package
Name Type
prettier-plugin-pkg 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
coderabbitai bot commented Jun 6, 2025

Walkthrough

A new plugin option, packageIgnoreSort, was introduced to allow users to specify property names in package.json that should be excluded from sorting. The implementation includes updates to option declarations, type definitions, and the main formatting logic. A dedicated test verifies the new option's behavior.

Changes

File(s) Change Summary
packages/pkg/src/index.ts, packages/pkg/src/types.ts Added packageIgnoreSort option to plugin options and type definitions; updated sorting logic.
packages/pkg/test/ignore-sort.spec.ts Added new test file to verify that ignored properties are not sorted as per the new option.
.changeset/full-frogs-join.md Added changeset documenting the new minor feature and option introduction.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Prettier
    participant Plugin as prettier-plugin-pkg

    User->>Prettier: Format package.json with packageIgnoreSort option
    Prettier->>Plugin: Call format() with options
    Plugin->>Plugin: Filter out properties in packageIgnoreSort
    Plugin->>Plugin: Sort remaining properties
    Plugin-->>Prettier: Return formatted result
    Prettier-->>User: Output formatted package.json
Loading

Assessment against linked issues

Objective Addressed Explanation
Add option to ignore sorting scripts in prettier-plugin-pkg (#466)
Allow users to specify properties to exclude from sorting (#466)
Update documentation and types to reflect new option (#466)
Add test to verify that ignored properties are not sorted (#466)

Poem

A rabbit hops through JSON fields,
With nimble paws, a new rule wields—
"Ignore these keys!" the plugin cries,
And leaves their order as the prize.
Sorting tamed, the code looks neat,
This bunny’s work is quite a treat!
🐇✨

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.

packages/pkg/src/index.ts

Oops! Something went wrong! :(

ESLint: 9.28.0

Error [ERR_MODULE_NOT_FOUND]: Cannot find package '@1stg/eslint-config' imported from /eslint.config.js
at Object.getPackageJSONURL (node:internal/modules/package_json_reader:255:9)
at packageResolve (node:internal/modules/esm/resolve:767:81)
at moduleResolve (node:internal/modules/esm/resolve:853:18)
at defaultResolve (node:internal/modules/esm/resolve:983:11)
at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:799:12)
at #cachedDefaultResolve (node:internal/modules/esm/loader:723:25)
at ModuleLoader.resolve (node:internal/modules/esm/loader:706:38)
at ModuleLoader.getModuleJobForImport (node:internal/modules/esm/loader:307:38)
at #link (node:internal/modules/esm/module_job:170:49)


📜 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 29f75b1 and 6fdaf32.

📒 Files selected for processing (1)
  • packages/pkg/src/index.ts (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/pkg/src/index.ts
⏰ Context from checks skipped due to timeout of 90000ms (5)
  • GitHub Check: Codacy Static Code Analysis
  • GitHub Check: Lint and Test with Node.js 22 on windows-latest
  • GitHub Check: Lint and Test with Node.js 24 on windows-latest
  • GitHub Check: Lint and Test with Node.js 18 on windows-latest
  • GitHub Check: Lint and Test with Node.js 20 on windows-latest
✨ 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 quer 8000 y. 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.

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.

Copy link
codesandbox-ci bot commented Jun 6, 2025

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Copy link
pkg-pr-new bot commented Jun 6, 2025

Open in StackBlitz

prettier-plugin-autocorrect

npm i https://pkg.pr.new/prettier-plugin-autocorrect@472

prettier-plugin-pkg

npm i https://pkg.pr.new/prettier-plugin-pkg@472

prettier-plugin-sh

npm i https://pkg.pr.new/prettier-plugin-sh@472

prettier-plugin-sql

npm i https://pkg.pr.new/prettier-plugin-sql@472

prettier-plugin-toml

npm i https://pkg.pr.new/prettier-plugin-toml@472

commit: 6fdaf32

Copy link
codecov bot commented Jun 6, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 85.78%. Comparing base (bd2b7b0) to head (6fdaf32).
Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #472      +/-   ##
==========================================
+ Coverage   85.41%   85.78%   +0.37%     
==========================================
  Files          10       10              
  Lines         192      197       +5     
  Branches       52       55       +3     
==========================================
+ Hits          164      169       +5     
  Misses         27       27              
  Partials        1        1              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@Shinigami92 Shinigami92 marked this pull request as ready for review June 6, 2025 15:36
Copy link
Contributor
@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

Important

Looks good to me! 👍

Reviewed everything up to fb938a5 in 58 seconds. Click for details.
  • Reviewed 156 lines of code in 6 files
  • Skipped 0 files when reviewing.
  • Skipped posting 5 draft comments. View those below.
  • Modify your settings and rules to customize what types of comments Ellipsis leaves. And don't forget to react with 👍 or 👎 to teach Ellipsis.
1. .changeset/full-frogs-join.md:5
  • Draft comment:
    Changeset message is clear and follows conventions.
  • Reason this comment was not posted:
    Confidence changes required: 0% <= threshold 50% None
2. packages/pkg/src/index.ts:30
  • Draft comment:
    Passing 'options' into the 'object' function ensures the new packageIgnoreSort setting is carried through. This design is clear.
  • Reason this comment was not posted:
    Confidence changes required: 0% <= threshold 50% None
3. packages/pkg/src/index.ts:65
  • Draft comment:
    New 'packageIgnoreSort' option is defined similarly to 'packageSortOrder'. Confirm that its default value structure (i.e. [{ value: [] }]) meets the expected type (string[]) in FormatOptions.
  • Reason this comment was not posted:
    Confidence changes required: 33% <= threshold 50% None
4. packages/pkg/src/rules/object.ts:18
  • Draft comment:
    The check using 'options.packageIgnoreSort?.includes(key)' cleanly skips sorting for properties in the ignore list.
  • Reason this comment was not posted:
    Confidence changes required: 0% <= threshold 50% None
5. packages/pkg/test/ignore-sort.spec.ts:13
  • Draft comment:
    The test effectively verifies that properties specified in 'packageIgnoreSort' (e.g. 'resolutions') remain unsorted.
  • Reason this comment was not posted:
    Confidence changes required: 0% <= threshold 50% None

Workflow ID: wflow_Vs4kA2mFt2Q3p150

You can customize Ellipsis by changing your verbosity settings, reacting with 👍 or 👎, replying to comments, or adding code review rules.

@Shinigami92 Shinigami92 requested a review from JounQin June 6, 2025 15:39
Copy link
sonarqubecloud bot commented Jun 7, 2025

@JounQin JounQin merged commit d5442c8 into un-ts:master Jun 7, 2025
24 of 26 checks passed
@JounQin JounQin mentioned this pull request Jun 6, 2025
@Shinigami92 Shinigami92 deleted the issue-466 branch June 7, 2025 14:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[prettier-plugin-pkg] add option to ignore sorting scripts
2 participants
0