I\'m using tslint, and got the error.
\'myVariable\' is declared but its value is never read.
I went to the website that documents the rules
First turn off noUnusedLocals
in tsconfig.json:
{
"compilerOptions": {
"noUnusedLocals": false,
}
}
Then fix eslint rules in .eslintrc.js
:
module.exports = {
rules: {
'no-unused-vars': ['warn', { 'varsIgnorePattern': '^_' }],
'@typescript-eslint/no-unused-vars': ['warn', { 'varsIgnorePattern': '^_' }],
},
};
And If using @typescript-eslint/naming-convention
rule should add leadingUnderscore: 'allow'
, For example, if you are using Airbnb config:
'@typescript-eslint/naming-convention': [
'error',
{
selector: 'variable',
format: ['camelCase', 'PascalCase', 'UPPER_CASE'],
leadingUnderscore: 'allow',
},
{
selector: 'function',
format: ['camelCase', 'PascalCase'],
},
{
selector: 'typeLike',
format: ['PascalCase'],
},
],