esLint - Configuring “no-unused-vars” for Typescript

后端 未结 4 1053
暗喜
暗喜 2020-12-09 00:56

I use esLint in all of my Typescript projects with the following settings:

  \"extends\": [\"airbnb\", \"prettier\", \'plugin:vue/recommended\'],
  \"plugins         


        
4条回答
  •  轮回少年
    2020-12-09 01:53

    It's a bit buried in the documentation, but if you add some things to the 'extends' property, you can use both the rules recommended by ESLint like no-unused-vars, and have it actually work in Typescript. Like so:

    "extends": [
            "eslint:recommended",
            "plugin:@typescript-eslint/eslint-recommended",
            "plugin:@typescript-eslint/recommended"
        ],
    

    @typescript-eslint/recommended seems to be the thing that allows eslint:recommended to deal with Typescript constructs effectively. Not sure how it would affect your other extensions though.

提交回复
热议问题