Migrating to TSLint

In notebook:
FrontEndMasters Intermediate React
Created at:
2019-06-25
Updated:
2019-08-15
Tags:
React libraries JavaScript

https://frontendmasters.com/courses/intermediate-react-v2/migrating-to-tslint/

Use TSLint instead of ESLint

Eventually they want to stop the fork, between TSLint and ESLint and just use ESLint for everyone. It will take until 2020 for this migration to be ready. ESLint does understand TypeScript, but doesn't have many rules for it yet.

Remove all the ESLint packages:

npm uninstall eslint babel-eslint eslint-config-prettier eslint-plugin-import eslint-plugin-JSX-a11y eslint-plugin-react eslint-plugin-react-hooks

then install TSLint:

npm install -D tslint tslint-react tslint-config-prettier

then delete the eslint config file, eslintrc.json.

then update package.json

   //    ****        package.json        ****

 "scripts": {
  "lint": "tslint --project"
 }

This means that TSLint should read its settings from the tsconfig file.

then create the settings file tslint.json

   //    ****  tslint.json     ****

{
"extends": ["tslint:recommended", "tslint-react", "tslint-config-prettier"], // make sure tslint prettier is last
  "rules": {
    "ordered-imports": false, // not necessary
    "object-literal-sort-keys": false, // not useful
    "member-ordering": false, // again not needed to alphabetize
    "no-console": false,
    "jsx-no-lambda": false // it wouldn't work with hooks
  }
}

Then in VSCode, install the TSLint plugin.