An MSBuild target for linting TypeScript code using TSLint. Get it at nuget.org.
⚠️ TSLint is deprecated. See this issue for more details: Roadmap: TSLint → ESLint. ⚠️
Add this package and TSLint using your NuGet Package Manager. It should be automatically added to your project.
TSLint's default configurations are used by default.
If you'd like to use your own tslint.json
file, add a TSLintConfig
property to your project:
<TSLintConfig>Scripts/tslint.json</TSLintConfig>
All overrideable item groups and properties are below. Read the TSLint documentation for TSLint-specific linting details.
Item Group | Description | Default |
TSLintExclude |
Globs of file names to exclude. | (blank) |
---|---|---|
TSLintInclude |
File names to lint. | @(TypeScriptCompile) (unless TSLintExcludeTypeScriptCompile is true ) |
TSLintRulesDirectory |
Directories for user-created rules | (blank) |
<ItemGroup>
<TSLintExclude Include="typings/**/*.d.ts"><Visible>False</Visible></TSLintExclude>
</ItemGroup>
Property | Description | Default |
TSLintBreakBuildOnError |
Whether linting failures should break the build. | false |
---|---|---|
TSLintCreateTimestampFile |
Whether the timestamp file should be created on each build. | true |
TSLintConfig |
Path to a specific tslint.json. | (blank) |
TSLintForceBuild |
Force TSLint to run after the build, even if there are no file changes. Not compatible with TSLintTimestampFile , this is the recommended option when using TSLintBreakBuildOnError |
false |
TSLintCli |
Path to a TSLint CLI to run with. | The first TSLint version in the solution's packages directory, or the Project Dir's node_modules/tslint/bin/tslint directory. |
TSLintDisabled |
Whether to skip running TSLint. | false |
TSLintExcludeTypeScriptCompile |
Whether to exclude @(TypeScriptCompile) from @(TSLintInclude) . |
false |
TSLintExtraArgs |
Any extra arguments to pass to the TSLint CLI. | (blank) |
TSLintFileListDisabled |
Whether to disable passing TypeScript file list on the command line. If true, it is expected that the files to lint are specified in the TSLintProject file. |
false |
TSLintNodeExe |
Path to a Node executable to execute the runner script. | The tools\node-12.4.0.exe in the package. |
TSLintProject |
Path to a tsconfig.json file to use as a type checker project. |
(blank) |
TSLintRunOutsideBuildingProject |
Whether to run even if BuildingProject isn't true . |
(blank) |
TSLintTimeout |
Maximum time to run the task, in case TSLint hangs or takes too long. | 10000000 |
TSLintTypeCheck |
Whether to enable the type checker (requires TSLintProject be set). |
false |
TSLintVersion |
Glob filter for the version of TSLint to use (ignored if TSLintConfig is provided). |
*.*.* |
Item Group | Description |
TSLintOutput |
Lines of console output from the TSLint CLI. |
---|
Property | Description |
TSLintErrorCode |
Exit code of the TSLint CLI. |
---|
The first available TSLint version in your NuGet packages directory will be used.
You can exclude .d.ts
files using <TSLintExclude Include="%2A%2A/%2A.d.ts" />
.
MSBuild escapes *
and other special characters using %
and their hexadecimal value.
Run the following commands to initialize your environment:
npm install -g gulp
npm install
Run npx gulp default
to build.
npx gulp test
just runs tests.
The version number is stored both in package.json
and TSLint.MSBuild.nuspec
.
Make sure to update it in both places.
File a bug report if upgrading causes any issues.