prettier/prettier-eslint

Shouldn't this be the other way around? "This formats your code via prettier, and then passes the result of that to eslint --fix."

Closed this issue · 6 comments

Versions:

  • prettier-eslint version: n/a
  • node version: v18.17.1
  • npm (or yarn) version: 9.6.7

This is more of a question or documentation request than a bug. The readme says,

This formats your code via prettier, and then passes the result of that to eslint --fix.

Wouldn't it make more sense to run eslint --fix THEN prettier instead of the other way around? My use case is the curly rule. eslint --fix will change

if (foo) foo++;

to

if (foo) {foo++};

and prettier will change it to this:

if (foo) {
  foo++
};

I may not be exactly right on the specifics of the formatting, but my point is that eslint --fix adds the curly braces and prettier formats them. If prettier runs first, the code will be left in this state:

if (foo) {foo++};

and, on a second run, the code will change again to this:

if (foo) {
  foo++
};

Is the curly rule a weird edge case, am I misinterpreting this repo's documentation, or am I confused in some other way?

https://github.com/prettier/prettier-eslint?tab=readme-ov-file#prettierlast-boolean

Please read document more carefully.

And people using this tool prefer prettier but with some exception and want to leave it to ESLint fixing.

@JounQin Thank you for the link. When you say, "And people using this tool prefer prettier but with some exception and want to leave it to ESLint fixing," do you mean people using this tool prefer to overwrite prettier's formatting changes with ESLint's formatting changes?

Yes, and that's why this tool is made for.

Maybe we should rerun the flow until the formatting is stable.

Yes, and that's why this tool is made for.

Thanks for the explanation. Are you aware all the eslint formatting options will soon be deprecated?

Maybe we should rerun the flow until the formatting is stable.

Maybe. But that sounds like it would have a performance cost.