Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Find unused files, dependencies and exports in your TypeScript and JavaScript projects
Knip is a tool for analyzing and managing unused files and dependencies in your JavaScript and TypeScript projects. It helps you keep your codebase clean and efficient by identifying and removing unnecessary code.
Identify Unused Files
This feature allows you to identify files in your project directory that are not being used. The code sample demonstrates how to use Knip to find unused files in the './src' directory.
const knip = require('knip');
knip.findUnusedFiles({
directory: './src'
}).then(unusedFiles => {
console.log('Unused files:', unusedFiles);
});
Identify Unused Dependencies
This feature helps you find dependencies listed in your package.json that are not being used in your project. The code sample shows how to use Knip to find unused dependencies in the current directory.
const knip = require('knip');
knip.findUnusedDependencies({
directory: './'
}).then(unusedDependencies => {
console.log('Unused dependencies:', unusedDependencies);
});
Remove Unused Files
This feature allows you to automatically remove files that are not being used in your project. The code sample demonstrates how to use Knip to remove unused files in the './src' directory.
const knip = require('knip');
knip.removeUnusedFiles({
directory: './src'
}).then(() => {
console.log('Unused files removed');
});
Remove Unused Dependencies
This feature helps you automatically remove dependencies that are not being used in your project. The code sample shows how to use Knip to remove unused dependencies in the current directory.
const knip = require('knip');
knip.removeUnusedDependencies({
directory: './'
}).then(() => {
console.log('Unused dependencies removed');
});
Depcheck is a tool that helps you find unused dependencies in your project. It analyzes your codebase to identify dependencies that are not being used. Compared to Knip, Depcheck focuses more on dependencies and does not provide functionality for identifying or removing unused files.
Unimported is a tool that helps you find and remove unused files and dependencies in your project. It provides similar functionality to Knip, including the ability to identify and remove unused files and dependencies. However, Unimported may have different configuration options and performance characteristics.
Madge is a tool for visualizing and analyzing the dependency graph of your project. It can help you identify circular dependencies and unused files. While Madge provides some overlapping functionality with Knip, it is more focused on visualizing dependencies and analyzing the structure of your codebase.
Knip finds unused files, dependencies and exports in your JavaScript and TypeScript projects. Less code and dependencies lead to improved performance, less maintenance and easier refactorings.
Special thanks to the wonderful people who have contributed to this project:
/'knɪp/ means "(to) cut" and is pronounced with a hard "K" 🇳🇱
FAQs
Find unused files, dependencies and exports in your TypeScript and JavaScript projects
The npm package knip receives a total of 578,740 weekly downloads. As such, knip popularity was classified as popular.
We found that knip demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer 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.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.