Loading ...
Sorry, an error occurred while loading the content.

1739Re: Fast fixing for JSLint

Expand Messages
  • Douglas Crockford
    Jan 9, 2011
    • 0 Attachment
      --- In jslint_com@yahoogroups.com, "aceblchboy" <aceblchboy@...> wrote:
      > What tools / do you use to quickly fix JS code up to satisfy JSLint's warnings and errors?
      > First I test the code's parsability, if I can get to the end of the code without an error, it's good to go. This is much harder to do these days, with more stopping errors.
      > Without concern for code formatting:
      > I use closure compiler whitespace + pretty print mode to fix missing brackets. The drawback is that it eats empty constructor brackets, optional semicolons, breaks up else if the hard way (becomes } else { if), and completely reformats the code. One advantage of this is that it reformats quotation marks for consistency and precomputes some math constants.
      > I then fill the missing semicolons with jsutility.pjoneil.net (JSLint derived). The drawback here is that it also completely reformats your code.
      > I beautify it with jsbeautifier, and hunt down the less noisier warnings.
      > With concern for formatting:
      > I have JSLint parse the code and look for missing semicolons, and fill those in by hand.
      > I have jsbeautifier beautify the code with indentation to match the document's formatting and preserve lines. This makes if\for\while (\(.*\)) (\w.*;)$ -> if\for\while \1 {\2} a fast bracket fix with another beautification. Then targeting the other warnings.
      > I think i'll grab a previous version of JSLint since there are now so many error stops over what were previously simple issues.

      I think you would do better to fix your code.

      I don't recommend automating correction because of the likelihood of automatic bug insertion. Using JSLint with an IDE seems to be the best alternative.
    • Show all 4 messages in this topic