nrwl / precise-commits

:sparkles: Painlessly apply Prettier by only formatting lines you have modified anyway!
MIT License
471 stars 20 forks source link

Doesnt seem to work when requirePragma: true #9

Closed omasback closed 6 years ago

omasback commented 6 years ago

Not sure if this is a bug in your code or prettier. I tried to run prettier cli with a range and it didn't work. So it seems that either this is a bug in prettier or i didnt enter the CLI range options right.

JamesHenry commented 6 years ago

Please could you share how you are setting up and running precise-commits in this case? (Including any prettier config etc)

omasback commented 6 years ago

My package.json: image

My .prettierrc: image

How I test:

  1. Save some bad formatting to a file.
  2. git add .
  3. npm run precise-commits
  4. --> No formatting changes required in: [file]
  5. change requirePragma to false in .prettierrc
  6. repeat steps 1-3
  7. --> Updated formatting in: [file]

(And yes I am sure I have the correct pragma in the file. When I turn on formatOnSave in my editor, the editor's prettier plugin formats the file.)

JamesHenry commented 6 years ago

Thanks a lot for providing all the details @omasback!

I can reproduce the issue within precise-commits, but more importantly also with just prettier directly. It would appear rangeStart and rangeEnd cannot easily be combined with requirePragma at the moment.

I have reported it in the prettier repo directly here: https://github.com/prettier/prettier/issues/3985

omasback commented 6 years ago

Cool, that was my experience as well trying to use prettier CLI with range and pragma combined. Thanks for making that issue!

JamesHenry commented 6 years ago

The underlying prettier issue should have now been fixed