Skip to content

brettjacobson/TSLint.MSBuild

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

87 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TSLint for MSBuild

NuGet Version and Downloads count

An MSBuild target for linting TypeScript code using TSLint. Get it at nuget.org.

Usage

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.

Overrideable Item Groups

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" />

Overrideable Properties

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 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
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)
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). *.*.*
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

Output Item Groups

Item Group Description
TSLintOutput Lines of console output from the TSLint CLI.

Output Properties

Property Description
TSLintErrorCode Exit code of the TSLint CLI.

TSLint version

The first available TSLint version in your NuGet packages directory will be used.

Errata

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.

Development

Run the following commands to initialize your environment:

npm install

Run gulp to build. gulp test just runs tests.

Updating the version

The version number is stored both in package.json and TSLint.MSBuild.nuspec. Make sure to update it in both places.

0.X to 1.X

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.

Why?

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:

  1. MSBuild determined build settings and passed them to the JavaScript code
  2. JavaScript code determined the TSLint location and re-formulated any arguments
  3. JavaScript code ran TSLint via a spawned process, captured its output, and re-logged it
  4. 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:

  1. MSBuild determines build settings and TSLint location
  2. MSBuild runs TSLint using the packaged Node executable

0.3.X to 0.4.X

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.

About

An MSBuild task for running Palantir's wonderful TSLint.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%