DEV Community

Cover image for What kind of tslint config you use for your React project?
Evaldas Buinauskas
Evaldas Buinauskas

Posted on

What kind of tslint config you use for your React project?

I've just started looking at TypeScript, React and wanted to prepare a nice working environment for it.

I've began with

create-react-app my-app --scripts-version=react-scripts-ts
Enter fullscreen mode Exit fullscreen mode

Added following dependencies

yarn add -D prettier tslint-config-prettier tslint-plugin-prettier husky pretty-quick
Enter fullscreen mode Exit fullscreen mode

Let Prettier know that I want single quotes, not doubles:

{
  "singleQuote": true
}
Enter fullscreen mode Exit fullscreen mode

Have added the following to my tslint.json:

{
  "extends": [
    "tslint-react",
    "tslint-plugin-prettier",
    "tslint-config-prettier"
  ],
  "rules": {
    ...,
    "prettier": true

  }
}

Enter fullscreen mode Exit fullscreen mode

And then added following line to my package.json:

{
  "scripts": {
    ...,
    "precommit": "pretty-quick staged"
  }
}
Enter fullscreen mode Exit fullscreen mode

It does seem to work nice for myself. Formatting is left for prettier and linting is done by tslint. What kind of setup do you use?

Top comments (0)