create-typescript-app icon indicating copy to clipboard operation
create-typescript-app copied to clipboard

🛠 Tooling: Add a bot that suggests auto-formatting

Open JoshuaKGoldberg opened this issue 2 years ago • 8 comments

Bug Report Checklist

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

Overview

Sometimes folks make edits in an environment without Git hooks, such as the web editor (or they use git commit --no-verify). Their commits and PRs will have big red ❌s complaining about formatting issues. Asking them to run Prettier might be too difficult; asking them to make manual edits might be too tedious.

Let's add a bot that offers to apply Prettier fixing for them. It should explain what the formatting needs are and have something like 'react with 👍' and/or 'reply with yes' to trigger.

~Edit: maybe not that last bit around having them react/reply? Maybe that can be an addon later? Honestly I haven't put too much thought into the UX of it.~ No, I really want this to be an opt-in thing. Folks who don't understand Git/GitHub well sometimes have a hard time updating their local branch from the upstream/origin.

Additional Info

This will be particularly useful for projects such as https://github.com/OpenContributionsProject/opensourcecontributionssite that are intended to have non-programmer folks participate.

JoshuaKGoldberg avatar Dec 21 '22 18:12 JoshuaKGoldberg

Oh, that's an interesting idea. Is there a bot that does something similar? I'll try tinkering about this :grin:

takanome-dev avatar Feb 21 '23 20:02 takanome-dev

Hooray!

Is there a bot that does something similar?

I vaguely remember poking around online and not finding much. There are bots that do it automatically, but I don't remember finding any that do it on command.

If such a thing doesn't exist, I'd want it to be a separate bot/action/thing (rather than a bunch of scripts checked into this repo). That way other folks can use it too, outside of this template!

JoshuaKGoldberg avatar Feb 21 '23 20:02 JoshuaKGoldberg

@JoshuaKGoldberg just started experimenting with a github action at https://github.com/TAKANOME-DEV/prettify-action. Any suggestions is welcomed :pray:

takanome-dev avatar Feb 22 '23 19:02 takanome-dev

@TAKANOME-DEV I've had a working setup of this feature in another project so decided to make a quick PR https://github.com/JoshuaKGoldberg/template-typescript-node-package/pull/261 Edit: looks like it's not gonna be so easy since we use pnpm :smiley_cat:

nowyDEV avatar Feb 22 '23 22:02 nowyDEV

@TAKANOME-DEV I've had a working setup of this feature in another project so decided to make a quick PR #261 Edit: looks like it's not gonna be so easy since we use pnpm smiley_cat

Woow, pretty cool. Didn't know something like that existed. We can fork it and make the necessary changes :rocket:

Edit: Ok, don't know why to rewrite it using pnpm :sweat_smile: Can you elaborate more on that?

takanome-dev avatar Feb 22 '23 22:02 takanome-dev

May be this can be useful for this issues?

https://autofix.ci/ https://autofix.ci/setup#typescript

navin-moorthy avatar Jul 11 '23 11:07 navin-moorthy

If it can offer to fix things, rather than just do it always, then great!

JoshuaKGoldberg avatar Jul 11 '23 14:07 JoshuaKGoldberg

This is a cool idea. Fact.

johnnyreilly avatar Apr 26 '24 04:04 johnnyreilly