Skip to content

jmbeach/tsqllint

 
 

Repository files navigation

npm version Build Status codecov

npm Gitter chat

tsqllint

tsqllint is a tool for describing, identifying, and reporting on undesirable patterns in TSQL scripts

Installation

The recommended method of installing tsqllint is to install the tool globally using NPM.

This binary can be installed though the npm registry. First, install Node.js version 4 or higher, and then installation is done using the npm install command:

$ npm install tsqllint -g

Configuration

# generate a default .tsqllintrc file using the init flag
$ tsqllint --init

Usage

# lint a single file
$ tsqllint test.sql

# lint all files in a directory
$ tsqllint c:\database_scripts

# lint a list of files and directories, paths with whitespace must be enclosed in quotes
$ tsqllint file_one.sql file_two.sql "c:\database scripts"

# lint using wild cards
$ tsqllint c:\database_scripts\file*.sql

# print path to .tsqllintrc config file
$ tsqllint --print

# display usage info
$ tsqllint --help

Creating custom configurations

Configure tsqllint by editing its config file, which is called .tsqllintrc, you can find its location with the "--print-confg" or "-p" option.

Rules may be set to off, warning, or error.

{
    "rules": {
        "conditional-begin-end": "error",
        "data-compression": "error",
        "data-type-length": "error",
        "disallow-cursors": "error",
        "information-schema": "error",
        "keyword-capitalization": "error",
        "multi-table-alias": "error",
        "object-property": "error",
        "print-statement": "error",
        "schema-qualify": "error",
        "select-star": "error",
        "semicolon-termination": "error",
        "set-ansi": "error",
        "set-nocount": "error",
        "set-quoted-identifier": "error",
        "set-transaction-isolation-level": "error",
        "set-variable": "error",
        "upper-lower": "error"
    }
}

About

Configurable linting for TSQL

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C# 95.1%
  • PowerShell 2.4%
  • PLpgSQL 1.2%
  • Batchfile 0.9%
  • JavaScript 0.2%
  • Shell 0.2%