JoshuaKGoldberg / TSLint.MSBuild

[Deprecated] An MSBuild task for running TSLint.
https://www.nuget.org/packages/TSLint.MSBuild
MIT License
15 stars 13 forks source link
code-quality csproj linter msbuild tslint typescript

TSLint for MSBuild

NuGet Version and Downloads count

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. ⚠️

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

Overrideable Properties

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

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 -g gulp
npm install

Run npx gulp default to build. npx 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.

File a bug report if upgrading causes any issues.