Best source code formatter for Javascript? [closed]

落花浮王杯 提交于 2019-11-27 04:37:20

问题


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.

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.

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 customizations page.

[EDIT] Related question on Stack Overflow.


回答1:


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

You can also customize the formatting.




回答2:


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

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




回答3:


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




回答4:


  • For Eclipse IDE you can use JavaScript Code Formatter based on Goolge's Style Guide

  • For IntelliJ IDEA you can use the same js code formatter xml file , but previously you have to install a special plugin Eclipse Code Formatter Plugin, which solves the problem of maintaining a common code style in team environments where both IDEA and Eclipse are used




回答5:


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

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




回答6:


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




回答7:


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



来源:https://stackoverflow.com/questions/351298/best-source-code-formatter-for-javascript

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!