Result of "idea format" in terminal differs from the in editor formatter
已回答
Dear Intellij Team,
as our team grows, the diversity of editors in use is also growing. Intellij has a very specific import order/layout that we want to use in the other editors as well. Unfortunately the basic editorconfig doesn't support all the properties needed, so we came up with the solution to format all the edited files in a pre-commit hook. I was sure formatting via cli respects the editorconfig file and all of ideas special properties but it doesn't seem so. The cli formatter reorganizes the imports differently than the formatter in the editor itself.
Is there a solution for this?
Regards,
Afgeoijlejk
请先登录再写评论。
Could you please provide a code example to reproduce a problem?
I think the problem is more of a feature request. The formatter works fine when given a code style file to apply. But the import order stays the same after applying formatting from another formatter. The idea cli formatter doesn't have options like "optimize imports" or anything like this that you can activate on the "Reformat" option within the editor. It would be very helpful if these settings could be integrated to the cli formatter as well.
Example: You have a file like this formatted within intellij (just the imports).
When formatted with another editor (respecting editorconfig) you get something like this:
and if you reformat the file with
the import order stays the same as the one formatted within the editor using editorconfig but one would expect to apply the optimize import operation as well.
Regards,
Afgeoijlejk (sorry for this very late reply, totally forgot this thread exists)
Seems we have related request on YouTrack: https://youtrack.jetbrains.com/issue/IDEA-180965/Command-line-formatter-to-rearrange-code. Please follow it for updates.