Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between `extends` and `rulesDirectory` in 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"
  ]
}

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.

like image 584
mittens pair Avatar asked Jul 08 '18 22:07

mittens pair


People also ask

What is the use of Tslint json file?

When using the CLI or many third-party tools, a file named tslint. json or tslint. yaml is used to configure which rules get run and each of their options.

Which command is correct regarding to Tslint?

tslint accepts the following command-line options: -c, --config: The location of the configuration file that tslint will use to determine which rules are activated and what options to provide to the rules. If no option is specified, the config file named tslint.


1 Answers

What is the difference between extends and rulesDirectory in TSLint

They are very different.

  • extends allows you to apply an existing tslint config and then extend it
  • rulesDirectory simply allows you to add directories for custom rules.
like image 162
basarat Avatar answered Oct 23 '22 00:10

basarat