Skip to content

Add --prettier flag for Prettier-formatted changelogs#155

Merged
danroc merged 6 commits intomainfrom
feature/use-prettier
Sep 22, 2023
Merged

Add --prettier flag for Prettier-formatted changelogs#155
danroc merged 6 commits intomainfrom
feature/use-prettier

Conversation

@danroc
Copy link
Copy Markdown
Contributor

@danroc danroc commented Sep 22, 2023

This PR adds a new --prettier flag. When enabled, this flag signals that the tool should expect the changelog to be formatted using Prettier. By default, this flag is set to false, ensuring backward compatibility with all existing CHANGELOG.md files.

The primary motivation for this change is to overcome a current limitation of auto-changelog. At present, our tool does not support the changelog format provided by Keep a Changelog (version ^1.1.0).

Fixes: #60

@danroc danroc force-pushed the feature/use-prettier branch from 976f9ce to 79caa80 Compare September 22, 2023 11:52
@danroc danroc marked this pull request as ready for review September 22, 2023 12:28
@danroc danroc requested a review from a team as a code owner September 22, 2023 12:28
Copy link
Copy Markdown
Member

@Mrtenz Mrtenz left a comment

Choose a reason for hiding this comment

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

Rather than running Prettier programatically, couldn't we just remove the changelog from the ignore list, and disable formatting with a flag?

https://github.com/MetaMask/metamask-module-template/blob/main/package.json#L45

@danroc
Copy link
Copy Markdown
Contributor Author

danroc commented Sep 22, 2023

I'm not sure. The update command would need to be paired with an external formater everytime it's executed. But we could add another flag (--ignore-formatting?) available only for validate.

@Mrtenz
Copy link
Copy Markdown
Member

Mrtenz commented Sep 22, 2023

I'm not sure. The update command would need to be paired with an external formater everytime it's executed. But we could add another flag (--ignore-formatting?) available only for validate.

We run Prettier regardless, hence why it's currently ignored.

@Gudahtt
Copy link
Copy Markdown
Member

Gudahtt commented Sep 22, 2023

Not always at the same time as updating the changelog though.

There's also the validate command; it's sensitive to formatting changes so we'd need to run prettier programmatically during validation to avoid breaking that.

@danroc
Copy link
Copy Markdown
Contributor Author

danroc commented Sep 22, 2023

If we ignore formating, enforcing that the sections are always in the same order may be more complex.

Yes @Gudahtt, this is why I passed the formatter to both validate and update commands.

@Mrtenz
Copy link
Copy Markdown
Member

Mrtenz commented Sep 22, 2023

Ok, makes sense!

@danroc
Copy link
Copy Markdown
Contributor Author

danroc commented Sep 22, 2023

If we are not willing to add a formatter, I suppose I could workaround like this:

Replace update with:

auto-changelog update && prettier

And replace validate with:

auto-changelog validate --fix && prettier

and then check if the CHANGELOG.md file changed, although it's not very elegant.

Copy link
Copy Markdown
Member

@Gudahtt Gudahtt left a comment

Choose a reason for hiding this comment

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

LGTM!

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.

Incompatibilities with some markdownlint rules

3 participants