Skip to content

tsqllint

GitHub stars GitHub release (latest SemVer) GitHub last commit GitHub commit activity GitHub contributors

tsqllint documentation

tsqllint - GitHub

Configuration in MegaLinter

Variable Description Default value
SQL_TSQLLINT_ARGUMENTS User custom arguments to add in linter CLI call
Ex: -s --foo "bar"
SQL_TSQLLINT_COMMAND_REMOVE_ARGUMENTS User custom arguments to remove from command line before calling the linter
Ex: -s --foo "bar"
SQL_TSQLLINT_FILTER_REGEX_INCLUDE Custom regex including filter
Ex: (src\|lib)
Include every file
SQL_TSQLLINT_FILTER_REGEX_EXCLUDE Custom regex excluding filter
Ex: (test\|examples)
Exclude no file
SQL_TSQLLINT_CLI_LINT_MODE Override default CLI lint mode
- file: Calls the linter for each file
- list_of_files: Call the linter with the list of files as argument
- project: Call the linter from the root of the project
list_of_files
SQL_TSQLLINT_FILE_EXTENSIONS Allowed file extensions. "*" matches any extension, "" matches empty extension. Empty list excludes all files
Ex: [".py", ""]
[".sql"]
SQL_TSQLLINT_FILE_NAMES_REGEX File name regex filters. Regular expression list for filtering files by their base names using regex full match. Empty list includes all files
Ex: ["Dockerfile(-.+)?", "Jenkinsfile"]
Include every file
SQL_TSQLLINT_PRE_COMMANDS List of bash commands to run before the linter None
SQL_TSQLLINT_POST_COMMANDS List of bash commands to run after the linter None
SQL_TSQLLINT_UNSECURED_ENV_VARIABLES List of env variables explicitly not filtered before calling SQL_TSQLLINT and its pre/post commands None
SQL_TSQLLINT_CONFIG_FILE tsqllint configuration file nameUse LINTER_DEFAULT to let the linter find it .tsqllintrc
SQL_TSQLLINT_RULES_PATH Path where to find linter configuration file Workspace folder, then MegaLinter default rules
SQL_TSQLLINT_DISABLE_ERRORS Run linter but consider errors as warnings false
SQL_TSQLLINT_DISABLE_ERRORS_IF_LESS_THAN Maximum number of errors allowed 0
SQL_TSQLLINT_CLI_EXECUTABLE Override CLI executable ['tsqllint']

IDE Integration

Use tsqllint in your favorite IDE to catch errors before MegaLinter !

IDE Extension Name Install
Visual Studio Code TSQL Lint Install in VSCode

MegaLinter Flavours

This linter is available in the following flavours

Flavor Description Embedded linters Info
all Default MegaLinter Flavor 121 Docker Image Size (tag) Docker Pulls
dotnet Optimized for C, C++, C# or VB based projects 63 Docker Image Size (tag) Docker Pulls
dotnetweb Optimized for C, C++, C# or VB based projects with JS/TS 72 Docker Image Size (tag) Docker Pulls

Behind the scenes

How are identified applicable files

  • File extensions: .sql

How the linting is performed

  • tsqllint is called once with the list of files as arguments (list_of_files CLI lint mode)

Example calls

tsqllint myfile.sql
tsqllint myfile.sql myfile2.sql

Help content

running tsqllint

tsqllint [options] [file.sql] | [dir] | [file.sql | dir]

  -c, --config          Used to specify a .tsqllintrc file path other than the
                        default
  -g, --ignorelist      Used to specify a .tsqllintignore file path other than
                        the default
  -f, --force           Used to force generation of default config file when
                        one already exists
  -x, --fix             Used to fix some of the common linting errors if
                        possible
  -i, --init            Generate default .tsqllintrc config file
  -p, --print-config    Print path to config file
  -l, --list-plugins    List the loaded plugins
  -v, --version         Display tsqllint version
  -h, --help            Display this help dialog

Installation on mega-linter Docker image

  • Dockerfile commands :
ENV PATH="${PATH}:/root/.dotnet/tools"
RUN dotnet tool install --global TSQLLint