Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Any tool to automatically fix simple JSLint issues? [closed]

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?

(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.)

like image 616
Damon Avatar asked Sep 27 '11 04:09

Damon


1 Answers

While it checks for different things than JSLint, the fixjsstyle mode of the Google closure linter may do what you want.

It automatically fixes code to (more closely) fit with the Google Javascript style guide which is well worth a read.

As others have pointed out, the Javascript beautifier is the way to go for spacing issues.

like image 112
Timothy Jones Avatar answered Sep 17 '22 13:09

Timothy Jones