Incorrect formatting for chained class members using Websharper #871
Closed
Description
Issue created from fantomas-online
Please describe here fantomas problem you encountered
This was reported in ionide/ionide-vscode-fsharp#1372, and I've reproduced it here with the associated fantomas-online link.
The issue seems to be the indent level of the class-members chained, the indent level of AttrPassword
is further in than AttrEmail
.
Code
namespace LoginWithBulmaTutorial
open System
open WebSharper
open WebSharper.JavaScript
open WebSharper.JQuery
open WebSharper.UI
open WebSharper.UI.Client
open WebSharper.UI.Notation
open WebSharper.UI.Templating
[<JavaScript>]
module Client =
// The templates are loaded from the DOM, so you just can edit index.html
// and refresh your browser, no need to recompile unless you add or remove holes.
type MySPA = Template<"wwwroot/index.html", ClientLoad.FromDocument>
[<SPAEntryPoint>]
let Main () =
let passwordValid = Var.Create true
let emailValid = Var.Create true
MySPA()
.AttrPassword(Attr.ClassPred "is-danger" (not passwordValid.V))
.AttrEmail(Attr.ClassPred "is-danger" (not emailValid.V))
.Login(fun e ->
passwordValid
:= not (String.IsNullOrWhiteSpace e.Vars.Password.Value)
emailValid
:= not (String.IsNullOrWhiteSpace e.Vars.Email.Value)
if passwordValid.Value && emailValid.Value
then JS.Alert(sprintf "Your email is %s" e.Vars.Email.Value)
e.Event.PreventDefault()
)
.Bind()
Error
Fantomas was able to format the code but the result appears to be invalid F# code.
Please open an issue.
Formatted result:
namespace LoginWithBulmaTutorial
open System
open WebSharper
open WebSharper.JavaScript
open WebSharper.JQuery
open WebSharper.UI
open WebSharper.UI.Client
open WebSharper.UI.Notation
open WebSharper.UI.Templating
[<JavaScript>]
module Client =
// The templates are loaded from the DOM, so you just can edit index.html
// and refresh your browser, no need to recompile unless you add or remove holes.
type MySPA = Template<"wwwroot/index.html", ClientLoad.FromDocument>
[<SPAEntryPoint>]
let Main () =
let passwordValid = Var.Create true
let emailValid = Var.Create true
MySPA().AttrPassword(Attr.ClassPred "is-danger" (not passwordValid.V))
.AttrEmail(Attr.ClassPred "is-danger" (not emailValid.V))
.Login
(fun e ->
passwordValid
:= not (String.IsNullOrWhiteSpace e.Vars.Password.Value)
emailValid
:= not (String.IsNullOrWhiteSpace e.Vars.Email.Value)
if passwordValid.Value && emailValid.Value
then JS.Alert(sprintf "Your email is %s" e.Vars.Email.Value)
e.Event.PreventDefault()).Bind()
Options
Fantomas Master at 05/27/2020 09:30:01 - 9df884b
Name | Value |
---|---|
IndentSpaceNum |
4 |
PageWidth |
120 |
SemicolonAtEndOfLine |
false |
SpaceBeforeParameter |
true |
SpaceBeforeLowercaseInvocation |
true |
SpaceBeforeUppercaseInvocation |
false |
SpaceBeforeClassConstructor |
false |
SpaceBeforeMember |
false |
SpaceBeforeColon |
false |
SpaceAfterComma |
true |
SpaceBeforeSemicolon |
false |
SpaceAfterSemicolon |
true |
IndentOnTryWith |
false |
SpaceAroundDelimiter |
true |
MaxIfThenElseShortWidth |
40 |
MaxInfixOperatorExpression |
50 |
MaxRecordWidth |
40 |
MaxArrayOrListWidth |
40 |
MaxLetBindingWidth |
40 |
MultilineBlockBracketsOnSameColumn |
false |
NewlineBetweenTypeDefinitionAndMembers |
false |
KeepIfThenInSameLine |
false |
StrictMode |
false |
Metadata
Assignees
Labels
No labels