cookiecutter-scverse icon indicating copy to clipboard operation
cookiecutter-scverse copied to clipboard

Prettier alternatives

Open grst opened this issue 1 year ago • 8 comments

Prettier requires a full-blown node installation and is rather slow. Alternatives would be welcome.

Maybe we soon don't need prettier anymore: https://biomejs.dev/

It doesn't have yaml support yet though

Originally posted by @flying-sheep in https://github.com/scverse/cookiecutter-scverse/issues/277#issuecomment-2073522201

grst avatar May 18 '24 05:05 grst

https://github.com/pre-commit/mirrors-prettier

is now archived completely

Zethson avatar Jun 20 '24 09:06 Zethson

I can’t add anything to what @henryiii said in https://github.com/prettier/prettier/issues/15742#issuecomment-2118548722

Not just deprecated: the mirror was archived at 4.0.0-alpha.8. Without any notice on how to replace it, just the notice "prettier made some changes that breaks plugins entirely". 6,500 projects use this hook, including more than a dozen of mine.

… and the following comment:

the mirrors-prettier plugin seems to work perfectly fine for me without having to change anything from the example in the docs. i have no idea why asottile would archive the repo with such a useless, unhelpful message like "prettier made some changes that breaks plugins entirely" without any information as to what exactly the issue was, but that's to be expected considering how rude he is to anybody who tries to raise an issue on any of his projects.

pre-commit is just so damn convenient. If there was a trivial way to get auto-formatting of PRs working with just GitHub actions, maybe not using pre-commit would be a good path.

flying-sheep avatar Jun 20 '24 10:06 flying-sheep

@g-plane said

How about considering dprint? It has more languages support which contains YAML.

flying-sheep avatar Aug 29 '24 10:08 flying-sheep

@g-plane @grst please use the issue for discussion.

dprint looks interesting too! But:

  • They don’t have official pre-commit support (yet?): https://github.com/dprint/dprint/issues/442
  • They don’t plan to support EditorConfig: https://github.com/dprint/dprint/issues/4
  • edit: Also there is little tool support, e.g. the VS Code extensions can’t download it and will instead use a global binary in $PATH (which users would need to provide themselves) or load it “from node_modules” (which doesn’t even exist in every npm project because of yarn 2)

flying-sheep avatar Aug 29 '24 10:08 flying-sheep

[...] will instead use a global binary in $PATH (which users would need to provide themselves) or load it “from node_modules” (which doesn’t even exist in every npm project because of yarn 2)

You can add "dprint.path": "node_modules/dprint/dprint" to your VSCode workspace settings

Avasam avatar Sep 23 '24 16:09 Avasam

FWIW, the mirrors suggested in the issue work fine, I've been using https://github.com/rbubley/mirrors-prettier and it's been fine.

henryiii avatar Sep 23 '24 17:09 henryiii

@henryiii Are you using a paid version of pre-commit.ci ? I thought that dprint downloading plugins at runtime would make it impossible to use with pre-commit.ci for free . https://github.com/dprint/dprint/issues/442#issuecomment-2219067045

Edit: sorry I completely misread and interpreted as you saying you're using the dprint mirror....

Avasam avatar Sep 23 '24 17:09 Avasam

I'm using prettier, as you can see above. :)

henryiii avatar Sep 23 '24 18:09 henryiii

Just got pointed to this: https://prettier.io/blog/2023/11/30/cli-deep-dive

Apparently prettier is working on a next-gen CLI that's faster

grst avatar Nov 04 '24 13:11 grst

Biome has editorconfig support and a tagged pre-commit repo, so apart from YAML formatting, it does everything we could want now. I updated #304

flying-sheep avatar Feb 19 '25 11:02 flying-sheep

What about markdown?

grst avatar Feb 19 '25 18:02 grst

I don’t think it’s wise to use MyST together with a formatter that doesn’t understand MyST syntax and will therefore happily destroy meaningful syntactical constructs.

flying-sheep avatar Feb 20 '25 09:02 flying-sheep

We could have mdformat as a dedicated hook for markdown formatting. Allegedly, it supports myst.

grst avatar Feb 24 '25 15:02 grst

looks good, but that’d be a big PR reformatting everything. How about we merge #304 and then go for it before the next release?

flying-sheep avatar Feb 24 '25 17:02 flying-sheep

yes... we can make the next release at the paris hackathon.

grst avatar Feb 24 '25 17:02 grst

Actually, there’s a blocker for mdformat: https://github.com/executablebooks/mdformat-myst/issues/13

flying-sheep avatar Feb 24 '25 17:02 flying-sheep

I guess we could disable colon fences in the myst configuration?

grst avatar Feb 25 '25 09:02 grst

We could, but that would

  1. break things for people using cruft who use them.
  2. potentially break things for people using any myst extensions that aren’t part of the default list: https://github.com/executablebooks/mdformat-myst/issues/13#issuecomment-982142237

So I’ll go ahead with #304 anyway, because the same applies for prettier, and the question if we should have any markdown formatting together with MyST is out-of-scope for #304.

flying-sheep avatar Feb 25 '25 10:02 flying-sheep

I filed https://github.com/scverse/cookiecutter-scverse/issues/353 for the MDFormat part of this

flying-sheep avatar Feb 25 '25 10:02 flying-sheep