eslint-plugin-no-unused
TypeScript icon, indicating that this package has built-in type declarations

0.0.14 • Public • Published

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.

Package Sidebar

Install

npm i eslint-plugin-no-unused

Weekly Downloads

0

Version

0.0.14

License

ISC

Unpacked Size

8.93 kB

Total Files

11

Last publish

Collaborators

  • andykog