nrwl / precise-commits

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

Difference between original Prettier #6

Closed defusioner closed 6 years ago

defusioner commented 6 years ago

Is this normal that the original Prettier run transforms the code:

const a = "a"

to

const a = 'a';

, when precise-commit doesn't do it ? ("a" stays always "a" and not 'a').

What are another style differences from the original one?

JamesHenry commented 6 years ago

Hi @defusioner, please can you provide a reproduction of Prettier doing that by default?

Here is my attempt using the official Prettier playground: https://prettier.io/playground/#N4Igxg9gdgLgprEAuc0DOMAEBDTBeTAHRG2JABoQIAHGAS3WVGwCcWIB3ABVYTWRIA3CHQAmFEhmQAzbABs0cSgCMW2MAGs4MAMrV1dKAHNkMFgFclIURDAz5iyocUsYXNUYC22ewqsArNAAPACE1TW0dbE84ABlDOF9HKnMYalSAJiSrfRYXAWVsZQBPOWgJahZDGAB1MRgAC2QADgAGSkqIRRq1agFKuBdBRMoWOABHczox92wvHyRZP0pFTzpTCys0QyM5OABFcwh4bMoYIrrRRuQMs7U6OR2AYQhPbwEoaBGQc0UAFSK-EWDjgAF9QUA

As you can see the input:

const a = "a"

Produces the output:

const a = "a";

precise-commits should not be affecting your prettier configuration, nor its defaults.

defusioner commented 6 years ago

@JamesHenry well, what do I have:

[TAB][TAB]const a = 'a' -> const a = "a"; via playground.

https://prettier.io/playground/#N4Igxg9gdgLgprEAuEAdG7JQM4wAQCGeAvHgOQFkgA0IEADjAJbTbKgEBOnEA7gApcEbFAQBuEJgBMaIArmQAzAgBtscWgCNOBMAGs4MAMr1dTKAHNkMTgFcNIKRDBLV62ufWcY-HRYC2BK5qDgBW2AAeAEI6+oZGBP5wADLmcMHudLYw9NkATBkOppxeyCCaBJoAnirQsvSc5jAA6tIwABbIABwADLQNEOrNOvRlDXBeYum0nHAAjrZMs74EAUFIyiG06v5M1nYO2OYWKnAAirYQ8IW0MJWtUh3Iebc6TCrHAMIQ-oFlUNBpiBbOoACqVESbdQAX2hQA

Installed Prettier 1.10.1 (configured as external tool in my IDEA), gives:

[TAB][TAB]const a = "a" -> const a = 'a';

Precise commits during a commit gives me:

if (true){ [TAB][TAB] const a = "a" }

Transformed into: if (true){ const a = "a"; }

So something seems not to be right.. I have just installed Prettier's 1.10.1 version globally.

I have same versions of prettier in my project and one installed globally.

JamesHenry commented 6 years ago

I think you are confirming above that precise-commits is indeed behaving as expected with regards to applying prettier (and using its default behaviour). Your playground example and your example with precise-commits are identical.

It seems like you have potentially set some configuration within your IDE which is overriding prettier's default for the singleQuote option. It is false by default, but it seems like you must have set it to true somewhere.

Not knowing what IDE you are using I can't really help any further, but I would try and find where you have configured the prettier extension you are using as a next step.

As this is not related to precise-commits I am going to close the issue for now.