Skip to content

Instantly share code, notes, and snippets.

@doxxx
Last active December 23, 2018 19:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save doxxx/be29aee5e414e7ac424c77cd62afaef5 to your computer and use it in GitHub Desktop.
Save doxxx/be29aee5e414e7ac424c77cd62afaef5 to your computer and use it in GitHub Desktop.
Steps to add TSLint to create-react-app project using the Typescript compiler plugin
  1. yarn add prettier tslint tslint-config-prettier tslint-react typescript-tslint-plugin
  2. Add the following to tsconfig.json:
    "plugins": [
      {
        "name": "typescript-tslint-plugin"
      }
    ]
  3. Create tslint.json containing the following:
    {
      "extends": ["tslint:recommended", "tslint-react", "tslint-config-prettier"],
      "linterOptions": {
        "exclude": [
          "node_modules/**/*.ts",
        ]
      },
      "rules": {
        // your custom rules here
      }
    }
  4. In Visual Studio Code:
    1. Install extensions: TypeScript TSLint Plugin and Prettier - Code formatter.
    2. Enable 'Editor: Format on Save' setting.
    3. Use the Typescript: Select Typescript Version command to select Use Workspace Version.
    4. Restart Visual Studio Code.
@doxxx
Copy link
Author

doxxx commented Dec 23, 2018

Custom TSLint rules that I like to use:

{
  "quotemark": [true, "double"],
  "jsx-no-lambda": false
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment