An MSBuild target for linting TypeScript code using TSLint. Get it at nuget.org.
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) |
---|---|---|
TSLintRulesDirectory |
Directories for user-created rules | (blank) |
Note that to use special characters (such as *
wildcards) in TSLintExclude
you must escape the special characters.
<!-- Equivalent to "typings/**/*.d.ts" -->
<TSLintExclude Include="typings/%2A%2A/%2A.d.ts" />
Property | Description | Default |
TSLintBreakBuildOnError |
Whether linting failures should break the build. | false |
---|---|---|
TSLintConfig |
Path to a specific tslint.json. | (blank) |
TSLintCli |
Path to a TSLint CLI to run with. | The highest-versioned TSLint version in the solution's packages directory. |
TSLintDisabled |
Whether to skip running TSLint. | false |
TSLintExtraArgs |
Any extra arguments to pass to the TSLint CLI. | (blank) |
TSLintNodeExe |
Path to a Node executable to execute the runner script. | The tools\node-7.3.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) |
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
Run gulp
to build.
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.
0.X versions ran JavaScript logic to search for TSLint, run it, and wrap the output. This was slow (running two nested Node processes, with intermediary file names in text).
1.X versions now are completely in a single MSBuild file. This is better for performance but has two downsides:
- It no longer searches for the "highest" available TSLint version in the packages directory; instead, the first found in a file search is used.
- The
TSLintErrorSeverity
flag is no longer supported (until TSLint adds support for error levels).
Furthermore, 1.0.0
removed the TSLint NuGet package dependency.
You'll need to install it separately.
The original structure of TSLint.MSBuild requires multiple layers of processes calling each other, which can wreak havoc in complex managed build systems. Then, in order:
- MSBuild determined build settings and passed them to the JavaScript code
- JavaScript code determined the TSLint location and re-formulated any arguments
- JavaScript code ran TSLint via a spawned process, captured its output, and re-logged it
- MSBuild captured the (re-logged TSLint) JavaScript output and logged it
1.X unified all the logic into MSBuild, which resulted in significant performance gains, code simplification, and runtime stability. Now, in order:
- MSBuild determines build settings and TSLint location
- MSBuild runs TSLint using the packaged Node executable
Versions 0.3.X and below manually call TSLint on individual folders, whereas 0.4.X defers to the TSLint CLI.
File a bug report if upgrading causes any issues.