eslint-plugin-no-unused
v0.0.14
Published
find unused properties
Downloads
37
Maintainers
Readme
eslint-plugin-no-unused
[experimental, in early stage of development]
Finds unused TypeScript code with no-unused.
Installation
Install eslint-plugin-no-unused
& @typescript-eslint/parser
:
npm install eslint-plugin-no-unused --save-dev
npm install @typescript-eslint/parser --save-dev
Usage
Make sure @typescript-eslint/parser
is configured in your .eslintrc
configuration file,
and has parserOptions.project
property.
{
"parser": "@typescript-eslint/parser",
"parserOptions": {
"project": "./tsconfig.json"
}
}
Add eslint-plugin-no-unused
to the plugins section of your .eslintrc
configuration file.
You can omit the eslint-plugin-
prefix:
{
"plugins": [
"no-unused"
]
}
Then configure the rule under the rules section.
{
"rules": {
"no-unused/no-unused": ["warn", {
"ignore": "**/*.spec.ts",
"ignoreExports": "src/entrypoint.ts,src/**/*.otherEntrypoints.ts"
}]
}
}
Options
ignore
(glob pattern) - pattern for ignored files. These files won't be analyzed. Hint: add**/*.spec.ts
then identifiers that are used only in tests will be marked as unused.ignoreExports
(glob pattern) - pattern for files where exports are considered used. Hint: add here entrypoints to your app as exports there are meant to be used by external code.
CLI tool
See no-unused.