Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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'] }; 
like image 940
Jian Cl Avatar asked Mar 21 '19 12:03

Jian Cl


People also ask

How do you ignore no-unused-vars ESLint?

To apply the ESLint no-unused-vars rule to a block of JavaScript code, we can wrap the code block that we want to apply the rule to with /* eslint-disable no-unused-vars */ and /* eslint-enable no-unused-vars */ respectively. to wrap the code that we want the rule to apply with the comments.

Why are there no unused variables?

Variables that are declared and not used anywhere in the code are most likely an error due to incomplete refactoring. Such variables take up space in the code and can lead to confusion by readers.

How do I disable typescript ESLint?

If you are using ESLint and you need to disable the next line, use this code: eslint-disable-next-line.


1 Answers

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" } 
like image 146
James Middleton Avatar answered Sep 20 '22 12:09

James Middleton