-
Notifications
You must be signed in to change notification settings - Fork 375
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
maint: Add prettier pre-commit hook #3663
Conversation
hooks: | ||
- id: rst-backticks | ||
- id: rst-directive-colons | ||
- id: rst-inline-touching-normal | ||
- id: rst-backticks |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This an example when existing hooks allow different styles (even in the same file)
@@ -5,28 +5,25 @@ repos: | |||
hooks: | |||
- id: trailing-whitespace | |||
- id: end-of-file-fixer | |||
- id: fix-encoding-pragma |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is deprecated
- id: check-yaml | ||
exclude: ^.+(/tests/|/recipe/).+$ | ||
- id: check-toml | ||
- id: check-json | ||
- id: check-merge-conflict | ||
- id: pretty-format-json | ||
args: [--autofix] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These checks (except check-merge-conflict
) no longer seem to be needed
- id: debug-statements | ||
language_version: python3 | ||
# Autoformat: YAML, JSON, Markdown, etc. | ||
- repo: https://github.com/rbubley/mirrors-prettier |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using a fork, since official prettier pre-commit hook has been archived:
http://github.com/prettier/prettier/issues/15742
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hum, I'm kind of reluctant here. As I'm in favor of general improvements, using something that just has been archived (even if a mirror is available) doesn't seem a good idea to me.
https://github.com/rbubley/mirrors-prettier
seems to rather be a workaround to let people keep using the hook and there are no guarantees that it will be maintained in the long term.
I would highly suggest to wait until a stable solution is available (could be something used by a significant number of people, regularly maintained, or officially superseding the archived one in pre-commit
).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is an important gotcha: the https://github.com/rbubley/mirrors-prettier is not a mirror/fork of prettier
ore pre-commit
.
It's a small repo to make vanilla prettier
work as pre-commit
hook.
If you take a look at the source code, you'll see that the part which matters is less than 100 lines.
So, there is not much to maintain and the code to automatically update the version of the prettier
is already there.
Even in the worst case scenario, this fork will stop updating, we will have some prettier version in this repo.
It's already working great for lots of files like json/yaml/toml/markdown.
I don't think these files have that much new syntax features added to them (unlike python/c++ code, where you really want tools to work with newer code as well).
So, it's unlikely we'll encounter issues due to not using the latest version.
And the sooner we add prettier, the less diff this PR will generate.
@@ -39,8 +39,7 @@ def template_substitute(contents): | |||
today = datetime.date.today() | |||
fmt_today = today.strftime("%B %d, %Y") | |||
|
|||
header_line = f"{name} {version} ({fmt_today})" | |||
res += f"{header_line}\n{'=' * len(header_line)}\n\n" | |||
res += f"# {name} {version} ({fmt_today})\n\n" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
releaser.py
and changelog.py
are changed manually by me, to make sure new changelogs are written correctly
@@ -40,15 +39,14 @@ Bug fixes: | |||
- [libmamba, micromamba] Create empty base prefix with `env update` by @Hind-M in https://github.com/mamba-org/mamba/pull/3519 | |||
- [libmamba, micromamba] fix: Use POSIX-compliant scripts by @jjerphan in https://github.com/mamba-org/mamba/pull/3522 | |||
- [libmamba, micromamba] maint: Clarify `env` subcommand documentation in help menu (cont'd) by @jjerphan in https://github.com/mamba-org/mamba/pull/3539 | |||
- [libmamba] fix: Handle space in `mamba` and `micromamba` executable absolute paths by @NewUserHa in https://github.com/mamba-org/mamba/pull/3525 | |||
- [libmamba] fix: Handle space in `mamba` and `micromamba` executable absolute paths by @NewUserHa in https://github.com/mamba-org/mamba/pull/3525 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sometimes prettier fixes double space and some other minor things in markdown text, don't think this is gonna cause trouble
Please, let me know if you don't like PRs with improvements to tooling around the code quality. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for this proposal, @mathbunnyru.
I am not against it, but I think we should ignore the formatting done by this PR then.
I am waiting for someone else from the team to comment.
Any other opinion on this @Klaim @JohanMabille? |
I don't have a clear opinion at the moment but a few notes:
|
96320fa
to
2fc282a
Compare
Please, take a look here: #3663 (comment)
Unfortunately not: prettier/prettier-vscode#352
|
2fc282a
to
b262d49
Compare
I rebased and improved my commits - now Apply prettier pre-commit hook is where I actually run I also ran |
@Klaim @jjerphan @Hind-M please, take a look, and if you have any questions, let me know. I understand, that this is not straightforward PR, and there is a decision to be made, and I'm ok if you want to close the PR, rather than merge it. At the same time, I think, all the files look significantly better than before. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM iif there's a (optional) way to ignore the diff of the merge commit of this PR via blame.ignoreRevsFile
. I am waiting for the rest of the team's opinion in this regard.
Thanks! I think you will squash the contents of this PR (if you decide to merge it), so I can only update I don't want to squash manually here, because it's quite difficult to rebase and review such PRs when everything is in one commit. |
I dont have any strong opinion about this, either way I'll follow what the rest of the team prefer. Maybe @JohanMabille has some opinon? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM if it leads to improvements.
Just a side note on ignoring the diff of the merge commit, I think we should be consistent with the repo history here. And since previous changes on the pre-commit hooks were never ignored, we should continue that approach. Otherwise, we should consider ignoring all of them to avoid potential confusion for anyone reviewing the commit history without context.
I would be in favor of doing this after the merge. |
Great, as soon as this gets merged, I will add all commits that changed |
Created a PR to unify the process of making such changes. |
Thank you for your patience, @mathbunnyru. |
prettier
is a much better tool than using hooks fromhttps://github.com/pre-commit/pre-commit-hooks
- the style is much better, always consistent and it actually works