任何自动修复简单JSLint问题的工具? [英] Any tool to automatically fix simple JSLint issues?

查看:87
本文介绍了任何自动修复简单JSLint问题的工具?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我第一次在一个相当冗长的文件上运行JSLint,我有很多错误,比如预计function和(或意外的''。我没有意识到这对我学习javascript的任何地方都很重要,现在用手工修理这些相当简单的东西似乎很令人沮丧。我可以通过简单的查找和替换来弄清楚,但我想知道是否有任何在线工具会自动为我做这些更改,因为它们看起来非常简单?

I've run JSLint for the first time on a rather lengthy file, and I have a lot of errors like expected exactly 1 space between "function" and "(" or unexpected ' '. I didn't realize this was important at all anywhere I learned about javascript and now fixing each one of these rather simple things by hand seems frustrating. Some I can figure out with simple find and replaces, but I wondered if there's any tools online that will automatically make these changes for me since they seem to be pretty straightforward?

(我在我的文件中有 / * jslint white:false * / ,我在 Netbeans 中开发和自动格式化(除了我必须纠正悬挂jQuery链接,因为它没有正确),并且我的代码仍然有大量的事情,jslint抱怨有关意外数量的空格。)

(I have /*jslint white: false */ in my file, I develop in Netbeans and auto-format (except then I have to correct hanging jQuery chainings because it doesn't do it right), and my code still ends up with a huge number of things that jslint complains about as far as unexpected numbers of spaces.)

推荐答案

Damon,更漂亮可能会做任何你想要的无痛javascript代码格式化。它会将您的代码转换为AST,然后将其打印回您的文件中,以便随时自动格式化。您甚至可以将它添加为预先挂起的钩子,或者在一个充满文件的文件夹上运行它(非常快!)这样你的整个代码库就会非常漂亮。

Damon, Prettier is probably going to do everything you want wrt painless javascript code formatting. It will convert your code to an AST and then pretty print it back into your file so it auto-formats as you go. You can even add it as a precommit hook or run it on a folder full of files (pretty quickly, too!) so that your entire codebase will be immediately pretty.

以下是来自ReactConf的视频,解释得非常好

这篇关于任何自动修复简单JSLint问题的工具?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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