Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/andykog/eslint-plugin-no-unused
https://github.com/andykog/eslint-plugin-no-unused
Last synced: about 1 month ago
JSON representation
- Host: GitHub
- URL: https://github.com/andykog/eslint-plugin-no-unused
- Owner: andykog
- Created: 2022-11-20T19:51:57.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2022-11-26T13:25:20.000Z (about 2 years ago)
- Last Synced: 2024-11-16T02:40:00.470Z (about 2 months ago)
- Language: TypeScript
- Size: 183 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# eslint-plugin-no-unused
[experimental, in early stage of development]
Finds unused TypeScript code with [no-unused](https://www.npmjs.com/package/no-unused).
## Installation
Install `eslint-plugin-no-unused` & `@typescript-eslint/parser`:
```sh
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.
```json
{
"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:```json
{
"plugins": [
"no-unused"
]
}
```Then configure the rule under the rules section.
```json
{
"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](https://www.npmjs.com/package/no-unused).