I don’t know when tsLint stopped being used.

TSLint is a great tool. It is a linter written specifically for the TypeScript AST format described above.

However, the main drawback of TSLint is that it is not compatible with ESLint. Now that the ESLint community is so well established, TsLint cannot use the work of those communities or contribute its own work back to the community. So Palantir, the proponent behind TSLint, has announced that it will phase out TSLint in favor of typescript-esLint-Parser.

That is, the main difference between typescript-esLint-Parser and tsLint is that they are lint tools based on different AST. Typescript-eslint-parser is compatible with the ESLint ecosystem, It can be used with various plugins for ESLint, but tsLint cannot.

Palantir, the backer behind TSLint, announced in 2019 that they were abandoning TSLint in favor of ** typescript-ESLint ** for the benefit of the community. You can read more about it here: HTTPS

://medium.com/palantir/tslint-in-2019-1a144c2317a9

How do I use typescript-esLint?

The installation

npm i eslint @typescript-eslint/parser @typescript-eslint/eslint-plugin -D
Copy the code

To configure ESLint rules, see eslint.org/docs/rules/

module.exports = {  
parser: '@typescript-eslint/parser', // Specifies the ESLint parser  
extends: [    
  'plugin:@typescript-eslint/recommended', // Uses the recommended rules from the @typescript-eslint/eslint-plugin    
  'prettier',  
],  
plugins: ['eslint-plugin-react'],  
rules: {    
  // Place to specify ESLint rules. Can be used to overwrite rules specified from the extended configs    
  // e.g. "@typescript-eslint/explicit-function-return-type": "off",
  // 0:"off", 1:"warn", 2:"error"    
  semi: 2,    
  '@typescript-eslint/no-empty-interface': 0,    
  '@typescript-eslint/ban-types': [      
    2,      
    {  
      types: {          
        Function: {            
          message: 'Prefer a specific function type, like `() => void`.',          
        },       
       },      
      },    
    ],    
   'no-use-before-define': 0,    
   '@typescript-eslint/no-use-before-define': 2,    
   'no-shadow': 0,    
   '@typescript-eslint/no-shadow': 2  
},  
parserOptions: {    
  sourceType: 'module',    
  ecmaFeatures: {      jsx: true,    },  
},  
settings: {    
  react: {      
    version: 'detect', // Tells eslint-plugin-react to automatically detect the version of React to use    
  },  
},
Copy the code

Note that esLint has some rules that conflict with @typescript-esLint and need to be adjusted:

Import React from ‘React ‘; Error problems are reported

'no-use-before-define': 0,    
'@typescript-eslint/no-use-before-define': 2,    
Copy the code

Resolve an enum type definition error

'no-shadow': 0,   
'@typescript-eslint/no-shadow': 2
Copy the code

Configuration vscode

{
  "eslint.validate": [
    "javascript",
    "javascriptreact",
    "typescript",
    "typescriptreact"
  ],
}
Copy the code

Learn to waste!