What is the difference between `extends` and `rulesDirectory` in TSLint

mit*_*air 9 lint typescript eslint tslint

The TSLint.json config file (https://github.com/palantir/tslint) supports extends and a rulesDirectory array like so

{
  "extends": [
    "tslint-microsoft-contrib",
    "tslint-config-security"
  ],
  "rulesDirectory": [
    "node_modules/tslint-eslint-rules/dist/rules",
    "node_modules/tslint-microsoft-contrib",
    "node_modules/tslint-config-security"
  ]
}
Run Code Online (Sandbox Code Playgroud)

The docs seem slightly open to interpretation for new users unfamiliar to the tool.

I would appreciate if anyone could clarify a few points on the behaviour of extends and rulesDirectory in relation to use in the VS Code editor and tslinting in general.

  1. Does extends only provide a default configuration (if provided by package)?

  2. and is this therefore different to rulesDirectory?

    • Does rulesDirectory only provide rules for you to specifically opt-in(and is required if specifying rules in the root tslint.json)?

    • Should I still specify the tslint packages in both extends and rulesDirectory?

  3. Assuming extends provides defaults from another tslint config file, would I be able to specify the rulesDirectory and add a rule to override a specific flag?

Concerned because only some of the rules show up in IntelliSense autocompletion and just a few behaviours that I would appreciate more clarity for.

bas*_*rat 5

extendsrulesDirectoryTSLint 和有什么不一样

他们有很大的不同。

  • extends 允许您应用现有的tslint配置,然后对其进行扩展
  • rulesDirectory 只是允许您添加自定义规则的目录。

  • 我根本不明白这些差异......你写的它们非常不同,但正如你所描述的,在这两种情况下,它们只是从包中添加自定义规则。一旦这些自定义规则来自配置文件,反之亦然,它们来自目录。所以我想说,它们几乎相同,但是添加它们的方式有点不同(配置文件与目录)。 (3认同)