If you want to silence the warning from ESLint, one way to do it is by disabling the rule in your configuration file such as .eslintrc.js
or .eslintrc.json
. Here's an example of how you can do it:
..
rules: {
'no-unused-vars': 'off',
'@typescript-eslint/no-unused-vars': 'off',
..
}
..
Alternatively, you could choose to disable the TypeScript warning instead, since the ESLint rule offers more flexibility. To disable it in TypeScript, adjust the compiler options in your tsconfig.json
like this:
..
"compilerOptions": {
"noUnusedLocals": false,
"noUnusedParameters": false,
..
}
..
You can also customize the ESLint rule further, for example by excluding identifiers starting with a _
. This can be done by modifying your .eslintrc.js
file as shown below:
..
rules: {
'no-unused-vars': 'off',
'@typescript-eslint/no-unused-vars':
['warn', {argsIgnorePattern: '^_', varsIgnorePattern: '^_'}],
..
}
It's worth noting that the base rule no-unused-vars
is advised to always be disabled according to the
@typescript-eslint/no-unused-vars
documentation. For a comprehensive list of options available for
@typescript-eslint/no-unused-vars
, refer to the
no-unused-vars
documentation, as they share the same options.