I need to disable some variable checks in ESLint
.
Currently, I am using this code, but am not getting the desired result:
/* eslint no-unused-vars: ["error", { "caughtErrorsIgnorePattern": "Hey" }] */ export type Hey = { a: string, b: object }
Two questions:
no-unused-vars
for a block of code?Something like...
/* eslint rule disable"*/ // I want to place my block of code, here /* eslint rule disable"*/
Hey
a global variable so that it can be ignored everywhere?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.
If you want to disable an ESLint rule in a file or on a specific line, you can add a comment. On a single line: const message = 'foo'; console. log(message); // eslint-disable-line no-console // eslint-disable-next-line no-console console.
To temporarily turn off ESLint, you should add a block comment /* eslint-disable */ before the lines that you're interested in: /* eslint-disable */ console.
Just use pair of lines:
/* eslint-disable no-unused-vars */ // ... your code here with unused vars... /* eslint-enable no-unused-vars */
Alternatively, you can disable the rule for one line:
// Based on your Typescript example export type Hey = { // eslint-disable-line no-unused-vars a: string, b: object }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With