Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/andykog/eslint-plugin-no-unused


https://github.com/andykog/eslint-plugin-no-unused

Last synced: about 1 month ago
JSON representation

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).