Security News
The Risks of Misguided Research in Supply Chain Security
Snyk's use of malicious npm packages for research raises ethical concerns, highlighting risks in public deployment, data exfiltration, and unauthorized testing.
@line/ts-remove-unused
Advanced tools
Remove unused code from your TypeScript project
npm i typescript ## TypeScript is a peer dependency
npm i -D @line/ts-remove-unused
Usage:
$ ts-remove-unused
Commands:
There are no subcommands. Simply execute ts-remove-unused
For more info, run any command with the `--help` flag:
$ ts-remove-unused --help
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
--check Check if there are any unused exports without removing them
-h, --help Display this message
-v, --version Display version number
The CLI will respect the tsconfig.json
for loading source files.
Here's an example of using the cli.
npx ts-remove-unused --skip 'src\/index\.ts'
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
Alternatively, you can use the JavaScript API to execute ts-remove-unused.
import { remove } from '@line/ts-remove-unused';
remove({
configPath: '/path/to/project/tsconfig.json',
projectRoot: '/path/to/project',
skip: [/main.ts/],
mode: 'write',
});
When you add a comment // ts-remove-unused-skip
to your export declaration, the CLI will skip it from being removed
// ts-remove-unused-skip
export const hello = 'world';
By default, .d.ts files are skipped. If you want to include .d.ts files, use the --include-d-ts option.
Copyright (C) 2023 LINE Corp.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
FAQs
Remove unused code from your TypeScript project
The npm package @line/ts-remove-unused receives a total of 1,183 weekly downloads. As such, @line/ts-remove-unused popularity was classified as popular.
We found that @line/ts-remove-unused demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Snyk's use of malicious npm packages for research raises ethical concerns, highlighting risks in public deployment, data exfiltration, and unauthorized testing.
Research
Security News
Socket researchers found several malicious npm packages typosquatting Chalk and Chokidar, targeting Node.js developers with kill switches and data theft.
Security News
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.