8000 Add a pre-commit configuration file and adopt Prettier by pradyunsg · Pull Request #910 · toml-lang/toml · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Add a pre-commit configuration file and adopt Prettier #910

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
Jul 31, 2022

Conversation

pradyunsg
Copy link
Member

This makes it easier to set up linters that check for various things
within the repository.

@pradyunsg pradyunsg added the task label Jun 18, 2022
@pradyunsg
8000 Copy link
Member Author

Well, I've been procrastinating on this for a while. :)

@pradyunsg pradyunsg changed the title Add a pre-commit configuration file Add a pre-commit configuration file and adopt Prettier Jun 18, 2022
@pradyunsg
Copy link
Member Author

I'm gonna leave this up for a bit, to let folks chime in with thoughts on this. I'm assuming no one's gonna be strongly opposed, but I'm open to being surprised. :)

@marzer
Copy link
Contributor
marzer commented Jun 20, 2022

FYI this has conflicts with these PRs:

(and probably others, I didn't check the rest.)

They've been open quite a while at this stage (#796 in particular). Can they be actioned first? Adding additional conflicts to them is only going to add (potentially many) more months worth of iteration to them. I think an auto-formatter is probably best applied after all the other outstanding spec changes are dealt with, so it hits them all at once.

@ChristianSi
Copy link
Contributor
ChristianSi commented Jun 21, 2022

I agree, let's finish the unfinished business first.

Also, to avoid the noise, I'd suggest to configure the pretty printer so as to make its output similar to the current Markdown style used, in order to just remove inconsistencies rather than changing everything. In particular, this seems to mean:

  • List items start with *.
  • Underlining (===, ---) is used for headers.

Otherwise this looks good.

@eksortso
Copy link
Contributor

I agree, let's finish the unfinished business first.

Agreed.

Also, to avoid the noise, I'd suggest to configure the pretty printer so as to make its output similar to the current Markdown style used
[[...]]

In the long run, it would make sense to use the default Markdown style. One less thing to worry about.

However, I think there's a way to configure Prettier with a TOML file. Correct me if I'm wrong, but the Prettier docs say that .prettierrc.toml in the project's root folder can enforce our current style. I'm a big fan of dogfooding, so if we can get a .prettierrc.toml file set up, then let's do what @ChristianSi said.

@ChristianSi
Copy link
Contributor
ChristianSi commented Jun 22, 2022

IMHO there is no such thing as a "default Markdown style", at least not when it comes to stuff such as * vs. - for lists or underlining vs. # for headers. Either is equally fine.

However, while Prettier is configurable to some degree, I cannot see any options that control how Markdown output is formatted. Maybe I'm just overlooking something?

If not, I'd suggest to look for another tool that's flexible enough to do a good job. This one, as far as I can tell, was mostly developed for JavaScript code, the Markdown support seems just a minor add-on and (I suspect) not all that well developed.

8000

@abelbraaksma
Copy link
Contributor

I’ve no problem with having a standard style for markdown. I’d prefer * over - for bullets, but that’s just a personal preference.

@pradyunsg, as others have already mentioned, there are quite a few completed, verified, agreed upon PRs open. Before we merge this one in, those others should be merged. If there’s anything we can do to help to make this easier, please let us know (including adding new maintainers).

This makes it easier to set up linters that check for various things
within the repository.
This helps ensure that all the files within the repository have a
consistent style.
This enforces that all Markdown files are wrapped at 80 characters,
in the style the prettier follows.
@pradyunsg pradyunsg force-pushed the manual-pre-commit-fixes branch from 11ce6f0 to be51db4 Compare July 30, 2022 16:12
@pradyunsg
Copy link
Member Author

Can they be actioned first?

Done. ;)

#891 is gonna need more discussion, and spec language change -- so I don't wanna block on that.

[* vs. - for lists, underlines vs. # for headers, keeping consistency with status quo]

As far as I am concerned, having an automated tool do the formatting for me is super useful, because -- as long as the output is understandable and "sane" -- it's very useful to have the tool enforce a consistent style across the project wherein no one needs to debate about style choices.

The defaults of prettier are workable, with the line length enforcement being useful for easier-to-review diffs on the GitHub UI (which doesn't do too well with long lines, but highlights changed words).

@arp242
Copy link
Member
arp242 commented Jul 30, 2022

Might be nice to document what the max line length is now; it seems shorter than 80 based on this patch; it's now 79? 78? 76?

Can maybe also add .editorconfig:

root = true
[*.md]
max_line_length = 78  # Or whatever it is.
indent_style = space  # Might as well add this too.

@pradyunsg
Copy link
Member Author

It's 80, which is the default -- https://prettier.io/docs/en/options.html#print-width

@abelbraaksma
Copy link
Contributor

#891 is gonna need more discussion, and spec language change -- so I don't wanna block on that.

No worries, I’ll be able to deal with some reformatting there.

@pradyunsg pradyunsg merged commit a418a44 into main Jul 31, 2022
@pradyunsg pradyunsg deleted the manual-pre-commit-fixes branch July 31, 2022 09:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants
0