Can't override ESLint rule "@typescript-eslint/no-unused-vars"
See original GitHub issueI tried different possibilities to override the default warning setting for “@typescript-eslint/no-unused-vars”.
The config below is what I ended up with. I also added an additional rule “no-empty-function” just to see if the whole section gets interpreted which is the case. My goal was to disable the rule for test files like “**/*.test.ts?(x)” but neither works for me.
"eslintConfig": {
"extends": [
"react-app",
"react-app/jest"
],
"overrides": [
{
"files": [
"**/*.ts?(x)"
],
"rules": {
"no-unused-vars": "off",
"@typescript-eslint/no-unused-vars": [
"off"
],
"no-empty-function": 2
}
}
]
},
Indeed, and that is interesting, it does work when I delete the lines from .\node_modules\eslint-config-react-app\index.js:82-88:
'@typescript-eslint/no-unused-vars': [
'warn',
{
args: 'none',
ignoreRestSiblings: true,
},
],
After this hard patch I’m able to set the values “off”, “warn” or “error” in the package.json above as I wish and it works fine.
Having in mind that I upgraded to react-scripts 4.0.1 from an earlier 3x version.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:6
- Comments:9
Top Results From Across the Web
Typescript eslint disable no-unused-vars - Stack Overflow
Go into your settings and search for 'eslint', then look for something called Elint:enable, uncheck the ...
Read more >no-unused-vars - ESLint - Pluggable JavaScript Linter
This rule is aimed at eliminating unused variables, functions, and function parameters. A variable foo is considered to be used if any of...
Read more >no-unused-vars - TypeScript ESLint
Disallow unused variables. Extending "plugin:@typescript-eslint/recommended" in an ESLint configuration enables this rule.
Read more >The 3 Best ESLint No-Unused-Vars Option Settings (Make it ...
Disable ESLint No-Unused-Vars Rule · Set "no-unused-vars": "off" in .eslintrc.json · Wrap a code block in /* eslint-disable no-unused-vars */ ( ...
Read more >typescript-eslint/no-unused-expressions' was not found
I want to use Jasmine and i'm in the middle of the tutorial of Jasmine, but they don't mention in the document how...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Non of the above solutions worked for me.
In my case the solution was to change the tsconfig.json
I dont want to disable it for each of those thousands of test files manually with comments. Further these comments have the disadvantage to disable it. What do you do if you decide to warn about these errors or fail in production in future when passing quality gate?
There are reasons where you like to have these unused vars (momentary), for instance when you especially know that your code will evolve within the next sprints. You are able to prepare it as much as possible, so the next developer will catch up more easily, knowing what is important. Or you have some objects for debug purposes in the test files when you play around with them. It can be valid code though, so there is no need to comment the whole setup out.
I could find plenty of reasons, but for long story short: If I want unused vars, I want unused vars! 😉 I am talking about the technical impediment here, not about if it is useful or not.
Cheers!