TsqlRefine 0.1.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 TsqlRefine --version 0.1.0
This package contains a .NET tool you can call from the shell/command line.
dotnet new tool-manifest
dotnet tool install --local TsqlRefine --version 0.1.0
This package contains a .NET tool you can call from the shell/command line.
#tool dotnet:?package=TsqlRefine&version=0.1.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
nuke :add-package TsqlRefine --version 0.1.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
tsqlrefine
T-SQL linter, auto-fixer, and formatter for SQL Server.
Note: This project is currently in early development (pre-1.0). Breaking changes are expected.
Features
Lint - Static Analysis
Detects issues in T-SQL code. Includes 86 built-in rules covering security, performance, and coding conventions.
# Lint a file
tsqlrefine lint path/to/file.sql
# Lint a directory recursively
tsqlrefine lint path/to/dir
# Lint from stdin
echo "SELECT * FROM users;" | tsqlrefine lint --stdin
# Output as JSON (for CI integration)
tsqlrefine lint --output json path/to/file.sql
Example output:
path/to/file.sql:3:1: warning avoid-select-star: Avoid SELECT *; explicitly list columns
path/to/file.sql:7:5: error missing-where-clause: UPDATE/DELETE without WHERE clause
Fix - Auto-fix
Automatically fixes detected issues. Rules with fixable: true can be auto-fixed.
# Preview fixes (dry run)
tsqlrefine fix path/to/file.sql
# Apply fixes to files
tsqlrefine fix --write path/to/file.sql
# Fix all .sql files in a directory
tsqlrefine fix --write path/to/dir
Auto-fix examples:
| Before | After |
|---|---|
select * from users |
SELECT * FROM users |
IF @x = NULL |
IF @x IS NULL |
EXEC('SELECT ...') |
EXEC sp_executesql N'SELECT ...' |
Format - Code Formatting
Formats T-SQL code to a consistent style. Respects .editorconfig indentation settings.
# Print formatted output to stdout
tsqlrefine format path/to/file.sql
# Format files in-place
tsqlrefine format --write path/to/file.sql
# Format all .sql files in a directory
tsqlrefine format --write path/to/dir
Formatting features:
- Keyword uppercasing (
select→SELECT) - Consistent indentation
- Whitespace normalization
- Trailing whitespace removal
Installation
.NET Global Tool (Recommended)
# Install
dotnet tool install --global TsqlRefine
# Update
dotnet tool update --global TsqlRefine
# Uninstall
dotnet tool uninstall --global TsqlRefine
Local Tool (Project-specific)
dotnet new tool-manifest
dotnet tool install TsqlRefine
dotnet tsqlrefine --help
From Source
git clone https://github.com/user/tsqlrefine.git
cd tsqlrefine
dotnet build src/TsqlRefine.sln -c Release
Configuration
Generate Config Files
tsqlrefine init
Creates the following files:
tsqlrefine.json- Tool configurationtsqlrefine.ignore- Exclusion patterns
tsqlrefine.json
{
"compatLevel": 150,
"ruleset": "rulesets/recommended.json",
"plugins": []
}
Preset Rulesets
| Preset | Rules | Use Case |
|---|---|---|
recommended |
49 | Balanced for production (default) |
strict |
86 | Maximum enforcement |
pragmatic |
30 | Production-ready minimum |
security-only |
10 | Security-focused |
tsqlrefine lint --preset strict path/to/file.sql
.editorconfig
The format command respects indentation settings:
[*.sql]
indent_style = space
indent_size = 4
Exit Codes
| Code | Meaning |
|---|---|
| 0 | Success (no violations) |
| 1 | Rule violations found |
| 2 | Parse error |
| 3 | Config error |
| 4 | Runtime exception |
Rules and Plugins
# List built-in rules
tsqlrefine list-rules
# List loaded plugins
tsqlrefine list-plugins
See docs/Rules/README.md for a rules overview, or docs/Rules/REFERENCE.md for the full rule reference.
Documentation
License
MIT License - see LICENSE
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. 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.