@typescript-eslint/eslint-plugin error: 'Route' is defined but never used (no-unused-vars)

Jian Cl picture Jian Cl · Mar 21, 2019 · Viewed 10.7k times · Source

After eslint adds typescript check, there will be an error when the attribute variable in the class definition is Array. enter image description here

enter image description here

enter image description here


this is my eslintrc.js

module.exports = {
  root: true,
  env: {
    node: true
  },
  'extends': ['plugin:vue/essential', '@vue/standard'],
  rules: {},
  parserOptions: {
    parser: '@typescript-eslint/parser',
    project: "./tsconfig.json"
  },
  plugins: ['@typescript-eslint']
};

Answer

James Middleton picture James Middleton · Jul 2, 2019

The solution is to disable the native no-unused-vars so that only the TS one is enabled. The former is likely to be enabled if you extend a config in ESLint. Add the rules below to your ESLint config.

"rules": {
  "no-unused-vars": "off",
  "@typescript-eslint/no-unused-vars": "error"
}