PinguApps.RazorStyle
0.1.0
See the version list below for details.
dotnet add package PinguApps.RazorStyle --version 0.1.0
NuGet\Install-Package PinguApps.RazorStyle -Version 0.1.0
<PackageReference Include="PinguApps.RazorStyle" Version="0.1.0" />
<PackageVersion Include="PinguApps.RazorStyle" Version="0.1.0" />
<PackageReference Include="PinguApps.RazorStyle" />
paket add PinguApps.RazorStyle --version 0.1.0
#r "nuget: PinguApps.RazorStyle, 0.1.0"
#:package PinguApps.RazorStyle@0.1.0
#addin nuget:?package=PinguApps.RazorStyle&version=0.1.0
#tool nuget:?package=PinguApps.RazorStyle&version=0.1.0
RazorStyle
RazorStyle is an opinionated Razor style linter and enforcer for Blazor .razor files. It exists to make Razor markup consistent across a solution, either by checking files in CI or fixing files during local builds.
It is distributed as two packages:
PinguApps.RazorStyle.Cli: a .NET tool namedrazorstyle.PinguApps.RazorStyle: an MSBuild integration package that runs RazorStyle during builds.
Rules
RS0001: start-tag attributes must wrap and align consistently.RS0002: child content must appear on its own line.RS0003: attributes must follow the preferred RazorStyle order.
RS0001 Attribute Wrapping
Before:
<Modal Title="Hello" IsOpen="true" OnClose="Close" />
After:
<Modal Title="Hello"
IsOpen="true"
OnClose="Close" />
Single-attribute and attribute-free tags remain inline:
<Modal />
<Modal Title="Hello" />
RS0002 Child Content Lines
Before:
<span>Some text</span>
After:
<span>
Some text
</span>
Self-closing tags are already valid:
<span />
<span class="foo" />
RS0003 Attribute Order
Before:
<button data-track="save" disabled class="btn" @onclick="Save" id="save-button" />
After:
<button id="save-button"
class="btn"
@onclick="Save"
data-track="save"
disabled />
CLI Usage
Install the tool:
dotnet tool install --global PinguApps.RazorStyle.Cli
Check files:
razorstyle check .\src
Fix files:
razorstyle fix .\src
Build Integration
Install the build package into a project that contains .razor files:
dotnet add package PinguApps.RazorStyle
By default:
- local builds run
fix - CI builds run
checkwhenContinuousIntegrationBuild=true
Override behavior with MSBuild properties:
<PropertyGroup>
<RazorStyleEnabled>true</RazorStyleEnabled>
<RazorStyleCommand>check</RazorStyleCommand>
<DisableRS0001>false</DisableRS0001>
<DisableRS0002>false</DisableRS0002>
<DisableRS0003>false</DisableRS0003>
</PropertyGroup>
The CLI also supports per-rule disables:
razorstyle check .\src --disable RS0001 --disable RS0003
Learn more about Target Frameworks and .NET Standard.
This package has no dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.