如何在大型反应项目中找到死代码? [英] How to find dead code in a large react project?

查看:129
本文介绍了如何在大型反应项目中找到死代码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为了重构客户端项目,我正在寻找一种安全的方法来查找(和删除)未使用的代码。

In order to refactor a client-side project, i'm looking for a safe way to find (and delete) unused code.

您使用哪些工具在大型反应项目中查找未使用/死代码?我们的产品已经开发了几年,手动检测不再使用的代码变得非常困难。但我们会尝试尽可能多地删除未使用的代码。

What tools do you use to find unused/dead code in large react projects? Our product has been in development for some years, and it is getting very hard to manually detect code that is no longer in use. We do however try to delete as much unused code as possible.

对于一般策略/技术(特定工具除外)的建议也很受欢迎。

Suggestions for general strategies/techniques (other than specific tools) are also appreciated.

谢谢

推荐答案

首先,
非常好的问题,大项目编码人员通常会尝试多行代码测试,并在结果结束时很难找到未使用的代码。

First of all, very good question, in large project coders usually try many lines of code test and at the end of result, hard to find the unused code.

有两种可能对您有用 - 我通常会在需要删除并将未使用的代码减少到项目中时执行。

There is two possible that must be work for you - i usually do whenever i need to remove and reduce the unused code into my project.

第一种方式WebStorm IDE:

如果你正在使用 web-storm IDE 或React JS / React Native或Vue js等它告诉我们并指出我们在编辑器中使用不同颜色或红色警告作为未使用的代码

If you're using the web-storm IDE for JS development or React JS / React Native or Vue js etc it's tell us and indicate us alote of mention with different color or red warning as unused code inside the editor

,但它在您的特定情况下不起作用,还有另一种方法可以删除未使用的代码。

but it's not works in your particular scenario there is another way to remove the unused code .

二路无回报库:

删除未使用代码的第二种方法项目内部是Unrequited库,你可以在这里访问: unquited github

The second way to remove the unused code inside the project is Unrequited library you can visit here : unrequited github

另一个名为depcheck的图书馆,名为NPM& github 此处

another library called depcheck under NPM & github here

只需遵循他们适当的方法 - 如何使用它们你将轻松解决这个未使用的问题

Just follow their appropriate method - how to use them you will fix this unused issue easily

希望这有助于你

这篇关于如何在大型反应项目中找到死代码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆