prettier-eslint icon indicating copy to clipboard operation
prettier-eslint copied to clipboard

prettier-eslint doesn't respect prettier default

Open AdrienLemaire opened this issue 5 years ago • 5 comments
trafficstars

from inferring prettierOptions via eslintConfig:

Defaults if you have all of the relevant ESLint rules disabled (or have ESLint disabled entirely via /* eslint-disable */ then prettier options will fall back to the prettier defaults:

{
  trailingComma: 'none',
}

Prettier Trailing Commas:

Default value changed from none to es5 in v2.0.0 "es5" - Trailing commas where valid in ES5 (objects, arrays, etc.)

As a result, When I save my file, prettier-eslint removes a trailing commas, and when I git commit my code, the pre-commit prettier hook fails and re-add the trailing comma.

Fixed by adding .prettierrc:

trailingComma: "es5"

It took me a while to figure out, just because I assumed the plugin respected prettier's default.

AdrienLemaire avatar May 28 '20 05:05 AdrienLemaire

Stale issue

github-actions[bot] avatar Jul 28 '20 00:07 github-actions[bot]

Definitely worth a fix, since the default value changed in v2.

Obviously, not a huge priority cuz you can just create a .prettierrc to get what you want!

kylemh avatar Jul 31 '20 17:07 kylemh

Stale issue

github-actions[bot] avatar Sep 30 '20 00:09 github-actions[bot]

I just hit this problem too, but only after upgrading to Prettier V2. Because es5 trailing commas is now default in prettier, I removed it from my .prettierrc and later noticed that trailing commas were being removed.

It was quite annoying to notice that trailing commas were sneaking back into the codebase and took a while to figure out that the problem is that this plugin is the cause.

Generally, it seems very strange that prettier-eslint doesn't use prettier defaults.... 😕

lougreenwood avatar Nov 11 '20 12:11 lougreenwood

To explain: it did and we fully intend on doing so again.

Prettier changed the defaults and we just never updated it here.

Should be a very simple PR!

kylemh avatar Nov 11 '20 12:11 kylemh

close in favor of #334

JounQin avatar Aug 15 '22 04:08 JounQin