tslint-microsoft-contrib

在一些微软项目中使用的一组 TSLint 规则。(A set of TSLint rules used on some Microsoft projects.)

  • Owner: microsoft/tslint-microsoft-contrib
  • Platform: BSD, Cross-platform, Linux, Mac, Web browsers, Windows
  • License:: MIT License
  • Category::
  • Topic:
  • Like:
    0
      Compare:

Github stars Tracking Chart

tslint-microsoft-contrib

在一些微软项目中使用的一组 TSLint 规则。

请参阅我们的发行说明以查找最新的新规则。

安装

npm install tslint-microsoft-contrib --save-dev

TSLint和相应的tslint-microsoft-contrib版本

TSLint version tslint-microsoft-contrib version
>= 5.x 5.x and 6.x (supporting TypeScript 2.3.x, >=2.4, 3.x)
>= 4.x 4.x (supporting TypeScript 2.1.x)
>= 3.2.x 2.x
3.1.x unsupported
3.0.x unsupported
2.x 1.x

配置

在“rulesDirectory”配置下添加“node_modules/tslint-microsoft-contrib”以通知TSLint它应该在此包下查找tslint.json中的其他规则:

{
    "rulesDirectory": ["node_modules/tslint-microsoft-contrib"],
    "rules": {
        // ...
    }
}
我应该打开哪个规则?

当然有很多选择! 首先,您可以通过在tslint.json中的“extends”下添加“tslint-microsoft-contrib”来启用我们推荐的默认值(recommended_ruleset.js):

{
    "extends": ["tslint-microsoft-contrib"],
    "rulesDirectory": ["node_modules/tslint-microsoft-contrib"],
    "rules": {
        // ...
    }
} 

然后,您可以禁用您认为有用的规则。

请注意,某些默认规则需要--project TSLint选项。

另请注意,向推荐的规则集添加规则被视为向后兼容。 如果依赖于依赖项中的版本范围,那么您可能会发现添加到产品中的新规则会导致违规并导致构建失败。 我们建议您在package.json中指定lint库的确切版本,包括tslint-microsoft-contrib。

Main metrics

Overview
Name With Ownermicrosoft/tslint-microsoft-contrib
Primary LanguageTypeScript
Program languageJavaScript (Language Count: 2)
PlatformBSD, Cross-platform, Linux, Mac, Web browsers, Windows
License:MIT License
所有者活动
Created At2015-08-20 12:44:29
Pushed At2020-12-10 08:13:40
Last Commit At2020-12-10 09:13:39
Release Count73
Last Release Name6.2.0 (Posted on )
First Release Namenpm-0.0.1 (Posted on )
用户参与
Stargazers Count699
Watchers Count48
Fork Count200
Commits Count879
Has Issues Enabled
Issues Count511
Issue Open Count0
Pull Requests Count270
Pull Requests Open Count0
Pull Requests Close Count113
项目设置
Has Wiki Enabled
Is Archived
Is Fork
Is Locked
Is Mirror
Is Private

tslint-microsoft-contrib

npm version
Downloads
TravisCI Build Status
Azure Pipelines Build Status
Join the chat at https://gitter.im/Microsoft/tslint-microsoft-contrib
code style: prettier

A set of TSLint rules used on some Microsoft projects.

Notice

This project is in read-only and archive mode.

Installation

npm install tslint-microsoft-contrib --save-dev

TSLint and corresponding tslint-microsoft-contrib version

TSLint version tslint-microsoft-contrib version
>= 5.x 5.x and 6.x (supporting TypeScript 2.3.x, >=2.4, 3.x)
>= 4.x 4.x (supporting TypeScript 2.1.x)
>= 3.2.x 2.x
3.1.x unsupported
3.0.x unsupported
2.x 1.x

Configuration

Add "node_modules/tslint-microsoft-contrib" under your "rulesDirectory" configuration to inform TSLint it should look under this package for additional rules in your tslint.json:

{
    "rulesDirectory": ["node_modules/tslint-microsoft-contrib"],
    "rules": {
        // ...
    }
}

Which Rules Should I Turn On?

There certainly are a lot of options!

If you extend from one of the following configurations, rulesDirectory will have node_modules/tslint-microsoft-contrib included for you.

Please note, some of the default ruleset rules require the --project TSLint option.

To start, you can enable our stable "recommended" defaults that come with tslint-microsoft-contrib (recommended.json) by adding "tslint-microsoft-contrib/recommended" under "extends" in your tslint.json:

{
    "extends": ["tslint-microsoft-contrib/recommended"]
    // ...
}

These rules will not be added to in minor or patch releases, but will be in major releases.

Latest

To run with the latest and greatest rules (latest.json), extend from tslint-microsoft-contrib/latest:

{
    "extends": ["tslint-microsoft-contrib/latest"]
    // ...
}

These rules will not be added to in patch releases, but will be in minor releases.

Legacy

The old "recommended" ruleset that ships by extending tslint-microsoft-contrib itself contains a list of rules that includes core TSLint rules.

To start, you can enable our recommended defaults (recommended.json) by adding just "tslint-microsoft-contrib" under "extends" in your tslint.json:

{
    "extends": ["tslint-microsoft-contrib"]
    // ...
}

This ruleset is considered legacy; it is generally preferable to extend from the 'recommended' or 'latest' rulesets.
We recommend you instead explicitly include tslint:recommended, tslint:latest, or tslint:all in your tslint.json rather than enable core rules through this configuration.

In the next major version of TSLint, this will instead be an alias for "tslint-microsoft-contrib/recommended".

Overriding Configurations

You can disable rules you don't find useful.

If you rely on version ranges in your dependencies then you may find that new rules being added to the product create violations and fail your build.
We recommend you specify exact versions of lint libraries, including tslint-microsoft-contrib, in your package.json.

Supported Rules

Development

See CONTRIBUTING.md.

Release notes

Check GitHub Releases for individual release notes or CHANGELOG.md for full project changelog.