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

🚀 Feature: sort-collections: alphabetically sorting with co-located hooks for scripts #499

Open
3 tasks done
lo1tuma opened this issue Sep 9, 2024 · 3 comments · May be fixed by #632
Open
3 tasks done

🚀 Feature: sort-collections: alphabetically sorting with co-located hooks for scripts #499

lo1tuma opened this issue Sep 9, 2024 · 3 comments · May be fixed by #632
Labels
status: accepting prs Please, send a pull request to resolve this! type: feature New enhancement or request

Comments

@lo1tuma
Copy link

lo1tuma commented Sep 9, 2024

Bug Report Checklist

  • I have tried restarting my IDE and the issue persists.
  • I have pulled the latest main branch of the repository.
  • I have searched for related issues and found none that matched my issue.

Overview

npm run-scripts support pre and post hooks. For readability I prefer them to be co-located next to their script they belong to,

e.g.

{
  "scripts": {
    "precompress": "",
    "compress": "",
    "postcompress": ""
  }
}

while pre comes before and post after the actual script.

So this should be valid:

{
  "scripts": {
    "build": "",
    "precompress": "",
    "compress": "",
    "postcompress": ""
  }
}

and this one invalid:

{
  "scripts": {
    "precompress": "",
    "compress": "",
    "postcompress": "",
    "build": ""
  }
}

Additional Info

No response

@lo1tuma lo1tuma added the type: feature New enhancement or request label Sep 9, 2024
@JoshuaKGoldberg
Copy link
Owner

Agreed, this would be a nice feature and matches the common convention. https://github.com/keithamus/sort-package-json/blob/92de3ef894435e402d76ae1e8444c4683a46ea2c/defaultRules.md#scripts is an example of this already being used in the wild:

Keys are sorted alphabetically except for pre/post scripts. Those are placed before and after their corresponding base npm script.

Since we're still on a 0.x version of the plugin I think we can turn it on for everyone by default. Thanks for filing!

@JoshuaKGoldberg JoshuaKGoldberg added the status: accepting prs Please, send a pull request to resolve this! label Sep 12, 2024
@JoshuaKGoldberg
Copy link
Owner

@all-contributors please add @lo1tuma for ideas.

🤖 Beep boop! This comment was added automatically by all-contributors-auto-action.
Not all contributions can be detected from Git & GitHub alone. Please comment any missing contribution types this bot missed.
...and of course, thank you for contributing! 💙

Copy link
Contributor

@JoshuaKGoldberg

I've put up a pull request to add @lo1tuma! 🎉

I couldn't determine any contributions to add, did you specify any contributions?
Please make sure to use valid contribution names.

JoshuaKGoldberg pushed a commit that referenced this issue Sep 12, 2024
Adds @lo1tuma as a contributor for ideas.

This was requested by JoshuaKGoldberg [in this
comment](#499 (comment))

---------

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: accepting prs Please, send a pull request to resolve this! type: feature New enhancement or request
Projects
None yet
2 participants