Skip to content

[Repo Assist] Warn on unrecognized .editorconfig property values instead of silently ignoring them - #3321

Merged
nojaf merged 2 commits into
mainfrom
repo-assist/improve-editorconfig-warnings-20260330-6b7698294b5a4617
Mar 30, 2026
Merged

nojaf merged 2 commits into
mainfrom
repo-assist/improve-editorconfig-warnings-20260330-6b7698294b5a4617

Conversation

@github-actions

Copy link
Copy Markdown
Contributor

🤖 This PR was created by Repo Assist, an automated AI assistant.

Summary

Closes #1236.

When a property key is present in .editorconfig but its value cannot be parsed (e.g., a typo like truee for a boolean, or an unrecognized enum string), Fantomas previously silently fell back to the default value. This made configuration mistakes very hard to diagnose.

This PR emits a warning to stderr for such cases while still using the default value, matching the behaviour users would expect from other tools.

Root Cause

In parseOptionsFromEditorConfig, the active pattern matching fell through to a catch-all | _ -> defaultValue that covered both the "key not found" case (expected, silent) and the "key found but value unparseable" case (unexpected, should warn). These two were indistinguishable.

Fix

Split the wildcard into two explicit arms:

  • | false, _ -> defaultValue — key not found; silently use default (expected)
  • | true, invalidValue -> eprintfn ... ; defaultValue — key found but value invalid; warn to stderr

Trade-offs

  • The warning goes to stderr, keeping stdout clean for piped formatting output.
  • No change to public API or function signature.
  • Default behaviour is preserved — the formatter still runs successfully.

Test Status

  • New test: invalid editorconfig value emits warning to stderr and uses default in EditorConfigurationTests.fs
  • All 27 EditorConfigurationTests pass
  • All 2770 Fantomas.Core.Tests pass
  • Build: ✅ succeeded (dotnet build fantomas.sln -c Release)

Generated by 🌈 Repo Assist at {run-started}. Learn more.

To install this agentic workflow, run

gh aw add githubnext/agentics/workflows/repo-assist.md@1f672aef974f4246124860fc532f82fe8a93a57e

…y ignoring them

Fixes #1236: previously, a property value in .editorconfig that could
not be parsed (e.g. a typo like 'truee' for a boolean) was silently
ignored and the default was used.  This made it very hard to diagnose
configuration mistakes.

Now, when a key is present in .editorconfig but its value cannot be
parsed, a warning is emitted to stderr and the default is used.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@nojaf
nojaf marked this pull request as ready for review March 30, 2026 06:51
@nojaf
nojaf merged commit 7c3cbbc into main Mar 30, 2026
11 checks passed
@nojaf
nojaf deleted the repo-assist/improve-editorconfig-warnings-20260330-6b7698294b5a4617 branch August 19, 2026 06:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Invalid .editorconfig file should give an error instead of being ignored

1 participant