import { Bar } from './Bar';
import { Baz } from './Baz';
import { Foo } from './Foo';
console.log(Foo, Bar, /* Baz */);
with tslint.json configuration:
{
"defaultSeverity": "error",
"extends": [],
"jsRules": {},
"rules": {
"no-unused-variable": true
},
"rulesDirectory": []
}
Command line:
tslint -p ./tsconfig.json -c ./tslint.json --fix
ERROR: C:/Workspaces/VSC/tslint-no-unused-variable/index.ts[2, 1]: 'Baz' is declared but its value is never read.
Import for Baz removed in source file, as suggested here: https://palantir.github.io/tslint/rules/no-unused-variable/
In addition to avoiding compilation errors, this rule may still be useful if you wish to have tslint automatically remove unused imports, ... when using TSLint鈥檚 --fix option.
would love this to avoid removing around 90 instances manually :D
I was experiencing the same issue in one of my projects, but it works for me after upgrading tslint:
typescript: 2.9.2
tslint: 5.9.1 (does not work), 5.10.0 (works), 5.11.0 (also works)
This should work now with the latest TSLint and TypeScript. 馃帀
Most helpful comment
would love this to avoid removing around 90 instances manually :D