-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[prettierX] better class & function formatting options #444
Comments
One option I haven't seen mentioned would be to use double indent for a multi line class (or function) definition. This would be the most preferable to me and I believe it's an option in JetBrains IDE's also. class HigherLevelClassWithLongNameAndExtendedFunctionality
extends SuperMajorBaseClassWithHeavyFunctionality
implements SuperLargeGenericInterface {
method1() {}
method2() {}
method3() {}
} This would work also for long constructor/method/function parameters. Input: function someVeryLongName(param1: QuiteLongType, param2: AnotherLongType, param3: string) {
doSomeThing();
} Current output: function someVeryLongName(
param1: QuiteLongType,
param2: AnotherLongType,
param3: string) {
doSomeThing();
} Suggested output: function someVeryLongName(
param1: QuiteLongType,
param2: AnotherLongType,
param3: string) {
doSomeThing();
} Edit: Added missing commas and semicolons. |
My apologies for the delay, definitely looks like a nice option.
Here is how Prettier 2.3.2 & prettierX 0.19.0 would currently format it: Prettier 2.3.2 --parser babel Input: class HigherLevelClassWithLongNameAndExtendedFunctionality
extends SuperMajorBaseClassWithHeavyFunctionality
implements SuperLargeGenericInterface {
method1() {}
method2() {}
method3() {}
} Output: class HigherLevelClassWithLongNameAndExtendedFunctionality
extends SuperMajorBaseClassWithHeavyFunctionality
implements SuperLargeGenericInterface
{
method1() {}
method2() {}
method3() {}
}
👍 |
👍
Current formatting behavior by Prettier 2.3.2 / prettierX 0.19.0 (don't think which parser will make a difference here): Prettier 2.3.2 --parser babel Input: function someVeryLongName(param1: QuiteLongType, param2: AnotherLongType, param3: string) {
doSomeThing();
} Output: function someVeryLongName(
param1: QuiteLongType,
param2: AnotherLongType,
param3: string
) {
doSomeThing();
}
That would definitely be more compact.
Thanks for the edits |
From prettier/prettier#10018 I am thinking it would be a nice solution to always put the opening brace (
{
) on its own line. This would be "solution 2" in prettier/prettier#10018 but for all ES classes. For example:I think this would be better than the request in prettier/prettier#4870 to "respect/enforce" line break after class declaration.
The text was updated successfully, but these errors were encountered: