{"_id":"@chrp/ts-unused-exports","_rev":"2-1e5b030dfdf373744944de07cb4126ee","name":"@chrp/ts-unused-exports","dist-tags":{"latest":"11.1.1"},"versions":{"11.1.0":{"name":"@chrp/ts-unused-exports","version":"11.1.0","keywords":["typescript","tslint","unused exports","dead code"],"author":{"name":"Patricio Zavolinsky"},"license":"MIT","_id":"@chrp/ts-unused-exports@11.1.0","maintainers":[{"name":"churpeau","email":"christophe@hurpeau.com"}],"homepage":"https://github.com/pzavolinsky/ts-unused-exports","bugs":{"url":"https://github.com/pzavolinsky/ts-unused-exports/issues"},"bin":{"ts-unused-exports":"bin/ts-unused-exports"},"dist":{"shasum":"9b72ef8dd0f2ac569631b43690d86a646287e9cb","tarball":"https://registry.npmjs.org/@chrp/ts-unused-exports/-/ts-unused-exports-11.1.0.tgz","fileCount":52,"integrity":"sha512-zeAcR3VxIaopf5FnQp2cwqRICCgcEaMTtuZF3HvoV8kywNDp11/q9WAxy3DD53YhShVAcsR769OX6vMzarXw3Q==","signatures":[{"sig":"MEYCIQCL0QosoZVH+OI1skkrSsXEQQtCuEckX5EX/9y7YPu15AIhAJ2L0gI3QyaO9zPYNAeNcevCuKdz+F52NV9X46uDNDcI","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":140433},"main":"lib/app.js","types":"./lib/app.d.ts","funding":"https://github.com/pzavolinsky/ts-unused-exports?sponsor=1","gitHead":"a7593e9959e19dd24b4fadbeae7039e44d6633a3","scripts":{"bump":"npm version patch","exec":"bin/ts-unused-exports","lint":"eslint --ext .ts src","pack":"docker build -t ts-unused-exports . && docker run -v $PWD/lib:/usr/src/lib ts-unused-exports","test":"npm run lint && npm run build && npm run test:cc && npm run test:itest","build":"tsc","watch":"tsc -w","test:cc":"nyc npm run test:unit:raw","lint:fix":"eslint --ext .ts src --fix","test:unit":"VERBOSE=1 npm run test:unit:raw","prepublish":"npm test","test:itest":"cd ispec && bash ./run.sh","test:unit:raw":"TS_NODE_FILES=true cucumber-js --require-module ts-node/register --exit -r src/test.ts --tags 'not @ignore'","test:unit:only":"TS_NODE_FILES=true cucumber-js --require-module ts-node/register --exit -r src/test.ts --tags '@only'","report-coverage-to-coveralls":"cat ./coverage/lcov.info | coveralls"},"_npmUser":{"name":"churpeau","email":"christophe@hurpeau.com"},"repository":{"url":"git+https://github.com/pzavolinsky/ts-unused-exports.git","type":"git"},"_npmVersion":"10.9.2","description":"ts-unused-exports finds unused exported symbols in your Typescript project","directories":{},"_nodeVersion":"22.14.0","dependencies":{"chalk":"^4.0.0","tsconfig-paths":"^3.9.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"packageManager":"yarn@1.22.21+sha1.1959a18351b811cdeedbd484a8f86c3cc3bbaf72","devDependencies":{"nyc":"^15.0.0","eslint":"^7.0.0","codecov":"^3.6.5","ts-node":"^9.0.0","prettier":"^2.0.0","coveralls":"^3.0.11","typescript":"^4.0.0","@types/node":"^14.0.0","pickled-cucumber":"^2.0.14","eslint-config-prettier":"^8.0.0","eslint-plugin-prettier":"^3.1.2","@typescript-eslint/parser":"^4.0.0","@typescript-eslint/eslint-plugin":"^4.0.0","@istanbuljs/nyc-config-typescript":"^1.0.1"},"peerDependencies":{"typescript":">=3.8.3"},"peerDependenciesMeta":{"typescript":{"optional":false}},"_npmOperationalInternal":{"tmp":"tmp/ts-unused-exports_11.1.0_1744200538606_0.8341853273947304","host":"s3://npm-registry-packages-npm-production"}},"11.1.1":{"name":"@chrp/ts-unused-exports","version":"11.1.1","description":"ts-unused-exports finds unused exported symbols in your Typescript project","main":"lib/app.js","publishConfig":{"access":"public"},"repository":{"type":"git","url":"git+https://github.com/christophehurpeau/ts-unused-exports.git"},"funding":"https://github.com/christophehurpeau/ts-unused-exports?sponsor=1","keywords":["typescript","tslint","unused exports","dead code"],"author":{"name":"Patricio Zavolinsky"},"license":"MIT","bugs":{"url":"https://github.com/christophehurpeau/ts-unused-exports/issues"},"homepage":"https://github.com/christophehurpeau/ts-unused-exports","scripts":{"bump":"npm version patch","build":"tsc","exec":"bin/ts-unused-exports","lint:fix":"eslint --ext .ts src --fix","lint":"eslint --ext .ts src","pack":"docker build -t ts-unused-exports . && docker run -v $PWD/lib:/usr/src/lib ts-unused-exports","prepublish":"npm test","report-coverage-to-coveralls":"cat ./coverage/lcov.info | coveralls","test:cc":"nyc npm run test:unit:raw","test:itest":"cd ispec && bash ./run.sh","test:unit:only":"TS_NODE_FILES=true cucumber-js --require-module ts-node/register --exit -r src/test.ts --tags '@only'","test:unit:raw":"TS_NODE_FILES=true cucumber-js --require-module ts-node/register --exit -r src/test.ts --tags 'not @ignore'","test:unit":"VERBOSE=1 npm run test:unit:raw","test":"npm run lint && npm run build && npm run test:cc && npm run test:itest","watch":"tsc -w"},"bin":{"ts-unused-exports":"bin/ts-unused-exports"},"devDependencies":{"@istanbuljs/nyc-config-typescript":"^1.0.1","@types/node":"^14.0.0","@typescript-eslint/eslint-plugin":"^4.0.0","@typescript-eslint/parser":"^4.0.0","codecov":"^3.6.5","coveralls":"^3.0.11","eslint":"^7.0.0","eslint-config-prettier":"^8.0.0","eslint-plugin-prettier":"^3.1.2","nyc":"^15.0.0","pickled-cucumber":"^2.0.14","prettier":"^2.0.0","ts-node":"^9.0.0","typescript":"^4.0.0"},"dependencies":{"chalk":"^4.0.0","tsconfig-paths":"^3.9.0"},"peerDependencies":{"typescript":">=3.8.3"},"peerDependenciesMeta":{"typescript":{"optional":false}},"_id":"@chrp/ts-unused-exports@11.1.1","gitHead":"d4cf030b37238c904b6293217e0b2c7c4f3e9ca7","types":"./lib/app.d.ts","_nodeVersion":"22.14.0","_npmVersion":"10.9.2","dist":{"integrity":"sha512-nvBNvakaS0nuwXkQmZqoDAVy9lu97ulQkCJsUlnYQ0HuWiT+guVVvs+n9cliqlt5ShAYgOW7Cjx0mZfz2qTwRg==","shasum":"142a4e61905fd1fc3029cc9db213f744a4e90c7c","tarball":"https://registry.npmjs.org/@chrp/ts-unused-exports/-/ts-unused-exports-11.1.1.tgz","fileCount":52,"unpackedSize":140512,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQCpgh6zepNMrgP5DCVcvzIRsz/NPD4dgb6JX63KOucoMQIgcZ/H2XvuJwjaaDZDHLYao4zAhizQsAWqRF43acXcWlk="}]},"_npmUser":{"name":"churpeau","email":"christophe@hurpeau.com"},"directories":{},"maintainers":[{"name":"churpeau","email":"christophe@hurpeau.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/ts-unused-exports_11.1.1_1744200866548_0.8100801989528779"},"_hasShrinkwrap":false}},"time":{"created":"2025-04-09T12:08:58.495Z","modified":"2025-04-09T12:14:27.010Z","11.1.0":"2025-04-09T12:08:58.790Z","11.1.1":"2025-04-09T12:14:26.827Z"},"bugs":{"url":"https://github.com/christophehurpeau/ts-unused-exports/issues"},"author":{"name":"Patricio Zavolinsky"},"license":"MIT","homepage":"https://github.com/christophehurpeau/ts-unused-exports","keywords":["typescript","tslint","unused exports","dead code"],"repository":{"type":"git","url":"git+https://github.com/christophehurpeau/ts-unused-exports.git"},"description":"ts-unused-exports finds unused exported symbols in your Typescript project","maintainers":[{"name":"churpeau","email":"christophe@hurpeau.com"}],"readme":"# ts-unused-exports\n\n> This is a fork of original lib with https://github.com/pzavolinsky/ts-unused-exports/issues/316 but added as a feature not an option.\n\n`ts-unused-exports` finds unused exported symbols in your Typescript project.\n\n[![Build Status](https://github.com/pzavolinsky/ts-unused-exports/actions/workflows/node.js.yml/badge.svg?branch=master)](https://github.com/pzavolinsky/ts-unused-exports/actions/workflows/node.js.yml?query=branch%3Amaster)\n[![Coveralls](https://img.shields.io/coveralls/pzavolinsky/ts-unused-exports.svg)](https://coveralls.io/github/pzavolinsky/ts-unused-exports)\n\n[![npm Package](https://img.shields.io/npm/v/ts-unused-exports.svg?style=flat-square)](https://www.npmjs.org/package/ts-unused-exports)\n[![NPM Downloads](https://img.shields.io/npm/dm/ts-unused-exports.svg)](https://npmjs.org/package/ts-unused-exports)\n\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\n[![ko-fi](https://ko-fi.com/img/githubbutton_sm.svg)](https://ko-fi.com/Z8Z13CHUI)\n\n## Installation\n\n```\nnpm install --save-dev ts-unused-exports\n```\n\nor, to install globally:\n\n```\nnpm install -g ts-unused-exports\n```\n\n## Usage\n\n```shell\n./node_modules/.bin/ts-unused-exports path/to/tsconfig.json [file1.ts ...] [options]\n```\n\nor, if installed globally:\n\n```shell\nts-unused-exports path/to/tsconfig.json [file1.ts ...] [options]\n```\n\n## Usage Options\n\n| Option name                | Description                                                                                                                                                                                                                                                                                                                                            | Example                               |\n| -------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------- |\n| `allowUnusedEnums`         | Allow unused `enum`s.                                                                                                                                                                                                                                                                                                                                  | `--allowUnusedEnums`                  |\n| `allowUnusedTypes`         | Allow unused `type` or `interface`.                                                                                                                                                                                                                                                                                                                    | `--allowUnusedTypes`                  |\n| `excludeDeclarationFiles`  | Exclude `.d.ts` files when looking for unused exports.                                                                                                                                                                                                                                                                                                 | `--excludeDeclarationFiles`           |\n| `excludePathsFromReport`   | Exclude files from the _output_ that match the given path segments or regex. The path segments or regexes are separated with a semi-colon.                                                                                                                                                                                                                                                                          | `--excludePathsFromReport=math;utils` |\n| `exitWithCount`            | Set the process exit code to be the count of files that have unused exports.                                                                                                                                                                                                                                                                           | `--exitWithCount`                     |\n| `exitWithUnusedTypesCount` | Set the process exit code to be the total count of unused exported types.                                                                                                                                                                                                                                                                              | `--exitWithUnusedTypesCount`          |\n| `findCompletelyUnusedFiles`                   | Find all *completely* unused files (where *all* exports are unused).                                                                                                                                                                                                                                                                                                                      | `--findCompletelyUnusedFiles`                            |\n| `ignoreFiles`              | Ignore files with filenames that match the given regex. Use this to exclude groups of files - for example test files and their utilities.                                                                                                                                                                                                              | `--ignoreFiles=.*spec`                |\n| `ignoreLocallyUsed`        | Exports which are used in the same file they are defined in won't be reported as unused. Note that this may have an impact on performance in larger codebases.  | `--ignoreLocallyUsed`                 |\n| `ignoreProductionFiles`    | Only scan **test** files (so ignore non-test 'production' files).                                                                                                                                                                                                                                                                                      | `--ignoreProductionFiles`             |\n| `ignoreTestFiles`          | Only scan **production** files (ignore all test files, like `spec.ts(x)` or `test.ts(x)` or `TestUtils.ts`). Use this to detect production code that is only used in tests (so is dead code). Note: this will NOT detect unused exports in test code - for that, you can run `ts-unused-exports` separately with the `--ignoreProductionFiles` option. | `--ignoreTestFiles`                   |\n| `maxIssues`                | Return successfully for up to a given number of modules with unused exports.                                                                                                                                                                                                                                                                           | `--maxIssues=7`                       |\n| `searchNamespaces`         | Enable searching for unused exports within namespaces. Note: this can affect performance on large codebases.                                                                                                                                                                                                                                           | `--searchNamespaces`                  |\n| `showLineNumber`           | Show the line number and column of the unused export.                                                                                                                                                                                                                                                                                                  | `--showLineNumber`                    |\n| `silent`                   | Don't write on stdout on success.                                                                                                                                                                                                                                                                                                                      | `--silent`                            |\n\nNote that if `ts-unused-exports` is called without files, the files will be read from the tsconfig's `files` or `include` key which must be present. If called with files, then those file paths should be relative to the `tsconfig.json`, just like you would specify them in your tsconfig's `files` key.\n\n`ts-unused-exports` also resolves path aliases specified in tsconfig's `paths` object.\n\nAs of version 7.0.0 the TypeScript compiler is a _peer dependency_ of `ts-unused-exports`. This means that if the TypeScript compiler is not already in the same spot as `ts-unused-exports`, you have to install it yourself (e.g. with `npm i -D typescript`).\n\n\n### Usage as a library\n\n#### Usage as a library - From TypeScript (was built with ES5 + commonjs)\n\n```ts\nimport { analyzeTsConfig } from 'ts-unused-exports';\nconst result = analyzeTsConfig('path/to/tsconfig.json');\n// or const result = analyzeTsConfig('path/to/tsconfig.json', ['file1.ts']);\n// or const result = analyzeTsConfig('path/to/tsconfig.json', ['file1.ts', '--excludePathsFromReport=math']);\n\n// result : { [index:string] : ExportNameAndLocation[] }\n// where the keys are file paths and the values are a structure descibing unused symbols:\n// interface ExportNameAndLocation {\n//   exportName: string;\n//   location: LocationInFile;\n// }\n```\n\nFor an example see `./example/library-usage-via-TypeScript/`.\n\n#### Usage as a library - From JavaScript\n\nFrom JavaScript - depending on your environment, you may need to navigate to reach the analyzeTsConfig() function.\n\n```js\nimport { analyzeTsConfig } from \"ts-unused-exports\";\nconst result = analyzeTsConfig.default('path/to/tsconfig.json');\n```\n\nFor an example see `./example/library-usage-via-JavaScript/`.\n\n## Why should I use this?\n\nIf you've ever used `tslint`'s [no-unused-variable](http://palantir.github.io/tslint/rules/no-unused-variable/) rule you already known how awesome it is. What this rule does is detect code in your modules that is not being used so that you can remove it.\n\nFor example, say that you refactored your `math.ts` module so that you no longer use `add1`:\n\n```ts\nfunction add1(x: number) {\n  return x + 1;\n} // warning here\n\nexport default (x: number) => x + 1;\n```\n\nWhen run, `tslint` will complain that `add1` is no longer in use.\n\nUnfortunately, if your symbols are exported, `tslint` does not complain anymore. Effectively `export`ing a symbol anchors the symbol so that, even if nobody uses it, it will not be marked as dead code.\n\nIf you've ever found yourself mid-refactor fixing a particularly fiendish function only to realize later that nobody really uses it you know exactly what I mean.\n\n`ts-unused-exports` fills this cross-module gap by complaining about exported symbols that no-one cares about.\n\nIn this sense, `ts-unused-exports` does not replace `tslint` but rather complements it by helping you detect unnecessary exports. Once those are fixed, `tslint`'s `no-unused-variable` rule will kick in and tell you which code you can safely remove.\n\n## Example\n\nThere is a (very silly) example in the [example/simple](https://github.com/pzavolinsky/ts-unused-exports/blob/master/example/simple) directory.\n\nIf you want to run it you can:\n\n```shell\ngit clone https://github.com/pzavolinsky/ts-unused-exports\ncd ts-unused-exports\n./bin/ts-unused-exports example/simple/tsconfig.json\n# or: node ./bin/ts-unused-exports example/simple/tsconfig.json\n# or: node bin\\ts-unused-exports example\\simple\\tsconfig.json\n```\n\nThe output should be:\n\n```\n2 modules with unused exports\n/home/stuff/src/github/ts-unused-exports/example/simple/math.ts: add1\n/home/stuff/src/github/ts-unused-exports/example/simple/unused.ts: unused\n```\n\n## Exit Code\n\nNormally, the exit code follows the convention used by [eslint](https://eslint.org/docs/user-guide/command-line-interface):\n\n- 0 = Linting was successful and there are no linting errors.\n- 1 = Linting was successful and there is at least one linting error.\n- 2 = Linting was unsuccessful due to bad arguments or an internal error.\n\nIf the option `--maxIssues=n` is used, then linting is considered successful, if at most n issues are found.\n\nIf the option `--exitWithCount` is used, then the exit status will equal the number of offending modules:\n\n```shell\necho $?\n# or: echo %ERRORLEVEL%\n2\n```\n\nSimilarly, the option `--exitWithUnusedTypesCount` means that the exit status will equal the number of offending types.\n\n## Specifying which TypeScript files to check\n\nIf not using `files` or `include` inside your `tsconfig` (e.g. using `webpack` with `ts-loader`), you can explicitly specify the files to check in the command line:\n\n```shell\n./bin/ts-unused-exports example/simple/tsconfig.json app.ts math.ts\n```\n\nor, in a more generic way:\n\n```shell\n./bin/ts-unused-exports example/simple/tsconfig.json $(cd example/simple; find -name '*.ts')\n```\n\nYou can use comment flags to ignore exports:\n\n```ts\n// ts-unused-exports:disable-next-line\nexport function add2(x: number) {\n  return x + 2;\n}\n```\n\n## Tooling\n\n### eslint plugins\n\n`ts-unused-exports` can also be executed via this [eslint plugin](https://github.com/gajus/eslint-plugin-canonical#no-unused-exports) by Gajus Kuizinas.\n\n## Changelog (Release History)\n\nTo see what has changed in each version, please see our [CHANGELOG.md](https://github.com/pzavolinsky/ts-unused-exports/blob/master/CHANGELOG.md).\n\n## Contributing\n\n`ts-unused-exports` is maintained by volunteers, working in their free time. If you'd like to help out, please see [CONTRIBUTING.md](https://github.com/pzavolinsky/ts-unused-exports/blob/master/CONTRIBUTING.md).\n\n`ts-unused-exports` was created by Patricio Zavolinsky. Improvements were contributed by the [open source\ncommunity](https://github.com/pzavolinsky/ts-unused-exports/graphs/contributors).\n\n## Licence: MIT\n\nThis project is licensed under the MIT License - see the [LICENSE](./LICENSE) file for details\n","readmeFilename":"README.md"}