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.)
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With