chore: add repo-wide consistent-formatting setup#261
Merged
Conversation
damyanpetev
force-pushed
the
dpetev/setup-update
branch
2 times, most recently
from
July 21, 2026 14:21
61cc657 to
fdbe764
Compare
damyanpetev
force-pushed
the
dpetev/formatting-setup
branch
from
July 21, 2026 17:23
17c8218 to
138097f
Compare
damyanpetev
marked this pull request as ready for review
July 21, 2026 17:32
damyanpetev
enabled auto-merge
July 21, 2026 17:32
kdinev
approved these changes
Jul 22, 2026
Comment on lines
+7
to
+9
| Top | ||
|
|
||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Do not squash
Steps:
dotnet format100% whitespace indents and new line removaldotnet format100% using-s cleanup and sort (mostly deletes of globals)prettierpass a bit more involved, quite noisy on the js files (no surprise there)Current implementation
dotnet format whitespace --folder--verify-no-changes)EnforceCodeStyleInBuild+.editorconfigdotnet build, IDE squigglesnpm run format:check).githooks/pre-commit→npx --no-install lint-stagedGit hooks use the native
core.hooksPathmechanism (git ≥ 2.9) instead of husky — the committed .githooks/ directory is activated by the npmpreparescript (git config core.hooksPath .githooks), which runs automatically onnpm install/npm ci. Same pattern as igniteui-angular (cec370f). Caveats: on a fresh clone hooks only work afternpm install(both to set the config and becausenpx --no-installneedsnode_modules), and the hook file must keep its executable bit for Linux/macOS clones. Hooks can be tested without committing viagit hook run pre-commit(git ≥ 2.36).The one-time repo-wide normalization was applied as a single mechanical commit (
dotnet format whitespace . --folder --exclude templates node_modules+npm run format— reproducible by rerunning the commands). Its SHA is listed in .git-blame-ignore-revs sogit blameand GitHub's blame view skip it; each clone needs a one-timegit config blame.ignoreRevsFile .git-blame-ignore-revs. This only affects blame — in diffs usegit diff -w/ GitHub's "Hide whitespace" (?w=1).Key files: .editorconfig, Directory.Build.props (
EnforceCodeStyleInBuild), ci.yml (both verify steps), package.json (format,format:check,prepare,lint-staged), .prettierrc, .prettierignore, .githooks/, .git-blame-ignore-revs..editorconfig structure
The file is Visual Studio's generated .editorconfig used as a neutral base, with repo-specific deviations marked
REPO:inline:varpreferences →true(VS defaultfalse; codebase usesvarheavily, matches aspnetcore)csharp_style_namespace_declarations = block_scoped(repo majority incl. generated components; aspnetcore prefersfile_scopedvia IDE0161)dotnet_style_allow_multiple_blank_lines_experimental = false+ IDE2000 warning (VS default allows them; aspnetcore also disallows)csharp_preserve_single_line_statements = false(VS defaulttrue; matches aspnetcore)end_of_line/charsetdeliberately unset (VS defaultcrlf) — needs a.gitattributesfirst, see open itemsinsert_final_newline = trueunder[*](VS defaultfalse)Enforced severities live in one block near the bottom. Note aspnetcore's .editorconfig keeps IDE0055 at
suggestionand relies on a CIdotnet formatcheck alone; we usewarningfor IDE/build visibility. aspnetcore's larger CA/IDE analyzer set (correctness, perf, hygiene — mostly without auto-fix) is captured as a commented "Future candidates" section at the end of our .editorconfig, including their pattern of relaxing rules tosuggestionfor test projects.Why not plain
dotnet format(the important caveat)Full
dotnet format(or itsstyle/analyzersverbs) corrupts this repo. The library multi-targetsnet8.0/net9.0/net10.0; fixers run once per TFM and Roslyn merges disagreeing edits by writing literal conflict markers into sources:Verified empirically in a throwaway worktree: a full
dotnet format IgniteUI.Blazor.Lite.slnxrun left ~7.7k conflict-marker errors and did not converge on re-verify. Known upstream issues:Why
dotnet formatalso doesn't fit pre-commit / format-on-saveSeparate from the corruption bug,
dotnet formatfundamentally cannot act as a Prettier-style per-file formatter:dotnet format <file>; today it demands a project/solution even with--include, so "format the staged files" is not expressible (folder mode being the partial workaround)dotnet new console(slower than building it); MSBuild workspace loading dominates, making per-commit runs painful — the discussion points to CSharpier as the practical alternativedotnet format whitespace . --folderavoids MSBuild entirely (formats files as text+syntax), so it is immune — and ~50x faster (seconds vs minutes). The trade-off: folder mode only runs the whitespace formatter.What each rule can and cannot do here
whitespace --folder)dotnet format style(unusable, see above) or CSharpier fixes itvar, namespaces, etc.¹ IDE0005 only surfaces at build when the project produces an XML docs file.
Editor gotchas (learned the hard way)
.editorconfigkeys are last-one-wins: a duplicateddotnet_diagnostic.IDE0055.severityline silently overrides the earlier one.suggestionseverity renders as a near-invisible hint in VS Code and does not appear in the Problems panel — usewarningfor anything that matters.IgniteUI.Blazor.Lite.slnx, not inIgniteUI.Blazor.Lite.Library.slnf— pick the solution accordingly (C# Dev Kit: "Open Solution" / status-bar picker). Same applies to builds:dotnet build <slnf>never compiles TestBed, so no warnings from its files.CSharpier evaluation (v1.3.0)
Opinionated Prettier-style formatter for C# (belav/csharpier), evaluated as a local dotnet tool. Test results on this repo:
dotnet formatproject mode). Works per-file with no MSBuild → does fit lint-staged, unlike dotnet format..csproj,.props,.targets) — a full run would touch ~379 files including project files.printWidth100), normalizes expression layout. Little to configure (width, tabs, endOfLine) — that is the point, but the diff goes beyond pure whitespace. Reads.editorconfigforindent_size/max_line_length.public A() : base() { }→public A()\n : base() { }); brace collapsing/expansion normalized to its own rules (e.g. empty/short bodies hugged onto the member line); long-line rewrapping and expression layout normalization throughout.CSharpier.MsBuildpackage (fail build if unformatted),.csharpierignore.Verdict: evaluated and rejected. Technically it is the strongest option — fast, per-file, immune to the multi-TFM bug, and the only tool that auto-fixes blank lines (IDE2000) — but its fixed style opinions (constructor initializer placement, brace collapsing, aggressive rewrapping) diverge from the preferred style of this codebase, and none of them are configurable. Consequence: IDE2000 and other style-verb rules stay report-only — build warnings with manual or IDE-code-fix cleanup, no bulk auto-fix. Should the preference shift (or CSharpier grow the relevant options), adoption would be: one-time
dotnet csharpier format ., swap the CI whitespace gate fordotnet csharpier check ., add"*.cs": "dotnet csharpier format"to lint-staged, and keep.editorconfig+EnforceCodeStyleInBuildfor the non-formatting style rules.Other deliberate choices / open items
src/src/ig/) is fully excluded: from Prettier via.prettierignoreand from editor churn via the[src/src/ig/**]unset-section at the end of.editorconfig(kept last so it overrides the[*]defaults)..gitattributes); adding one plusend_of_linein.editorconfigis a possible follow-up.*.mdin.prettierignore).eslint.config.jsfirst if lint gating is wanted.