rcorp / standard-project-structure

A mission to improve developer productivity. Automate Everything ™ !
Apache License 2.0
5 stars 3 forks source link

Rules for Linting TypeScript #15

Open gaurav21r opened 8 years ago

gaurav21r commented 8 years ago

I've done some research on what .tslintrc should look like. Here are my notes:

  1. We already have a very extensive ruleset for JavaScript / ECMAScript with AirBNB #6 .
  2. Unfortunately eslint currently does not work with TypeScript (https://github.com/eslint/typescript-eslint-parser). Its in the works but the autor @nzakas recommends to not use it in production.
  3. TSLint is currently the de facto standard for linting TypeScript.
  4. There is no comprehensive (and maintained) ruleset for tslint like AirBNB.
  5. Large projects in TypeScript have disparate rules for tslint:

In my opinion the long term view is to wait for ESLint to be compatible with TSLint so that all existing .eslintrc files are compatible with TypeScript on Day Zero. For this, I think whoever is reading this issue now or later should help @nzakas with https://github.com/eslint/typescript-eslint-parser

For now, we should use TSLint and find a ruleset which adheres to AirBNB for ES.

gaurav21r commented 8 years ago

@riteshe63 For now Lets go with this (https://github.com/Microsoft/tslint-microsoft-contrib/blob/master/tslint.json) Looks the most comprehensive and is Microsoft supported!

riteshe63 commented 8 years ago

27

Solve this issue

gaurav21r commented 7 years ago

We need the final configuration file like so:

{
  "rulesDirectory": "node_modules/tslint-microsoft-contrib",
  "extends": "tslint-microsoft-contrib",
  "rules": {
    "no-for-in-array": false,
    "restrict-plus-operands": false
  }
}

Please note the following points:

  1. We need to add rules because those rules which require typechecking is not supported by https://github.com/AtomLinter/linter-tslint Tracking AtomLinter/linter-tslint/issues/109.
  2. extends won't work until https://github.com/Microsoft/tslint-microsoft-contrib/pull/263 is merged.
HamletDRC commented 7 years ago

There are some angular rules here: https://github.com/mgechev/codelyzer

I have no idea if they are high quality or not.

gaurav21r commented 7 years ago

Great @HamletDRC Will check it out :+1: Do checkout the rest of this repo (although its highly work in progress) and any feedback would be appreciated :)

gaurav21r commented 7 years ago

extends is now done in because of https://github.com/Microsoft/tslint-microsoft-contrib/issues/263 thanks to @HamletDRC

We still need to follow up on https://github.com/AtomLinter/linter-tslint/issues/109