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

2682Re: [jslint] Re: Can we please lose the trailing whitespace and "this" restriction?

Expand Messages
  • Michael Mikowski
    Nov 16, 2011
      You want to do this independent of all other code work.  So the following workflow is recommended:

      git pull
      sed -i -e 's/\s*$//' $(find ./ -type f)
      // ensure nothing has been broken (run your executable against regression tests!):
      git diff
      git difftool

      // and now save the changes ye hath wrought:
      git commit -a -m 'Removed trailing whitespace in all files in repo'

      From: Michael Mikowski <z_mikowski@...>
      To: "jslint_com@yahoogroups.com" <jslint_com@yahoogroups.com>
      Cc: paulcrowder1979 <paul@...>
      Sent: Wednesday, November 16, 2011 1:27 PM
      Subject: Re: [jslint] Re: Can we please lose the trailing whitespace and "this" restriction?

      Removing trailing whitespace IS trivial:

      sed -i -e 's/\s*$//' $(find ./ -type f)

      Of course if you are using notepad, it might take a few months.

      From: paulcrowder1979 <paul@...>
      To: jslint_com@yahoogroups.com
      Sent: Wednesday, November 16, 2011 12:44 PM
      Subject: [jslint] Re: Can we please lose the trailing whitespace and "this" restriction?


      --- In jslint_com@yahoogroups.com, "douglascrockford" <douglas@...> wrote:
      > JSLint was written for me. JavaScript is a language full of traps and sharp edges. I do not dare write in JavaScript without JSLint's assistance. I have made it available to the world for free. If it helps you too, then great. If it doesn't help you, then don't use it. I get paid the same either way.
      > I have been improving JSLint with the assistance of the people who use it. As our understanding of the hazards in JavaScript improve, JSLint improves, and the subset of JavaScript that it recommends changes.
      > Regrettably, this necessarily causes programs with previously undiscovered faults to, as you would say, berak. When that happens, the best advice is to follow JSLint's advice and fix your code.
      > With respect to spaces at the end of lines: From a code hygiene perspective, there is no good argument for keeping them. If you are arguing that there is no one in your organization with the programming skill to remove them, then it seems your organization is suffering from problems that JSLint cannot help you solve. But in any case, the "Tolerate messy white space" option will ignore those spaces. But my advice is to not use that option and write smart looking code instead.

      I agree with some of your points. JSLint is a valuable tool, and I do not write JavaScript without it. I also see the value in adding new rules as new hazards are discovered. What I don't understand is adding arbitrary rules that don't add to the quality of the code. You say there's no argument for keeping trailing whitespace, but I disagree. The best argument is that the whitespace is already there, it's doing no harm, and to remove it and enforce that all new code not have it would require a non-trivial amount of effort. That is effort that could be spent adding to the quality of our product, such as adding new features and fixing real bugs, rather than fiddling with code (wasn't it you who said "I highly recommend you don't fiddle with code"? https://developer.yahoo.com/yui/theater/video.php?v=crockonjs-5). I'm not sure why you jumped to the conclusion that no one in my organization has the skill to write a utility to remove trailing whitespace
      rather than perhaps considering the fact that writing the utility costs time and money; I think that says more about you than it does my organization.

      [Non-text portions of this message have been removed]
    • Show all 22 messages in this topic