0

The react-script uses typescript-eslint internally which trows warnings/error and you see it in the terminal where the app is running.

I did create react app with create-react-app --typescript and did set up a tslint.json as follow:

 {
  "defaultSeverity": "error",
  "extends": [
    "tslint:recommended",
    "tslint-react",
    "tslint-eslint-rules",
    "tslint-plugin-prettier",
    "tslint-config-prettier"
  ],
  "jsRules": {},
  "linterOptions": {
    "exclude": ["node_modules", "dist", "build", "src/serviceWorker.ts"]
  },
  "rules": {
    "prettier": [true, "./.prettierrc"]
  },
  "rulesDirectory": []
}

and a lint check script like "lint": "tslint -p tsconfig.json -c tslint.json 'src/**/*.{ts,tsx}'" in package.json.

But not all typescript-eslint from react-script is covered by tslint and the lint script passes while there exists some warning.

Should I completely dump the usage of tslint and go for eslint? If so can someone provide a snippet for the settings?

Or if Tslint has any plan to be update and cover all those warnings from typescript-eslint

Amir-Mousavi
  • 4,273
  • 12
  • 70
  • 123

1 Answers1

0

Perhaps you could adjust your tslint configuration to get those warning it missed, but I don't think it is worth it.

For starters, as you note CRA has switched to eslint-typescript, and I think it is easier to just use the one officially supported linter rather then using both the old and the new.

Also, tslint is formally deprecated in favour of eslint-typescript so you are swimming against the stream and I doubt there will be updates. You might be able to get tslint to work as you want now, but probably not for the lifetime of your app.

The switch to eslint-typescript was announced almost a year ago and now that the major projects like CRA have also switched I think that early issues are resolved and it is time for all new projects to use it.

Tom
  • 17,103
  • 8
  • 67
  • 75
  • Yes, thanks, these are the good point I already knew, What I mostly was searching for was a setting snippet, extending from `react-app` with `prettier` inside the `.eslintrc` does not work as what https://create-react-app.dev/docs/setting-up-your-editor/ recommended. I have ssen people putting those rules in `package.json` I was looking for a working straight forward setup – Amir-Mousavi Dec 05 '19 at 14:25