Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
- Open-ended expressions (lambda, if-then-else, match, ...) in non-last positions of infix, tuple, list/array, and record expressions now stay multiline to preserve semantics. [#3279](https://github.com/fsprojects/fantomas/issues/3279)
- Lambda in tuple in list on single line changes code meaning. [#3278](https://github.com/fsprojects/fantomas/issues/3278)
- Custom operator applied to lambda collapses to single line changing semantics. [#3274](https://github.com/fsprojects/fantomas/issues/3274)
- Unrecognized `.editorconfig` property values now emit a warning to stderr instead of being silently ignored. [#1236](https://github.com/fsprojects/fantomas/issues/1236)

## [8.0.0-alpha-007] - 2026-03-10

Expand Down
30 changes: 30 additions & 0 deletions src/Fantomas.Tests/EditorConfigurationTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -543,3 +543,33 @@ fsharp_experimental_elmish = true
let config = EditorConfig.readConfiguration fsharpFile.FSharpFile

Assert.That(config.ExperimentalElmish, Is.True)

[<Test>]
let ``invalid editorconfig value emits warning to stderr and uses default`` () =
let rootDir = tempName ()

let editorConfig =
"""
[*.fs]
fsharp_experimental_elmish = not_a_bool
"""

use configFixture =
new ConfigurationFile(defaultConfig, rootDir, content = editorConfig)

use fsharpFile = new FSharpFile(rootDir)

let capturedErr = new System.IO.StringWriter()
let originalErr = Console.Error
Console.SetError(capturedErr)

let config =
try
EditorConfig.readConfiguration fsharpFile.FSharpFile
finally
Console.SetError(originalErr)

let output = capturedErr.ToString()
Assert.That(output, Does.Contain("fsharp_experimental_elmish"))
Assert.That(output, Does.Contain("not_a_bool"))
config.ExperimentalElmish == defaultConfig.ExperimentalElmish
7 changes: 6 additions & 1 deletion src/Fantomas/EditorConfig.fs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,12 @@ let parseOptionsFromEditorConfig
| true, MultilineFormatterType mft -> box mft
| true, EndOfLineStyle eol -> box eol
| true, BracketStyle bs -> box bs
| _ -> defaultValue)
| false, _ -> defaultValue
| true, invalidValue ->
eprintfn
$"warning: unrecognized value '%s{invalidValue}' for property '%s{editorConfigName}' in .editorconfig, using default."

defaultValue)
|> fun newValues ->

let formatConfigType = FormatConfig.Default.GetType()
Expand Down
Loading