Skip to content
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

Add Feliz-style formatting #1225

Closed
4 of 6 tasks
l3m opened this issue Nov 6, 2020 · 6 comments
Closed
4 of 6 tasks

Add Feliz-style formatting #1225

l3m opened this issue Nov 6, 2020 · 6 comments

Comments

@l3m
Copy link

l3m commented Nov 6, 2020

In #453, @ForNeVeR and @blumu asked for a style as follows (from aforementioned issue):

type MyRecord = {
    xxx: int
    yyy: string
    zzz: MyRecord option 
}

let nested = {
    xxx = 0
    yyy = ""
    zzz = Some {
        xxx = 0
        yyy = ""
        zzz = None
    }
}

This also corresponds to the default Feliz formatting (https://zaid-ajaj.github.io/Feliz/):

Html.div [
    Html.button [
        prop.style [ 
            style.marginRight 5 
        ]
        prop.text "Increment"
    ]
]

This is a style I see in a lot of open source projects and that's why we've adopted the style for all our projects too. While there have been follow-ups to other points from #453, I didn't see any on this.

In comparison with other styles:

  • The Microsoft-style uses half-indents, which often conflict with tooling and also with learned behavior from other languages
  • I feel G-Research style doesn't work well with Feliz and Fable.React as it seems to add lots of almost-empty lines that make it harder to parse Elmish/Feliz/Fable.React code (at least for me) - it makes code a lot longer vertically.

In my personal opinion, the style above is a nice compromise between the two, which might also be the reason why it's often seen even without any tooling support for it. As I believe I'm not the only one in favor of this style, a config option to enable this formatting similar to the multiline block one would allow us to adopt Fantomas into our CI pipeline and greatly improve our F# dev experience.

I propose we extend Fantomas to support this style.

Pros and Cons

The advantages of making this adjustment to Fantomas are

  • Support for Feliz
  • Support for a style that is widely used in open source projects

The disadvantages of making this adjustment to Fantomas are that it's probably a non-trivial change.

Examples

See #453

Extra information

Estimated cost (XS, S, M, L, XL, XXL): Unsure, maybe L - XL?

Affidavit (please submit!)

Please tick this by placing a cross in the box:

Please tick all that apply:

  • This is not a breaking change to Fantomas
  • I or my company would be willing to help implement and/or test this
  • This suggestion is part of the Microsoft style guide (please add a link to section if so)
  • This suggestion is part of the G-Research style guide (please add a link to section if so)
@nojaf
Copy link
Contributor

nojaf commented Nov 9, 2020

Hello, this feature suggestion violates our Contribution Guidelines and falls under the section What are we not looking for?.

Fantomas has two styles of formatting records and this third one would imply massive changes over the entire codebase. I have no interest in maintaining this and wish to stick to what is listed in the styles guides. Please read the Contribution Guidelines carefully to understand why I'm closing this.

@nojaf nojaf closed this as completed Nov 9, 2020
@l3m
Copy link
Author

l3m commented Nov 12, 2020

@nojaf Thanks for the explanation and a working link to the contributor guidelines. - the one in the issue template is broken and leads to a 404.

@nojaf
Copy link
Contributor

nojaf commented Nov 13, 2020

the one in the issue template is broken and leads to a 404.

Thanks for pointing that out, created #1246

@texastoland
Copy link
Contributor

texastoland commented Jul 25, 2021

Update: Already implemented with SingleArgumentWebMode as pointed out by @alfonsogarciacaro


This is an issue for me for the same reason. Feliz is the standard library for React rendering in Fable. Both the extra horizontal cadence of ElmishSyntax and extra vertical (and horizontal) cadence of MultilineBlockBracketsOnSameColumn hinder a HTML-like reading of the data structure.

@jkone27
Copy link

jkone27 commented Jan 12, 2024

hello, i would need this working also for Feliz.ViewEngine, what settings do i need to specify?
else fantomas keeps formatting everything a bit random inside a Feliz view. cheers!
https://github.com/dbrattli/Feliz.ViewEngine

@nojaf
Copy link
Contributor

nojaf commented Jan 12, 2024

https://fsprojects.github.io/fantomas/docs/end-users/Configuration.html#fsharp_experimental_elmish

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants