Skip to content
| Marketplace
Sign in
Visual Studio Code>Linters>Tollgate — Pre-Commit ChecksNew to Visual Studio Code? Get it now.
Tollgate — Pre-Commit Checks

Tollgate — Pre-Commit Checks

Kazeem Quadri

|
1 install
| (0) | Free
Pre-commit checks that just work: runs your lint, typecheck, Biome and Prettier, blocks secrets, debug code, conflict markers and large files, and enforces commit message rules — from VS Code or the terminal.
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

Tollgate logo

Tollgate — Pre-Commit Checks

Every commit stops at the gate.
Tollgate runs your linters, type-checker and formatter, catches secrets, debug code, merge conflicts and oversized files before they reach your repository. Works with JavaScript, TypeScript, .NET/C#, and monorepos. No setup required.


Tollgate blocking a commit: results in the Checks view, problems highlighted in the editor, and the hook output in the terminal

Why Tollgate?

  • Works on day one. Open a repo and accept the prompt. Tollgate finds your lint, typecheck and format:check scripts, auto-detects Biome, Prettier, .NET and CSharpier, and checks them on every commit.
  • Works in VS Code and the terminal. It installs real git hooks, so commits from the Source Control panel, the terminal and other Git clients are all checked. Results always appear in VS Code.
  • Points at the problem. Problems show up in a Checks view, the Problems panel and as squiggles in your code. Click any finding to jump to the exact line.
  • Only checks what you changed. Content checks only look at the lines you added, so problems in old code never block your commit.
  • Monorepo-ready. Runs each check from the right folder, detects project ownership, and handles nested solutions and package.json scripts automatically.
  • Configurable down to each check. You can turn every check on or off, choose whether it blocks or warns, and tune it. You can also add any shell command as your own check.
  • Shared with your team. Commit a .tollgaterc.json and everyone gets the same rules, with autocomplete and validation in the editor.

Features

What it checks

Check What it does Default
package.json scripts Runs lint, typecheck, tsc, format:check and similar if they exist. Detects npm / yarn / pnpm / bun. Monorepo aware: runs in the nearest package that has them. ✅ blocks
Biome biome check on staged files when the project uses Biome. Auto-detected in monorepos. ✅ auto
Prettier prettier --check on staged files when the project uses Prettier. Can format and re-stage for you. ✅ auto
lint-staged Runs your lint-staged config, per-package in monorepos. ✅ auto
.NET (C#/VB) dotnet format on staged files, dotnet build, CSharpier, and optionally dotnet test on push. Monorepo aware: finds the right .sln/.slnx and runs from the correct folder. See C# and .NET. ✅ auto
Secrets & credentials AWS, GitHub, GitLab, Stripe, Slack, Google, OpenAI, Anthropic, npm, Azure, SendGrid and Twilio keys, JWTs, private keys, passwords in code, in URLs and in connection strings. Matches are masked in the output. ✅ blocks
Merge conflict markers <<<<<<< / ======= / >>>>>>> ✅ blocks
JSON syntax Staged .json files must parse (comments are allowed in tsconfig.json, appsettings.json, launchSettings.json and .vscode/) ✅ blocks
Large files Files over 1 MB (configurable) ✅ blocks
Forbidden files .env, *.pem, *.key, id_rsa, *.user, *.suo, .vs/, bin/ and obj/ output, *.publishsettings, … (.env.example is allowed) ✅ blocks
Debug statements console.log, debugger, it.only / describe.only, pdb, binding.pry, Debugger.Break() ⚠️ warns
Protected branches Committing straight to main / master ⚠️ warns
TODO / FIXME Newly added TODOs off
Trailing whitespace · Final newline Both can be fixed automatically off
Branch naming e.g. feature/…, fix/… off
Commit message Conventional Commits, required ticket IDs (ABC-123), length limits off
Your own commands Any shell command, filtered by glob, at pre-commit, commit-msg or pre-push —

"auto" means the check runs when Tollgate finds that tool's config in your project. It doesn't run twice if one of your package.json scripts already calls the tool.

Your results

The Checks view in the Activity Bar shows every check for each git hook. It also shows disabled checks, so you can turn them on in one click. Hover a check to run it again or disable it. Right-click to change its severity.

The Tollgate Checks view

Every finding also appears in the Problems panel, with the check that raised it:

Findings in the Problems panel

Configure without leaving the editor

Use Tollgate: Enable / Disable Checks… to pick checks from a list:

Enable or disable checks from a quick pick

…or edit .tollgaterc.json, which has full autocomplete and an explanation for every option:

Autocomplete in .tollgaterc.json

Getting started

  1. Install Tollgate from the Marketplace (v1.1.2+).
  2. Open a git repository. Tollgate offers to install its git hooks. Click Install hooks.
  3. Commit as usual. If a blocking check fails, the commit is stopped and Tollgate shows you why.

Want to check before you commit? Click ▶ in the Tollgate view, or run Tollgate: Run Checks on Staged Changes.

Requirements: Git, and a workspace you trust. Tollgate runs commands from the repository, so it is turned off in Restricted Mode. The hooks use Node.js from your PATH, or VS Code's built-in runtime if Node isn't installed.

Configuration

Most people never need to edit config: change things from the Tollgate view and command palette. To share rules with your team, run Tollgate: Create / Open .tollgaterc.json and commit the file.

// .tollgaterc.json
{
  "extends": "recommended",          // minimal | recommended | strict | none
  "failOn": "error",                 // set to "warning" to block on warnings too
  "checks": {
    "npmScripts": { "scripts": ["lint", "typecheck", "test"] },
    "prettier": { "applyFixes": true },              // format & re-stage instead of failing
    "secrets": { "allowlist": ["EXAMPLE_KEY"] },
    "debugStatements": { "severity": "error" },
    "protectedBranches": { "branches": ["main", "release/*"], "severity": "error" },
    "commitMessage": { "enabled": true, "requireTicket": true, "ticketPattern": "PROJ-\\d+" },
    "largeFiles": { "maxSizeKB": 500 }
  },
  "custom": [
    { "name": "Stylelint", "command": "npx stylelint {files}", "glob": "**/*.{css,scss}" },
    { "name": "Unit tests", "command": "npm test", "stage": "pre-push" }
  ]
}

Where settings come from (later ones win): built-in defaults → preset → your VS Code settings (tollgate.*) → "tollgate" key in package.json → .tollgaterc.json (shared) → .tollgaterc.local.json (personal, add it to .gitignore).

Presets

Preset What you get
minimal Secrets, conflict markers, large and forbidden files, your lint script, and the auto-detected tools (Biome in lint-only mode)
recommended (default) Everything in the "Default" column of the table above
strict Recommended, plus whitespace, final newline, TODOs, branch naming, Conventional Commits and your test script. Debug statements block instead of warning.
none Nothing. Only the checks you turn on yourself.

Custom checks

Run Tollgate: Add Custom Check…, or add an entry under custom. Your command can use these placeholders:

Placeholder Becomes
{files} Staged files matching glob (quoted, and split into batches for long lists)
{root} Repository root
{branch} Current branch
{msgFile} Path to the commit message file (commit-msg stage)
{stagedCount} Number of matching staged files

Set "restage": true for formatters that rewrite files, so their changes are included in the commit. Files that also have unstaged edits are never re-staged automatically.

Skipping checks

To… Do this
Ignore one line Add a tollgate-ignore comment on that line (pragma: allowlist secret also works)
Skip some checks for one commit SKIP=secrets,prettier git commit -m "…"
Skip everything for one commit git commit --no-verify
Pause Tollgate in this workspace Tollgate: Pause / Resume Checks

The terminal output always lists the IDs of the checks that failed, so you can copy them straight into SKIP=.

Editor settings

Setting Default Description
tollgate.autoInstallHooks prompt prompt, always or never
tollgate.notifyOn failure When to show a notification after a hook runs: failure, all, never
tollgate.showDiagnostics true Show findings in the Problems panel
tollgate.showStatusBar true Show the status bar item
tollgate.showDisabledChecks true List disabled checks in the Checks view
tollgate.configTarget auto Where UI changes are saved: .tollgaterc.json if it exists, otherwise workspace settings

All .tollgaterc.json options (checks, custom, extends, failOn, exclude, hooks, autoFix, …) can also be set as tollgate.* VS Code settings.

C# and .NET

Tollgate turns its .NET checks on when your repo has a .sln, .slnx or project file and the dotnet CLI is on your PATH. Without the SDK, the checks are skipped and never block. Old-style (non-SDK) projects, such as classic .NET Framework apps and VSIX extensions, can't be built with dotnet build, so they're skipped too.

New in v1.1.2: Full monorepo support. Tollgate automatically finds the right solution for each project, handles nested global.json and tool manifests, and runs CSharpier from the correct folder.

Part What it runs Default
dotnet:format dotnet format --verify-no-changes, limited to the staged files and following your .editorconfig ✅ blocks
dotnet:build dotnet build on the solution or projects that own the staged files. Errors are reported with file and line. Monorepo aware: finds the right .sln/.slnx in any parent folder. ✅ blocks
dotnet:csharpier csharpier check when CSharpier is in .config/dotnet-tools.json or the repo has a .csharpierrc. Runs from the folder that has the tool manifest. Replaces dotnet format whitespace checks. ✅ auto
dotnet:test dotnet test, at pre-push. Respects nested test projects in monorepos. off (on in strict)
{
  "checks": {
    "dotnet": {
      "target": "src/App.sln",                    // optional; found automatically
      "format": { "mode": "whitespace", "applyFixes": true },  // auto | full | whitespace | style | analyzers
      "build": { "configuration": "Release", "warningsAsErrors": true },
      "test": { "enabled": true, "filter": "Category!=Integration" }
    }
  }
}

Skip it for one commit with SKIP=dotnet git commit …, or only the build with SKIP=dotnet:build.

Using Tollgate with Visual Studio

Tollgate is available as a Visual Studio extension with the same config and checks. Install it alongside the VS Code extension to use the same .tollgaterc.json in both editors.

Monorepo support

Nothing has to live at the repo root. Each check runs from the folder that owns the staged file:

  • package.json scripts run in the nearest package that has them when the root package.json is missing or has none of the configured scripts. Set "npmScripts": { "scope": "affected" } to always do that.
  • Biome, Prettier and lint-staged run from the nearest folder with their config file or dependency, using that package's node_modules and package manager.
  • .NET/C# (v1.1.2+) automatically finds the correct .sln or .slnx in the project folder or any parent that references the changed project. Respects nested global.json, tool manifests and .csharpierrc files. CSharpier runs from the folder that has its configuration. Set dotnet.target to pin a single solution or project.
  • Custom checks can use {root} to refer to the repository root, or run from a specific folder by setting cwd in the check definition.

Works with your existing setup

  • Existing git hooks are kept and run before Tollgate's checks.
  • Husky / core.hooksPath: run Tollgate: Integrate with Husky to add a one-line call to your Husky hooks. That line does nothing for teammates who don't have Tollgate, so it's safe to commit.

Using it without VS Code

The hook runner is a single file in your repo's .git folder. You can use it in scripts or CI:

node .git/tollgate/runner.js run            # check staged changes
node .git/tollgate/runner.js run --all      # check every tracked file
node .git/tollgate/runner.js run --only secrets,biome --json
node .git/tollgate/runner.js config         # show the resolved config and which sources it was built from
node .git/tollgate/runner.js list --json    # every check, enabled or not
node .git/tollgate/runner.js toggle dotnet:build off --local

FAQ

Will Tollgate ever block a commit because Tollgate itself broke? No. If the runner is missing or crashes, the hook lets the commit through and prints a message.

Does it slow down my commits? The built-in checks only read staged changes and take milliseconds. Your scripts (lint, typecheck) run in parallel, and only when relevant files are staged. A commit that only touches a README doesn't run your linter.

Can my team use it without the extension? Yes, for Husky users: integrate once and commit the hook line. Teammates without the extension skip it silently.

Do I need to install the .NET SDK? No, but Tollgate's .NET checks won't run without it. They're automatically skipped if dotnet isn't on your PATH.

Feedback

Found a bug or have an idea? Open an issue. If Tollgate saves you from committing a secret, a ⭐ on the repo is appreciated.

License

MIT

  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
  • Your Privacy Choices
  • Consumer Health Privacy
© 2026 Microsoft