BlazorLore.Format.Cli
1.0.0
There is a newer version of this package available.
See the version list below for details.
See the version list below for details.
dotnet tool install --global BlazorLore.Format.Cli --version 1.0.0
This package contains a .NET tool you can call from the shell/command line.
dotnet new tool-manifest
dotnet tool install --local BlazorLore.Format.Cli --version 1.0.0
This package contains a .NET tool you can call from the shell/command line.
#tool dotnet:?package=BlazorLore.Format.Cli&version=1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
nuke :add-package BlazorLore.Format.Cli --version 1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
BlazorLore Format CLI
A powerful formatter for Blazor and Razor components, similar to Prettier for HTML/CSS/JS. This tool helps maintain consistent code style across your Blazor projects.
Installation
dotnet tool install --global BlazorLore.Format.Cli
Usage
Format files
# Format all .razor files in current directory
blazorfmt format
# Format specific files
blazorfmt format Component1.razor Component2.razor
# Format and write changes
blazorfmt format --write
# Check if files are formatted
blazorfmt format --check
Initialize configuration
# Create a .blazorfmt.json config file
blazorfmt init
Configuration
Create a .blazorfmt.json
file in your project root:
{
"IndentSize": 4,
"UseTabs": false,
"AttributeFormatting": "multilineWhenMany",
"AttributeBreakThreshold": 3,
"BreakContentWithManyAttributes": true,
"ContentBreakThreshold": 2,
"QuoteStyle": "double"
}
Configuration Options
- IndentSize: Number of spaces for indentation (default: 4)
- UseTabs: Use tabs instead of spaces (default: false)
- AttributeFormatting: How to format attributes
"singleLine"
: Keep all attributes on one line"multilineAlways"
: Always put each attribute on a new line"multilineWhenMany"
: Break to multiple lines when threshold is reached
- AttributeBreakThreshold: Number of attributes before breaking to multiple lines (default: 3)
- BreakContentWithManyAttributes: Break content to new line when element has many attributes (default: true)
- ContentBreakThreshold: Number of attributes before breaking content to new line (default: 2)
- QuoteStyle: Quote style for attributes (
"double"
or"single"
)
Command Line Options
--write, -w
: Write formatted output back to files--check, -c
: Check if files are formatted (exit with error if not)--config
: Path to configuration file--indent-size
: Override indent size--use-tabs
: Override to use tabs--attribute-break-threshold
: Override attribute break threshold--content-break-threshold
: Override content break threshold--break-content-with-many-attributes
: Override content breaking behavior
VS Code Extension
For the best experience, install the BlazorLore Format VS Code extension which integrates seamlessly with this CLI tool.
Examples
Before formatting:
<button class="btn btn-primary" @onclick="IncrementCount" disabled="@IsDisabled" title="Click me">Click me</button>
After formatting (with default settings):
<button
class="btn btn-primary"
@onclick="IncrementCount"
disabled="@IsDisabled"
title="Click me">
Click me
</button>
License
MIT License - see LICENSE file for details
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
This package has no dependencies.
v1.0.0:
- Initial release
- Format Blazor/Razor components with proper indentation
- Smart line breaking for attributes and content
- Configurable formatting options
- VS Code extension integration
- Native AOT support for fast performance