VSCode and TSLint Setup

#linter#tslin#ts#typescript#vscode#microsoft

By Oguzhan Cakmak at

TLDR

TSLint will hopefully be deprecated next year (2021). Till then it is the best linter option for Typescript project and VSCode should work with it properly

Example TSLint Rules

{
  "extends": ["tslint:recommended", "tslint-react", "tslint-config-prettier"],
  "rules": {
    "ordered-imports": true,
    "object-literal-sort-keys": true,
    "member-ordering": true,
    "no-console": true,
    "jsx-no-lambda": true
  }
}

How to setup VSCode to format on save based on TSLint Rules

  1. Press CMD + , or click Code, Preferences and Settings

  2. Click the icon below vscode

  3. Add "tslint.autoFixOnSave": true to settings.json file

Conclusion

Your VSCode should format on save and live happily ever after with TSLint