fsharp-hedgehog
fsharp-hedgehog copied to clipboard
Follow the F# style guide
For reference: https://docs.microsoft.com/en-us/dotnet/fsharp/style-guide/
/cc @moodmosaic @TysonMN
This can be a prerequisite for #182. IIRC, @cmeeren follows a different style there.
I don't care too much about the style used in Hedgehog.Experimental. I'd be surprised if it's at all consistent there; there's probably one style from stuff originally from someone else, one style for old stuff I made, and one style for new stuff I made. I haven't spent much effort trying to be consistent, since it's such a small project. Feel free to reformat however you like when merging (or in PRs to the Hedgehog.Experimental),
I suggest using Fantomas and configuring it using an .editorconfig
. Fantomas isn't bug-free, but its aim is to have defaults that match the F# style guide. It's very nearly at a point where I can begin using it for my own projects at work.
@cmeeren We had a brief discussion about using Fantomas in #271, I think we came to an agreement that it would be easier to just apply it once as a single PR, then exercise discipline in subsequent PRs. If you know how to better configure Fantomas and could get it working that would be great though.
Configuring Fantomas is simple. Just place an .editorconfig
in the repo root, have it contain everything listed here, and tweak to your liking (see the rest of the document linked above for a description of each setting).
If you use VS, download the "F# Formatting" extension which enables formatting in F# files using Fantomas with the settings from .editorconfig
(or as configured in the plugin settings, but that's of course not portable). Any setting left at the default can be removed, but AFAIK it's safer to leave it, since otherwise someone may have a device-specific configuration of Fantomas (e.g. the F# Formatting extension config) that does not match your chosen (default) settings.
If you use VS, download the "F# Formatting" extension which enables formatting in F# files using Fantomas with the settings from
.editorconfig
(or as configured in the plugin settings, but that's of course not portable). Any setting left at the default can be removed, but AFAIK it's safer to leave it, since otherwise someone may have a device-specific configuration of Fantomas (e.g. the F# Formatting extension config) that does not match your chosen (default) settings.
Including an explicit version of these settings in our own .editorconfig
file is better both because this ensures consistency among developers and because it is more readable.
Including an explicit version of these settings in our own
.editorconfig
file is better both because this ensures consistency among developers and because it is more readable.
Yep, though it's more maintenance, because ideally you'll need to keep the settings list up-to-date when Fantomas adds/removes settings.