0.0.25 • Published 1 year ago

no-unused v0.0.25

Weekly downloads
-
License
ISC
Repository
github
Last release
1 year ago

no-unused

experimental, early stage of development

Finds unused properties in code utilizing TypeScript type system.

Usage

npx no-unused src/**/*.ts
Arguments:
  pattern                        pattern for source files (omit to find automatically)

Options:
  -V, --version                  output the version number
  -i, --ignore [pattern]         pattern for ignored files (default: "**/*.@(spec|test).*")
  -I, --ignoreExports [pattern]  pattern for files where exports are ignored
  -p, --project [string]         path to tsconfig.json (omit to resolve automatically)
  -e, --errors                   emit tsc errors
  -h, --help                     display help for command

Note: files matched with --ignore won't be analyzed. Files containing .spec. or .test. are ignored by default to also find identifiers that are used only in tests.

Example

Source file:

const data = {name: 'John', surname: 'Smith'};

type Params = {a?: number; wat?: string};

const selector = ({a}: Params) => [a, data.name];

selector({});

Output:

src/example.ts:1:29 - message TS0: Unused identifier

1 const data = {name: 'John', surname: 'Smith'};
                              ~~~~~~~
src/example.ts:3:28 - message TS0: Unused identifier

3 type Params = {a?: number; wat?: string};
                             ~~~

Total: 2 unused identifiers

Ignoring unused app entrypoints

App entrypoints appear unused because they are meant to be used by external code. To ignore them:

Option 1

Use --ignoreExports entrypointsPattern

npx no-unused src/**/*.ts --ignoreExports 'src/entrypoint.ts,src/otherEntrypoints/*.ts'

Option 2

Add /** @public */ comment for exports used by external code:

/** @public */
export const renderApp = () => {...};

/** @public */
export const appConfig = {...};

Eslint plugin

See eslint-plugin-no-unused

0.0.25

1 year ago

0.0.24

1 year ago

0.0.23

1 year ago

0.0.22

1 year ago

0.0.21

1 year ago

0.0.20

1 year ago

0.0.19

1 year ago

0.0.18

1 year ago

0.0.17

1 year ago

0.0.16

1 year ago

0.0.15

1 year ago

0.0.14

1 year ago

0.0.13

1 year ago

0.0.12

1 year ago

0.0.11

1 year ago

0.0.10

1 year ago

0.0.9

1 year ago

0.0.8

1 year ago

0.0.7

1 year ago

0.0.6

1 year ago

0.0.5

1 year ago

0.0.4

1 year ago

0.0.3

1 year ago

0.0.2

1 year ago

0.0.1

1 year ago