"Dead code" refers to parts of a codebase that are written but never executed, called, imported, or otherwise needed during the normal operation of the application. Cleaning up unused code improves clarity, performance, and long-term maintainability."Dead code" refers to parts of a codebase that are written but never executed, called, imported, or otherwise needed during the normal operation of the application. Cleaning up unused code improves clarity, performance, and long-term maintainability.

Everything You Need to Know About Dead Code

What Is "Dead Code"?

Dead code refers to parts of a codebase that are written but never executed, called, imported, or otherwise needed during the normal operation of the application.

Over time, as features are added, changed, or removed, some code becomes obsolete but is accidentally left behind. This can lead to:

  • Increased bundle size
  • Slower build times
  • Harder maintenance and onboarding
  • Potential security risks

Cleaning up unused code improves clarity, performance, and long-term maintainability.

What Is Considered "Dead Code"?

Here are the common categories of unused code:

  1. Unused Variables

    Declared but never used in any operation.

  2. Unused Functions or Methods

    Defined but never called anywhere.

  3. Unused Imports

    Imported modules or packages that are never referenced.

  4. Unused Exports

    Functions or components exported from a module but not imported elsewhere.

  5. Unused Files

    Complete files (components, modules, etc.) that are never imported or required.

  6. Unused Dependencies

    Libraries listed in your package manager (e.g., package.json) that are not imported or used in the codebase.

Some exceptions:

  • Disabled Features

    Features that are temporarily disabled or taken out, but will be used in the future.

  • Helper functions

    Utility functions that help with common tasks can be reviewed regularly to check if it needs to be removed.

Tools for Scanning Dead Code

The following tools help detect and analyze unused code, imports, functions, variables, and dependencies. Choose tools based on your tech stack:

  • ts-prune
  • Detects unused exported functions, constants, and types in TypeScript projects.
  • On Maintenance (no further update)
  • depcheck
  • Checks for unused npm dependencies and missing ones.
  • knip.dev (We are using this!)
  • Knip finds and fixes unused dependencies, exports and files in your JavaScript and TypeScript projects. Less code and dependencies lead to improved performance, less maintenance and easier refactorings.

How to Scan and Remove Unused Code with knip

Follow these steps to identify and safely remove unused code from your project using knip:

  1. Install knip (if not already installed):
   yarn add -D knip    # or    npm install -D knip 
  1. Run the analysis:
   yarn knip 

Note: Replace yarn with your preferred package manager (npm, pnpm, etc.).

\

  1. Review the list of unused files or exports:

  2. Go through the list from top-down, starting with high-level components, constants, and utilities.

  3. Search your codebase to verify whether each flagged file or export is truly unused.

    • If it's used elsewhere, skip it.
    • If it has no references, it’s safe to delete.

  4. Remove confirmed dead code

  5. Delete unused files, exports, or lines confidently after reviewing

    • Check with your teammates if the components/files is not used anymore or just temporarily not used

    • Validate your codebase:

    • Run linters and TypeScript checks to catch any issues:

        yarn lint   npx tsc --noEmit 
    • Start the development server to confirm everything still works:

        yarn dev 
    • Final step: Commit your changes with a clear message, e.g.:

   git commit -m "chore: remove unused code and dependencies" 

Getting rid of dead code might feel like a chore, but it’s totally worth it. Cleaner code means fewer headaches, faster builds, and easier debugging down the line. With the right tools and a step-by-step approach, it’s not that hard to keep your codebase in shape. If you’re working in a fast-paced company where keeping track of all the new code is challenging, making this part of your regular workflow is a must.

If you have any other better approach or just want to share your own process, feel free to share in the comment! I would love to hear your thought!

Disclaimer: The articles reposted on this site are sourced from public platforms and are provided for informational purposes only. They do not necessarily reflect the views of MEXC. All rights remain with the original authors. If you believe any content infringes on third-party rights, please contact service@support.mexc.com for removal. MEXC makes no guarantees regarding the accuracy, completeness, or timeliness of the content and is not responsible for any actions taken based on the information provided. The content does not constitute financial, legal, or other professional advice, nor should it be considered a recommendation or endorsement by MEXC.

You May Also Like

Whales keep selling XRP despite ETF success — Data signals deeper weakness

Whales keep selling XRP despite ETF success — Data signals deeper weakness

The post Whales keep selling XRP despite ETF success — Data signals deeper weakness appeared on BitcoinEthereumNews.com. XRP ETFs have crossed $1 billion in assets
Share
BitcoinEthereumNews2025/12/20 02:55
Top Solana Treasury Firm Forward Industries Unveils $4 Billion Capital Raise To Buy More SOL ⋆ ZyCrypto

Top Solana Treasury Firm Forward Industries Unveils $4 Billion Capital Raise To Buy More SOL ⋆ ZyCrypto

The post Top Solana Treasury Firm Forward Industries Unveils $4 Billion Capital Raise To Buy More SOL ⋆ ZyCrypto appeared on BitcoinEthereumNews.com. Advertisement &nbsp &nbsp Forward Industries, the largest publicly traded Solana treasury company, has filed a $4 billion at-the-market (ATM) equity offering program with the U.S. SEC  to raise more capital for additional SOL accumulation. Forward Strategies Doubles Down On Solana Strategy In a Wednesday press release, Forward Industries revealed that the 4 billion ATM equity offering program will allow the company to issue and sell common stock via Cantor Fitzgerald under a sales agreement dated Sept. 16, 2025. Forward said proceeds will go toward “general corporate purposes,” including the pursuit of its Solana balance sheet and purchases of income-generating assets. The sales of the shares are covered by an automatic shelf registration statement filed with the US Securities and Exchange Commission that is already effective – meaning the shares will be tradable once they’re sold. An automatic shelf registration allows certain publicly listed companies to raise capital with flexibility swiftly.  Kyle Samani, Forward’s chairman, astutely described the ATM offering as “a flexible and efficient mechanism” to raise and deploy capital for the company’s Solana strategy and bolster its balance sheet.  Advertisement &nbsp Though the maximum amount is listed as $4 billion, the firm indicated that sales may or may not occur depending on existing market conditions. “The ATM Program enhances our ability to continue scaling that position, strengthen our balance sheet, and pursue growth initiatives in alignment with our long-term vision,” Samani said. Forward Industries kicked off its Solana treasury strategy on Sept. 8. The Wednesday S-3 form follows Forward’s $1.65 billion private investment in public equity that closed last week, led by crypto heavyweights like Galaxy Digital, Jump Crypto, and Multicoin Capital. The company started deploying that capital this week, announcing it snatched up 6.8 million SOL for approximately $1.58 billion at an average price of $232…
Share
BitcoinEthereumNews2025/09/18 03:42
Cryptos Signal Divergence Ahead of Fed Rate Decision

Cryptos Signal Divergence Ahead of Fed Rate Decision

The post Cryptos Signal Divergence Ahead of Fed Rate Decision appeared on BitcoinEthereumNews.com. Crypto assets send conflicting signals ahead of the Federal Reserve’s September rate decision. On-chain data reveals a clear decrease in Bitcoin and Ethereum flowing into centralized exchanges, but a sharp increase in altcoin inflows. The findings come from a Tuesday report by CryptoQuant, an on-chain data platform. The firm’s data shows a stark divergence in coin volume, which has been observed in movements onto centralized exchanges over the past few weeks. Bitcoin and Ethereum Inflows Drop to Multi-Month Lows Sponsored Sponsored Bitcoin has seen a dramatic drop in exchange inflows, with the 7-day moving average plummeting to 25,000 BTC, its lowest level in over a year. The average deposit per transaction has fallen to 0.57 BTC as of September. This suggests that smaller retail investors, rather than large-scale whales, are responsible for the recent cash-outs. Ethereum is showing a similar trend, with its daily exchange inflows decreasing to a two-month low. CryptoQuant reported that the 7-day moving average for ETH deposits on exchanges is around 783,000 ETH, the lowest in two months. Other Altcoins See Renewed Selling Pressure In contrast, other altcoin deposit activity on exchanges has surged. The number of altcoin deposit transactions on centralized exchanges was quite steady in May and June of this year, maintaining a 7-day moving average of about 20,000 to 30,000. Recently, however, that figure has jumped to 55,000 transactions. Altcoins: Exchange Inflow Transaction Count. Source: CryptoQuant CryptoQuant projects that altcoins, given their increased inflow activity, could face relatively higher selling pressure compared to BTC and ETH. Meanwhile, the balance of stablecoins on exchanges—a key indicator of potential buying pressure—has increased significantly. The report notes that the exchange USDT balance, around $273 million in April, grew to $379 million by August 31, marking a new yearly high. CryptoQuant interprets this surge as a reflection of…
Share
BitcoinEthereumNews2025/09/18 01:01