ReGitLint.Fork 6.0.7

dotnet tool install --global ReGitLint.Fork --version 6.0.7                
This package contains a .NET tool you can call from the shell/command line.
dotnet new tool-manifest # if you are setting up this repo
dotnet tool install --local ReGitLint.Fork --version 6.0.7                
This package contains a .NET tool you can call from the shell/command line.
#tool dotnet:?package=ReGitLint.Fork&version=6.0.7                
nuke :add-package ReGitLint.Fork --version 6.0.7                

ReGitLint

Integrates the free CleanupCode command line tool from ReSharper Command Line Tools with git to provide low friction .net linting for teams without requiring everyone to install ReSharper.

CleanupCode supports formatting c# as well as vb.net, c++, html, asp.net, razor, javascript, typescript, css, xml, & xaml.

ReGitLint puts and end to style wars by making it easy to add git hooks and CI checks to ensure code is formatted consistenlty. Your team will be holding hands and singing kum ba yah in no time! Kum ba yah

Formatting options are specified in .editorconfig so everyone can use their favorite editor. There are many formatting options supported... Here's a reference

Why CleanupCode instead of the built in dotnet format?

dotnet format is cool, but currently doesn't support .editorconfig max_line_length. For curmudgeons like me this is a deal breaker. There's an open issue for it but so far no fix.

Quick Start

If you don't already have a tool manifest in your project

dotnet new tool-manifest

Install jb & regitlint

dotnet tool install JetBrains.ReSharper.GlobalTools
dotnet tool install ReGitLint

Now to clean up the whole solution run

dotnet regitlint

To keep everything formatted you can add a pre-commit hook and build step. Don't panic!!! ReGitLint has options to format only what's changed so it's fast!

Add the following to .git/hooks/pre-commit

#!/bin/sh
dotnet regitlint -f staged --fail-on-diff

ReGitLint will run CleanupCode to format all staged files. If they don't match .editorconfig the commit will fail and you'll see a message like:

!!!! Process Aborted !!!!
Code formatter changed the following files:
 * Directory/SomeCode.cs

To enforce code formatting on the build server add this to your build script

dotnet tool restore
dotnet regitlint -f commits -a $env.GIT_PREVIOUS_SUCCESSFUL_COMMIT -b $env.GIT_COMMIT --fail-on-diff --print-diff

Or if you use jenkins you can just add this

dotnet tool restore
dotnet regitlint --jenkins

This will only format the files changed between the commit that triggered the build and the commit that triggered the last successful build. This saves a lot of time when compared to formatting all files on a large project.

More Examples:

  • Run cleanup on entire solution

    dotnet regitlint

  • Format only, don't run a full code cleanup

    dotnet regitlint --format-only

  • Clean up all staged files

    dotnet regitlint -f staged

  • Clean up all modified files

    dotnet regitlint -f modified

  • Clean up only c# files

    dotnet regitlint -p "**/*.cs"

  • Clean up only js files

    dotnet regitlint -p "**/*.js"

  • Clean up all files modified by commit 3796556

    dotnet regitlint -f commits -a 3796556

  • Clean up all files modified between commit 6708090 and 3796556

    dotnet regitlint -f commits -a 6708090 -b 3796556

  • Clean up all files modified by the last four commits

    dotnet regitlint -f commits -a head^^^^ -b head

  • Clean up staged files, return 1 if files change. Handy for git hooks.

    dotnet regitlint -f staged --fail-on-diff

  • Clean up files between commits and return 1 if files change. Handy for enforcing code formatting on build server.

    dotnet regitlint -f commits -a 6708090 -b 3796556 --fail-on-diff

  • Enforce code formatting on jenkins

    dotnet regitlint --jenkins

  • Enforce code formatting on other build servers

    dotnet regitlint -f commits -a $env.GIT_PREVIOUS_SUCCESSFUL_COMMIT -b $env.GIT_COMMIT --fail-on-diff --print-diff

  • Pass options through to jb cleanupcode

    dotnet regitlint --jb --toolset=16.0 --jb --exclude="**/*.html"


If you've found ReGitLint helpful you can buy me a coffee to say thanks. Happy linting!

Product Compatible and additional computed target framework versions.
.NET net5.0 is compatible.  net5.0-windows was computed.  net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp3.1 is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

This package has no dependencies.

Version Downloads Last updated
6.0.7 294 2/9/2022