tsqllint is a tool for describing, identifying, and reporting on undesirable patterns in TSQL scripts
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
# generate a default .tsqllintrc file using the init flag
$ tsqllint --init
# 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
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"
}
}