Javascript 的最佳源代码格式化程序?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/351298/
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-08-11 13:42:42  来源:igfitidea点击:

Best source code formatter for Javascript?

javajavascriptcode-formatting

提问by thebossman

I've been digging through Stack Overflow as well as a number of Google searches, and I cannot find a satisfactory code formatter for Javascript.

我一直在挖掘 Stack Overflow 以及许多 Google 搜索,但找不到令人满意的 Javascript 代码格式化程序。

I have found several related tools, such as syntax highlighters and pretty-printers, but I am looking for a tool that I can ideally create a wrapper for in Eclipse and simply run from the menu bar. Hence, if any Java-based ones are available, that is a big plus. Free and/or open-source is preferred as well.

我找到了几个相关的工具,例如语法高亮器和漂亮的打印机,但我正在寻找一种工具,我可以理想地在 Eclipse 中为其创建包装器,并且只需从菜单栏运行。因此,如果有任何基于 Java 的可用,那将是一个很大的优势。免费和/或开源也是首选。

I am looking for something that my development group can use to maintain a consistent code style.

我正在寻找我的开发团队可以用来保持一致的代码风格的东西。

Thanks.

谢谢。

[EDIT]Thank you for the incredibly fast responses! I would upvote you both if I had any karma. But especially kRON for linking to the format customizationspage.

[编辑]感谢您的令人难以置信的快速响应!如果我有任何业力,我会赞成你们两个。但特别是用于链接到格式自定义页面的kRON 。

[EDIT]Related questionon Stack Overflow.

[编辑]Stack Overflow 上的相关问题

采纳答案by Filip Dupanovi?

In one breath: Aptana Studio! Yes, it's Java based and free (Eclipse, as standalone or plugin).

一口气:Aptana Studio!是的,它是基于 Java 的并且是免费的(Eclipse,作为独立的或插件)。

You can also customize the formatting.

您还可以自定义格式

回答by CMS

If you already use Eclipse, I recommend you to try Aptana, you can install it as an Eclipse Plugin.

如果您已经使用 Eclipse,我建议您尝试Aptana,您可以将其安装为 Eclipse 插件。

回答by Peter

If you also need Java programming I can recommend 'IntelliJ IDEA'

如果您还需要 Java 编程,我可以推荐“ IntelliJ IDEA

It offers excellent JavaScript formatting and refactoring out of the box.

它提供了出色的 JavaScript 格式和开箱即用的重构。

回答by eozzy

This is by far the best I've come across: http://jsbeautifier.org/

这是迄今为止我遇到的最好的:http: //jsbeautifier.org/

Available as an online tool, or on the command-line using node.js or python. The source code is available.

可作为在线工具使用,或在命令行上使用 node.js 或 python。 源代码可用

回答by JGFMK

Have you tried jsfiddler. It's great for trying things out with Javascript. Built in JSLint & something called Tidy. Not sure whether that infers jstidyPiotr Zalewais the guy who wrote it. May be worth giving him a Tweet @zalunto confirm.

你试过jsfiddler 吗?非常适合使用 Javascript 进行尝试。内置 JSLint 和称为 Tidy 的东西。不确定这是否推断jstidy Piotr Zalewa是编写它的人。可能值得给他发一条推文@zalun来确认。

回答by Sun Junwen

If you are using notepad++, you can try jsminnpp plugin

如果你使用的是记事本++,你可以试试 jsminnpp 插件

回答by yurko