Skip to content
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

Issue with pretier 4.0.0@alpha3 and pre-commit #15742

Open
Goldziher opened this issue Dec 1, 2023 · 11 comments
Open

Issue with pretier 4.0.0@alpha3 and pre-commit #15742

Goldziher opened this issue Dec 1, 2023 · 11 comments
Labels
area:cli Issues with Prettier's Command Line Interface status:needs investigation Issues that need additional investigation, e.g. to understand whether the reported behavior is a bug

Comments

@Goldziher
Copy link

Hi there,

Updating the pre-commit hook to the latest version causes the following error:

  The "--list-different" and "--write" flags cannot be used together

This has been the case since 4.0.0@alpha1.

@kachkaev kachkaev added area:cli Issues with Prettier's Command Line Interface status:needs investigation Issues that need additional investigation, e.g. to understand whether the reported behavior is a bug labels Dec 1, 2023
@acdha
Copy link
Contributor

acdha commented Dec 1, 2023

For anyone else hitting this, adding PRETTIER_LEGACY_CLI=1 to our global CI environment was an effective fix.

acdha referenced this issue in pre-commit/mirrors-prettier Dec 1, 2023
@ma11011s
Copy link

ma11011s commented Dec 4, 2023

For anyone that uses mirrors-prettier with pre-commit:

  - repo: https://github.com/pre-commit/mirrors-prettier
    rev: v4.0.0-alpha.3
    hooks:
      - id: prettier
        entry: env PRETTIER_LEGACY_CLI=1 prettier

stefanv added a commit to numpy/numpydoc that referenced this issue Dec 4, 2023
matthiask added a commit to jazzband/django-debug-toolbar that referenced this issue Dec 4, 2023
GriceTurrble added a commit to GriceTurrble/advent-of-code that referenced this issue Dec 4, 2023
effigies added a commit to bids-standard/bids-specification that referenced this issue Dec 4, 2023
@mpoli
Copy link

mpoli commented Dec 4, 2023

PRETTIER_LEGACY_CLI=1 isn't working for me.

It changes error behavior and now I have dozens of:

[error] No parser could be inferred for file .....

effigies added a commit to bids-standard/bids-specification that referenced this issue Dec 4, 2023
* [pre-commit.ci] pre-commit autoupdate

updates:
- [github.com/pre-commit/mirrors-prettier: v3.1.0 → v4.0.0-alpha.3](pre-commit/mirrors-prettier@v3.1.0...v4.0.0-alpha.3)

* Work around prettier/prettier#15742

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Chris Markiewicz <markiewicz@stanford.edu>
@Pierre-Sassoulas
Copy link

The issue lie with the prettier mirror env, here. pre-commit already fails when a file is modified by a hook, so --list-different is useless. It should be fixed soon or it's possible to directly use:

-   id: prettier
    name: prettier
    description: ''
    entry: prettier --write --ignore-unknown
    language: node
    'types': [text]
    args: []
    require_serial: false
    additional_dependencies: ["prettier@4.0.0-alpha.3"]
    minimum_pre_commit_version: '0'

(Note however that ["prettier@4.0.0-alpha.3"] won't update automatically with pre-commit autoupdate)

StarHeartHunt added a commit to nonebot/nb-cli that referenced this issue Dec 5, 2023
StarHeartHunt added a commit to nonebot/adapter-feishu that referenced this issue Dec 5, 2023
yanyongyu pushed a commit to nonebot/nb-cli that referenced this issue Dec 5, 2023
sengels-tum added a commit to cda-tum/mtct that referenced this issue Dec 6, 2023
sengels-tum added a commit to cda-tum/mtct that referenced this issue Dec 6, 2023
* ⬆️🪝 update pre-commit hooks

updates:
- [github.com/pre-commit/mirrors-clang-format: v17.0.5 → v17.0.6](pre-commit/mirrors-clang-format@v17.0.5...v17.0.6)
- [github.com/pre-commit/mirrors-prettier: v3.1.0 → v4.0.0-alpha.3](pre-commit/mirrors-prettier@v3.1.0...v4.0.0-alpha.3)

* Workaround for error message

See prettier/prettier#15742

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Stefan Engels <112686201+sengels-tum@users.noreply.github.com>
BalconyJH added a commit to BalconyJH/nonebot_plugin_bh3_elysian_realm that referenced this issue Dec 17, 2023
lpilz added a commit to xarray-contrib/xwrf that referenced this issue Dec 18, 2023
* cf. prettier/prettier#15742
* this doesn't work locally for me, testing it in CI. Otherwise changing to prettier/pre-commit
AzideCupric added a commit to GuGuMur/nonebot-plugin-skland-arksign that referenced this issue Jan 3, 2024
AzideCupric added a commit to GuGuMur/nonebot-plugin-skland-arksign that referenced this issue Jan 3, 2024
* 🔧 添加editorconfig

* ⬆️ set prettier to v4.0.0-alpha8 to avoid prettier/prettier#15742

* 👷 更改ci发版方式
@jamesbraza
Copy link

I just opened a related issue #16076, which points out https://github.com/pre-commit/mirrors-prettier stopped supporting prettier v3 after v3.1.0, even though v3 releases are still being cut

@michaelfarrell76
Copy link

it appears that mirrors-prettier is deprecated and no longer in use but it's still the recommended setup in the official prettier docs: https://prettier.io/docs/en/precommit.html

could someone update the recommended configuration using prettier and pre-commit now that this repo is deprecated?

@michaelfarrell76
Copy link

this is what we are using now in our pre commit config with prettier version 4.0.0-alpha.8:

- id: prettier
        name: Prettier
        language: node
        entry: yarn
        args: [run, prettier, --write, --ignore-unknown]
        types: [file]

i think this is doing what we need where it's only running prettier against files that are staged. and has the added benefit of our .prettierignore file being respected rather than using the pre-commit exclude statement.

@henryiii
Copy link

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.

@benoit9126
Copy link

The prettier website also refers to the mirror for pre-commit usage here

@DetachHead
Copy link

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.

as far as i can tell, the issue seems to be resolved in the latest beta (4.0.0@alpha8, the version it was archived at).

@Pierre-Sassoulas
Copy link

Pierre-Sassoulas commented May 29, 2024

as far as i can tell, the issue seems to be resolved in the latest beta (4.0.0@alpha8, the version it was archived at).

It was fixed in pre-commit/mirrors-prettier#51 (so for 4.0.0@alpha3 to 4.0.0@alpha8). But the repo is now archived and not releasing new tags. New tags are required for easy prettier upgrades through pre-commit autoupgrade. (It only have v3.1.0 but not above that, when 7 versions were released since, the current latest being v3.2.5).

It would be nice if prettier had this pre-commit config directly in the main repository so a mirror is not required, but I can understand if they don't want to do it. In any case a change in documentation to remove the archived mirror seems warranted.

Edit after digging:
Currently there's been an update of the doc: #16229
rbubley made a fork of the mirror: https://github.com/rbubley/mirrors-prettier
prettier won't consider the new mirror until pre-commit "makes it official": #16229 (comment)
pre-commit won't make it official: pre-commit/pre-commit.com#957

I think the easier fix is to use the for of the mirror by rbubley , but you really need some digging before finding it atm :)

Pierre-Sassoulas added a commit to Pierre-Sassoulas/django-zxcvbn-password-validator that referenced this issue May 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:cli Issues with Prettier's Command Line Interface status:needs investigation Issues that need additional investigation, e.g. to understand whether the reported behavior is a bug
Projects
None yet
Development

No branches or pull requests