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

Feature: space between function and unit #649

Merged
merged 26 commits into from
Mar 18, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
95cc2cf
Split up setting SpaceBeforeArgument into multiple settings.
nojaf Jan 24, 2020
3040e39
Print warning for --noSpaceBeforeArgument.
nojaf Jan 24, 2020
446ddfc
Update SpaceBeforeArgument in json schema
nojaf Jan 24, 2020
36093e1
Adding extra settings for Class constructors
nojaf Jan 24, 2020
79484dd
Update documentation and schema.json
nojaf Jan 24, 2020
446c5cf
Add empty line at the end of file.
nojaf Jan 24, 2020
662fc07
Merged master
nojaf Jan 24, 2020
4b51b00
Updated month in release notes
nojaf Feb 3, 2020
3868c55
Merged master
nojaf Feb 3, 2020
860f07d
Merged master
nojaf Feb 3, 2020
c7d675f
Merge branch 'feature/space-between-function-and-unit' of https://git…
nojaf Feb 3, 2020
8a7c550
Merge branch 'master' of https://github.com/nojaf/fantomas
nojaf Feb 4, 2020
21fdbc0
Merge branch 'master' into feature/space-between-function-and-unit
nojaf Feb 4, 2020
fa8a37c
Merge remote-tracking branch 'upstream/master'
nojaf Feb 6, 2020
2f341d8
Merge branch 'master' of https://github.com/nojaf/fantomas
nojaf Feb 18, 2020
c28a045
Merge remote-tracking branch 'upstream/master'
nojaf Feb 18, 2020
e75942e
Merge remote-tracking branch 'upstream/master'
nojaf Feb 18, 2020
3fa733c
Merge remote-tracking branch 'upstream/master'
nojaf Feb 19, 2020
0d093e5
Merged latest master
nojaf Feb 21, 2020
cbfcbcd
Reduced class constructor setting to one setting.
nojaf Feb 21, 2020
cac8d65
Update sample default configuration
nojaf Feb 21, 2020
cfc1fc6
Merged latest master
nojaf Mar 6, 2020
cfb5e51
Simply configuration options
nojaf Mar 6, 2020
1ee8f20
Merge branch 'master' into feature/space-between-function-and-unit
nojaf Mar 17, 2020
56452ec
Update schema.json
nojaf Mar 17, 2020
b792c1d
Remove documentation for space before parameters.
nojaf Mar 17, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 12 additions & 9 deletions docs/Documentation.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
## Fantomas: How to use

### Using the command line tool

---

For the overview how to use the tool, you can type the command
Expand Down Expand Up @@ -131,12 +132,6 @@ add semicolons at the end of lines e.g.
Mass = 0.0002858859807 * solarMass }
```

##### `--noSpaceBeforeArgument`

if being set, no space is inserted before a function name and its first argument.
For example, `Seq.filter (fun x -> x > 2)` becomes `Seq.filter(fun x -> x > 2)`.
This doesn't affect methods and constructors, e.g. `Console.WriteLine("Hello World")`.

##### `--spaceBeforeColon`

if being set, there is a space before `:` e.g.
Expand Down Expand Up @@ -292,11 +287,19 @@ Use a JSON configuration file based on a [schema](../src/Fantomas/schema.json) t

A default configuration file would look like
```json
{
{
"IndentSpaceNum":4,
"PageWidth":120,
"SemicolonAtEndOfLine":false,
"SpaceBeforeArgument":true ,
"SpaceBeforeUnitArgumentInUppercaseInvocation":false,
"SpaceBeforeUnitArgumentInLowercaseInvocation":false,
"SpaceBeforeParenthesesInUppercaseInvocation":false,
"SpaceBeforeParenthesesInLowercaseInvocation":true ,
"SpaceBeforeUnitParameterInUppercaseFunctionDefinition":false,
"SpaceBeforeUnitParameterInLowercaseFunctionDefinition":false,
"SpaceBeforeParenthesesInUppercaseFunctionDefinition":false,
"SpaceBeforeParenthesesInLowercaseFunctionDefinition":true ,
"SpaceBeforeClassConstructor":false,
"SpaceBeforeColon":false,
"SpaceAfterComma":true ,
"SpaceBeforeSemicolon": false,
Expand All @@ -306,7 +309,7 @@ A default configuration file would look like
"SpaceAroundDelimiter":true ,
"KeepNewlineAfter":false,
"MaxIfThenElseShortWidth":40,
"StrictMode":false
"StrictMode":false
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unneeded trailing whitespace addition?

}
```

Expand Down
153 changes: 0 additions & 153 deletions src/Fantomas.CoreGlobalTool/Arg.fs

This file was deleted.

3 changes: 0 additions & 3 deletions src/Fantomas.CoreGlobalTool/Program.fs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ type Arguments =
| [<Unique>] Check
| [<Unique;AltCommandLine("--pageWidth")>] PageWidth of int
| [<Unique;AltCommandLine("--semicolonEOL")>] SemicolonEOL
| [<Unique;AltCommandLine("--noSpaceBeforeArgument")>] NoSpaceBeforeArgument
| [<Unique;AltCommandLine("--spaceBeforeColon")>] SpaceBeforeColon
| [<Unique;AltCommandLine("--noSpaceAfterComma")>] NoSpaceAfterComma
| [<Unique;AltCommandLine("--noSpaceAfterSemiColon")>] NoSpaceAfterSemiColon
Expand Down Expand Up @@ -46,7 +45,6 @@ with
| Check -> "Don't format files, just check if they have changed. Exits with 0 if it's formatted correctly, with 1 if some files need formatting and 99 if there was an internal error"
| PageWidth _ -> "Set the column where we break to new lines (default = 80). The value should be at least 60."
| SemicolonEOL -> "Enable semicolons at the end of line (default = false)."
| NoSpaceBeforeArgument -> "Disable spaces before the first argument of functions when there are parenthesis (default = true). For methods and constructors, there are never spaces regardless of this option."
| SpaceBeforeColon -> "Enable spaces before colons (default = false)."
| NoSpaceAfterComma -> "Disable spaces after commas (default = true)."
| NoSpaceAfterSemiColon -> "Disable spaces after semicolons (default = true)."
Expand Down Expand Up @@ -271,7 +269,6 @@ let main argv =
| Indent i -> { acc with IndentSpaceNum = i }
| PageWidth pw -> { acc with PageWidth = pw }
| SemicolonEOL -> { acc with SemicolonAtEndOfLine = true }
| NoSpaceBeforeArgument -> { acc with SpaceBeforeArgument = false }
| SpaceBeforeColon -> { acc with SpaceBeforeColon = true }
| NoSpaceAfterComma -> { acc with SpaceAfterComma = false }
| NoSpaceAfterSemiColon -> { acc with SpaceAfterSemicolon = false }
Expand Down
8 changes: 4 additions & 4 deletions src/Fantomas.Tests/AttributeTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,9 @@ and [<Test>] b () = 10""" config
|> prepend newline
|> should equal """
[<Test>]
let rec a() = 10
let rec a () = 10

and [<Test>] b() = 10
and [<Test>] b () = 10
"""

[<Test>]
Expand Down Expand Up @@ -190,7 +190,7 @@ let printInStyle (style: string) (msg): unit = jsNative
let printModel model: unit = jsNative

[<Emit("console.trace()")>]
let printStackTrace(): unit = jsNative
let printStackTrace (): unit = jsNative
#endif

let e2e value = Props.Data("e2e", value)
Expand Down Expand Up @@ -292,7 +292,7 @@ let main argv =
SpaceAfterComma = false
SpaceAfterSemicolon = false
SpaceAroundDelimiter = false
SpaceBeforeArgument = false })
SpaceBeforeLowercaseInvocation = false })
|> prepend newline
|> should equal """
open System
Expand Down
14 changes: 7 additions & 7 deletions src/Fantomas.Tests/CommentTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ let print_30_permut() =
""" config
|> prepend newline
|> should equal """
let print_30_permut() =
let print_30_permut () =

/// declare and initialize
let permutation: int array =
Expand All @@ -59,7 +59,7 @@ let print_30_permut() =
""" config
|> prepend newline
|> should equal """
let print_30_permut() =
let print_30_permut () =

/// declare and initialize
let permutation: int array =
Expand Down Expand Up @@ -120,7 +120,7 @@ let f() =
""" config
|> prepend newline
|> should equal """
let f() =
let f () =
// COMMENT
x + x
"""
Expand All @@ -134,7 +134,7 @@ let f() =
""" config
|> prepend newline
|> should equal """
let f() =
let f () =
let x = 1 // COMMENT
x + x
"""
Expand All @@ -156,7 +156,7 @@ let f() =
|> should equal """
/// XML COMMENT
// Other comment
let f() =
let f () =
// COMMENT A
let y = 1
(* COMMENT B *)
Expand All @@ -182,7 +182,7 @@ let f() =
|> should equal """
/// XML COMMENT A
// Other comment
let f() =
let f () =
// COMMENT A
let y = 1
/// XML COMMENT B
Expand Down Expand Up @@ -380,7 +380,7 @@ let hello() = "hello world"
""" config
|> prepend newline
|> should equal """
let hello() = "hello world"
let hello () = "hello world"

(* This is a comment. *)
"""
Expand Down
10 changes: 5 additions & 5 deletions src/Fantomas.Tests/CompilerDirectivesTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,12 @@ let ``line, file and path identifiers``() =
""" config
|> prepend newline
|> should equal """
let printSourceLocation() =
let printSourceLocation () =
printfn "Line: %s" __LINE__
printfn "Source Directory: %s" __SOURCE_DIRECTORY__
printfn "Source File: %s" __SOURCE_FILE__

printSourceLocation()
printSourceLocation ()
"""

[<Test>]
Expand Down Expand Up @@ -170,7 +170,7 @@ let [<Literal>] private assemblyConfig() =
|> prepend newline
|> should equal """
[<Literal>]
let private assemblyConfig() =
let private assemblyConfig () =
#if TRACE
let x = ""
#else
Expand Down Expand Up @@ -1021,7 +1021,7 @@ let f () =
|> prepend newline
|> should equal """
#if TEST
let f() =
let f () =
async {
let x = 2
return x
Expand All @@ -1042,7 +1042,7 @@ let f () =
|> prepend newline
|> should equal """
#if TEST
let f() =
let f () =
async {
let x = 2
return x
Expand Down
10 changes: 5 additions & 5 deletions src/Fantomas.Tests/ComputationExpressionTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ let s2 = seq { 0 .. 10 .. 100 }
let rec inorder tree =
seq {
match tree with
| Tree(x, left, right) ->
| Tree (x, left, right) ->
yield! inorder left
yield x
yield! inorder right
Expand Down Expand Up @@ -108,7 +108,7 @@ async {
|> prepend newline
|> should equal """
async {
match! myAsyncFunction() with
match! myAsyncFunction () with
| Some x -> printfn "%A" x
| None -> printfn "Function returned None!"
}
Expand Down Expand Up @@ -158,9 +158,9 @@ parallel {
|> should equal """
// Reads the values of x, y and z concurrently, then applies f to them
``parallel`` {
let! x = slowRequestX()
and! y = slowRequestY()
and! z = slowRequestZ()
let! x = slowRequestX ()
and! y = slowRequestY ()
and! z = slowRequestZ ()
return f x y z }
"""

Expand Down
Loading