Skip to content

chore: add workflow to automatically run prettier when renovate updates it #6370

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 2 commits into from
Jun 4, 2023

Conversation

JamesHenry
Copy link
Member

PR Checklist

Overview

If a prettier update causes formatting to change (which it usually does) then right now a maintainer has to manually update the relevant renovate PR by running yarn format locally and committing the results.

After this PR goes in, that yarn format and commit step will be done automatically on the PR without any maintainer involvement

@typescript-eslint
Copy link
Contributor

Thanks for the PR, @JamesHenry!

typescript-eslint is a 100% community driven project, and we are incredibly grateful that you are contributing to that community.

The core maintainers work on this in their personal time, so please understand that it may not be possible for them to review your work immediately.

Thanks again!


🙏 Please, if you or your company is finding typescript-eslint valuable, help us sustain the project by sponsoring it transparently on https://opencollective.com/typescript-eslint.

@nx-cloud
Copy link

nx-cloud bot commented Jan 23, 2023

☁️ Nx Cloud Report

CI is running/has finished running commands for commit cf25963. As they complete they will appear below. Click to see the status, the terminal output, and the build insights.

📂 See all runs for this branch


✅ Successfully ran 47 targets

Sent with 💌 from NxCloud.

@netlify
Copy link

netlify bot commented Jan 23, 2023

Deploy Preview for typescript-eslint ready!

Name Link
🔨 Latest commit ade7707
🔍 Latest deploy log https://app.netlify.com/sites/typescript-eslint/deploys/647cb107d157220008663e80
😎 Deploy Preview https://deploy-preview-6370--typescript-eslint.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

Copy link
Member

@JoshuaKGoldberg JoshuaKGoldberg left a comment

Choose a reason for hiding this comment

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

It would have been nice to get this natively in Renovate with postUpgradeTasks but it says they're only supported in self-hosted instances 😞...

{
  "postUpgradeTasks": {
    "commands": ["yarn format"],
    "fileFilters": ["**/*"]
  }
}

But, this feels like something a lot of repos have to solve in more situations. Surely folks need this whenever they update Prettier? So it's something I think we should tackle more holistically.

What about a post-commit hook to run yarn format when the root package.json changes? [their closest example, ignoring filename changes]

@JoshuaKGoldberg JoshuaKGoldberg added the awaiting response Issues waiting for a reply from the OP or another party label Jan 23, 2023
@JamesHenry
Copy link
Member Author

@JoshuaKGoldberg would a local hook be triggered/included in renovate's commit though?

@JoshuaKGoldberg
Copy link
Member

Hmm, good question. I don't actually know. Never mind me 😄

Copy link
Member

@JoshuaKGoldberg JoshuaKGoldberg left a comment

Choose a reason for hiding this comment

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

:shipit: Thanks!

Comment on lines +36 to +37
yarn --ignore-scripts
yarn format
Copy link
Member

Choose a reason for hiding this comment

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

For a bit faster install, maybe?

Suggested change
yarn --ignore-scripts
yarn format
npx prettier --write .

Copy link
Member

Choose a reason for hiding this comment

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

will npx respect the package.json version of prettier?

Copy link
Member

Choose a reason for hiding this comment

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

It goes with the latest by default, which should be what the PR is upgrading to anyway.

@bradzacher bradzacher added the repo maintenance things to do with maintenance of the repo, and not with code/docs label Mar 15, 2023
@JamesHenry JamesHenry merged commit 8292c70 into main Jun 4, 2023
@JamesHenry JamesHenry deleted the automated-prettier-update branch June 4, 2023 15:51
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 12, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
awaiting response Issues waiting for a reply from the OP or another party repo maintenance things to do with maintenance of the repo, and not with code/docs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants