New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@line/ts-remove-unused

Package Overview
Dependencies
Maintainers
0
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@line/ts-remove-unused - npm Package Compare versions

Comparing version 0.2.0 to 0.3.0

dist/cli.d.ts

19

package.json
{
"name": "@line/ts-remove-unused",
"version": "0.2.0",
"description": "Remove unused code from your TypeScript project",

@@ -11,12 +10,16 @@ "type": "module",

"license": "Apache-2.0",
"bin": "dist/index.js",
"bin": "dist/cli.js",
"files": [
"dist"
],
"exports": {
".": "./dist/main.js"
},
"types": "./dist/main.d.ts",
"scripts": {
"lint": "eslint . --ext .ts,.cjs,.js",
"build": "rm -rf dist && tsc --outDir dist",
"type-check": "tsc --noEmit",
"build": "rm -rf dist && node ./build.js",
"type-check": "tsc -b",
"prepublishOnly": "npm run build",
"test": "glob -c 'node --loader ts-node/esm --test' 'src/**/*.test.ts'"
"test": "TS_NODE_PROJECT=tsconfig.test.json glob -c 'node --loader ts-node/esm --test' 'lib/**/*.test.ts' 'test/**/*.test.ts'"
},

@@ -27,2 +30,3 @@ "devDependencies": {

"@typescript-eslint/parser": "^6.4.1",
"esbuild": "^0.23.1",
"eslint": "^8.48.0",

@@ -37,7 +41,8 @@ "eslint-config-prettier": "^9.0.0",

"cac": "^6.7.14",
"ts-morph": "^17.0.1"
"chalk": "^5.3.0"
},
"peerDependencies": {
"typescript": ">=4.0.0"
}
},
"version": "0.3.0"
}

@@ -16,3 +16,3 @@ # ts-remove-unused

Usage:
$ ts-remove-unused
$ ts-remove-unused

@@ -26,8 +26,8 @@ Commands:

Options:
--project <file> Path to your tsconfig.json
--skip <regexp_pattern> Specify the regexp pattern to match files that should be skipped from transforming
--include-d-ts Include .d.ts files in target for transformation
-h, --help Display this message
-v, --version Display version number
--project <file> Path to your tsconfig.json
--skip <regexp_pattern> Specify the regexp pattern to match files that should be skipped from transforming
--include-d-ts Include .d.ts files in target for transformation
--check Check if there are any unused exports without removing them
-h, --help Display this message
-v, --version Display version number
```

@@ -40,5 +40,29 @@

```
ts-remove-unused --skip 'src\/index\.ts'
npx ts-remove-unused --skip 'src\/index\.ts'
```
### Check
Use `--check` to check for unused files and exports without making changes to project files. The command will exit with
code: 1 if there are any unused files or exports discovered.
```
npx ts-remove-unused --check
```
### Use the JavaScript API
Alternatively, you can use the JavaScript API to execute ts-remove-unused.
```typescript
import { remove } from '@line/ts-remove-unused';
remove({
configPath: '/path/to/project/tsconfig.json',
projectRoot: '/path/to/project',
skip: [/main.ts/],
mode: 'write',
});
```
### Skip removing unused exports

@@ -55,14 +79,2 @@

## Known Issue
Since this CLI uses TypeScript's transformer API, it can't preserve the original format of the file. Although most of the format change can be restored using linters like prettier, empty lines will be omitted. Here's a workaround for this issue using git.
```bash
npx ts-remove-unused ## execute the cli
npx prettier --write . ## fix the format
git add .
git commit ## commit first
git checkout HEAD~1 -- . && git diff HEAD~1 HEAD --ignore-blank-lines | git apply && git reset ## this will try to restore irrelevant changes of empty lines caused by the first commit
```
## License

@@ -69,0 +81,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc