Skip to main content

TSLint

danger

We have dropped the support for TSLint on July 8, 2021. Please migrate to TypeScript ESLint. tslint-to-eslint-config might help your migration.

Supported VersionLanguageWebsite
5.0.0+ (default: 6.1.3)TypeScripthttps://palantir.github.io/tslint

TSLint is an extensible static analysis tool for TypeScript. It checks your code for readability, maintainability, and functionality errors.

Getting Started#

To start using TSLint, enable it in your repository settings. After enabled, Sider will automatically analyze your TypeScript files with the default version and default configuration. Or if you already have configured TSLint, Sider will install your dependencies and analyze with your configuration.

But if you have no configuration yet and need more customization, install TSLint first:

$ npm install tslint --save-dev

Next, create the configuration file (tslint.json):

$ npx tslint --init

Then, edit the configuration file as you want. For more details about the configuration, please see the TSLint documentation.

Default Configuration for TSLint#

Sider prepares the default TSLint configuration.

Configuration#

Here is an example configuration via sider.yml:

linter:  tslint:    glob: "path/to/**/*.ts"    config: my_tslint.json    exclude: "vendor/**"    project: frontend/tsconfig.json    rules-dir: your_custom_rules/

You can use the following options to make analysis fitter for your project.

NameTypeDefault
root_dirstring-
dependenciesstring[], map[]-
npm_installboolean, string-
globstring**/*.ts{,x}
configstring-
excludestring, string[]node_modules/**
projectstring-
rules-dirstring, string[]-
type-checkbooleanfalse

glob#

This option allows you to specify files to analyze.

config#

This option allows you to specify a configuration file you want.

exclude#

This option allows you to exclude files from analysis. Glob patterns are also available.

project#

This option allows you to specify a TypeScript project file or directory.

rules-dir#

This option allows you to specify your own rules. If you want to use multiple rules, declare them as follows:

linter:  tslint:    rules-dir:      - rules/ACustomRule      - rules/AnotherCustomRule
note

Note that you need to use TSLint since version 5.12.0 to set the rules-dir option as an array.

type-check#

This option controls whether to enable type checking when running TSLint. If you want type checking, set this to true.

note

Note that the option is deprecated since TSLint version 5.8.0. TSLint no longer have done type checking since it. For more details about the change, see the pull request.