eclipse 你如何重构 JavaScript、HTML、CSS 等?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1446267/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 14:01:33  来源:igfitidea点击:

How do you refactor JavaScript, HTML, CSS, etc?

javascripthtmlcsseclipserefactoring

提问by Alex Siman

I'm using Eclipse and the current solution (which I dislike) is to use "Search/Replace". This is an error prone solution.

我正在使用 Eclipse,当前的解决方案(我不喜欢)是使用“搜索/替换”。这是一个容易出错的解决方案。

Do you know any better approach to refactor JavaScript, HTML, CSS resources safely in big applications? Or do you use any other cool refactoring tool(s)?

您知道在大型应用程序中安全地重构 JavaScript、HTML、CSS 资源的更好方法吗?或者您是否使用任何其他很酷的重构工具?

回答by ripper234

IntelliJ seems to supportJavacsript/HTML/CSS refactoring out of the box.

IntelliJ 似乎支持开箱即用的 Javacsript/HTML/CSS 重构。

回答by Oliver Watkins

Because Javascript is weakly typed, effortless refactoring is nearly impossible. JetBrains Webstorm is the best thing out there that does something that "resembles" refactoring.

由于 Javascript 是弱类型的,因此轻松重构几乎是不可能的。JetBrains Webstorm 是最好的东西,它可以做一些“类似于”重构的事情。

And please look at this comparison of Javascript refactoring of common Javascript IDEs : http://blue-walrus.com/2013/08/review-javascript-ides/

请看一下常见 Javascript IDE 的 Javascript 重构比较:http: //blue-walrus.com/2013/08/review-javascript-ides/

回答by Pascal Thivent

Eclipse Galileo for Java EE 3.5 has built-in support for JavaScript, with auto-complete, refactoring, etc. For HTML/XHTML/CSS, I'm not aware of any special features to ease refactoring apart from the project-wide search/replace.

Eclipse Galileo for Java EE 3.5 内置了对 JavaScript 的支持,具有自动完成、重构等功能。对于 HTML/XHTML/CSS,除了项目范围的搜索之外,我不知道有任何特殊功能可以简化重构/代替。

From this point of view, IntelliJ IDEA seems thus to have much better support. See:

从这个角度来看,IntelliJ IDEA 似乎因此有更好的支持。看:

回答by Pascal Thivent

The trick is to maintain CSS clean and transparent from the beginning and clean it up as soos as things are starting to get messy.

诀窍是从一开始就保持 CSS 干净和透明,并在事情开始变得混乱时将其清理干净。

CSS is one of those things that are terribly hard to clean up LATER.

CSS 是那些以后很难清理的东西之一。

Also, when naming selectors, choose names wisely in order to avoid coincidence with the other code of the application (at least when case-sensitive). This will help you with search & replace approach.

此外,在命名选择器时,请明智地选择名称以避免与应用程序的其他代码重合(至少在区分大小写时)。这将帮助您使用搜索和替换方法。

回答by Raja

Check out CodeRush, a plugin for MS Visual Studio. It claims to support over 50 different refactorings for JavaScript. How far did DevExpress get with Javascript refactoring?

查看 CodeRush,一个 MS Visual Studio 插件。它声称支持 50 多种不同的 JavaScript 重构。 DevExpress 在 Javascript 重构方面取得了多大进展?

Hope that helps!

希望有帮助!

回答by Kzqai

One possibility that I've come across (though haven't used extensively yet) for css is: https://addons.mozilla.org/en-US/firefox/addon/5392

对于 css,我遇到的一种可能性(虽然还没有广泛使用)是:https: //addons.mozilla.org/en-US/firefox/addon/5392

The Dustme Selectors firefox addon, which is supposed to let you weed out css selectors that aren't used when you browse a subset of pages.

Dustme Selectors firefox 插件,它应该让您清除浏览页面子集时不使用的 css 选择器。

Another solution that I have used for minor css checks is: http://www.cleancss.com/

我用于次要 css 检查的另一个解决方案是:http: //www.cleancss.com/

Some of the "color word to color code efficiency changes" are probably very minimal unless you have a large number of occurrences of them, but it's useful for analysis in general as well.

一些“颜色词到颜色代码的效率变化”可能非常小,除非它们出现的次数很多,但它对一般分析也很有用。