Fix jshint warnings.

Review Request #4302 — Created July 6, 2013 and submitted

Information

Review Board
master

Reviewers

Fix jshint warnings.

This fixes a bunch of warnings in our JavaScript that JSHint reported.

A .jshintrc has been created which will suppress warnings about
__proto__ being used (needed in _.super), and operators like "&&", "?"
and ":" being at the beginning of lines.

This also turns on a bunch of jshint options for things we want to
enforce, like one var statement at the top of a function, unused
variable checks, trailing comma detection, and more.

One thing to note is that we use some reserved keywords as keys, which
causes warnings in JSHint unless they're always quoted. This so far only
came up with the new RepositoryBranch. I've quoted them, but we may want
to consider coming up with new standardized names, such as "isDefault".
Didn't see any issues using the site.

Unit tests passed.

JSHint was happy, except for diffviewer.js, which is gone with my other
changes.
Description From Last Updated

Just an aside--should we be using hasOwnProperty here?

daviddavid

You should be able to wrap this nicer now: .load(url, function(responseText) { ... });

daviddavid

Do you want to do /* rsp */ here, like you did elsewhere?

daviddavid
reviewbot
  1. This is a review from Review Bot.
      Tool: PEP8 Style Checker
      Processed Files:
      Ignored Files:
        reviewboard/static/rb/js/views/tests/reviewBoxListViewTests.js
        reviewboard/static/rb/js/views/draftReviewBannerView.js
        reviewboard/static/rb/js/views/issueSummaryTableView.js
        reviewboard/static/rb/js/models/tests/draftReviewModelTests.js
        reviewboard/static/rb/js/views/abstractCommentBlockView.js
        reviewboard/static/rb/js/collections/resourceCollection.js
        reviewboard/static/rb/js/resources/models/tests/repositoryBranchModelTests.js
        reviewboard/static/rb/js/views/tests/reviewDialogViewTests.js
        reviewboard/static/rb/js/views/reviewRequestEditorView.js
        reviewboard/static/rb/js/models/tests/reviewModelTests.js
        reviewboard/static/rb/js/views/reviewReplyEditorView.js
        reviewboard/static/rb/js/utils/compatUtils.js
        reviewboard/static/rb/js/models/diffCommentModel.js
        reviewboard/static/rb/js/views/commentIssueBarView.js
        reviewboard/static/rb/js/utils/tests/keyBindingUtilsTests.js
        reviewboard/static/rb/js/views/collectionView.js
        reviewboard/static/rb/js/utils/propertyUtils.js
        reviewboard/static/rb/js/models/reviewRequestEditorModel.js
        reviewboard/static/rb/js/models/userSessionModel.js
        reviewboard/static/rb/js/resources/collections/tests/repositoryBranchesCollectionTests.js
        reviewboard/static/rb/js/views/fileAttachmentThumbnailView.js
        reviewboard/static/rb/js/resources/collections/tests/repositoryCommitsCollectionTests.js
        reviewboard/static/rb/js/resources/collections/repositoryCommitsCollection.js
        reviewboard/static/rb/js/views/commentDialogView.js
        reviewboard/static/rb/js/resources/models/repositoryBranchModel.js
        reviewboard/static/rb/js/diffviewer/views/diffReviewableView.js
        reviewboard/static/rb/js/models/baseResourceModel.js
        reviewboard/static/rb/js/models/diffModel.js
        reviewboard/static/rb/js/models/draftResourceModelMixin.js
        reviewboard/static/rb/js/utils/linkifyUtils.js
        reviewboard/static/rb/js/views/reviewDialogView.js
        reviewboard/static/rb/js/views/tests/reviewRequestEditorViewTests.js
        reviewboard/static/rb/js/views/tests/reviewReplyEditorViewTests.js
        reviewboard/static/rb/js/models/baseCommentReplyModel.js
        reviewboard/static/rb/js/views/reviewBoxView.js
        reviewboard/static/rb/js/pages/views/diffViewerPageView.js
        reviewboard/static/rb/js/models/baseCommentModel.js
        reviewboard/static/rb/js/models/screenshotCommentModel.js
        reviewboard/static/rb/js/utils/tests/linkifyUtilsTests.js
        reviewboard/static/rb/js/models/fileAttachmentCommentModel.js
        reviewboard/static/rb/js/diffviewer/views/tests/diffReviewableViewTests.js
        reviewboard/static/rb/js/views/tests/draftReviewBannerViewTests.js
        reviewboard/static/rb/js/views/tests/fileAttachmentThumbnailViewTests.js
        reviewboard/static/rb/js/utils/apiUtils.js
        reviewboard/static/rb/js/utils/consoleUtils.js
        reviewboard/static/rb/js/models/commentEditorModel.js
        reviewboard/static/rb/js/views/tests/reviewReplyDraftBannerViewTests.js
        reviewboard/static/rb/js/repositoryform.js
        reviewboard/static/rb/js/views/tests/commentDialogViewTests.js
        reviewboard/static/rb/js/models/tests/reviewReplyModelTests.js
        reviewboard/static/rb/js/models/tests/draftReviewRequestModelTests.js
        reviewboard/static/rb/js/models/abstractCommentBlockModel.js
        reviewboard/static/rb/js/models/tests/baseResourceModelTests.js
        reviewboard/static/rb/js/utils/keyBindingUtils.js
        reviewboard/static/rb/js/.jshintrc
        reviewboard/static/rb/js/models/reviewReplyEditorModel.js
        reviewboard/static/rb/js/admin.js
        reviewboard/static/rb/js/common.js
        reviewboard/static/rb/js/models/abstractReviewableModel.js
        reviewboard/static/rb/js/models/tests/commentEditorModelTests.js
        reviewboard/static/rb/js/views/diffFragmentQueueView.js
    
    
  2. 
      
reviewbot
  1. This is a review from Review Bot.
      Tool: Pyflakes
      Processed Files:
      Ignored Files:
        reviewboard/static/rb/js/views/tests/reviewBoxListViewTests.js
        reviewboard/static/rb/js/views/draftReviewBannerView.js
        reviewboard/static/rb/js/views/issueSummaryTableView.js
        reviewboard/static/rb/js/models/tests/draftReviewModelTests.js
        reviewboard/static/rb/js/views/abstractCommentBlockView.js
        reviewboard/static/rb/js/collections/resourceCollection.js
        reviewboard/static/rb/js/resources/models/tests/repositoryBranchModelTests.js
        reviewboard/static/rb/js/views/tests/reviewDialogViewTests.js
        reviewboard/static/rb/js/views/reviewRequestEditorView.js
        reviewboard/static/rb/js/models/tests/reviewModelTests.js
        reviewboard/static/rb/js/views/reviewReplyEditorView.js
        reviewboard/static/rb/js/utils/compatUtils.js
        reviewboard/static/rb/js/models/diffCommentModel.js
        reviewboard/static/rb/js/views/commentIssueBarView.js
        reviewboard/static/rb/js/utils/tests/keyBindingUtilsTests.js
        reviewboard/static/rb/js/views/collectionView.js
        reviewboard/static/rb/js/utils/propertyUtils.js
        reviewboard/static/rb/js/models/reviewRequestEditorModel.js
        reviewboard/static/rb/js/models/userSessionModel.js
        reviewboard/static/rb/js/resources/collections/tests/repositoryBranchesCollectionTests.js
        reviewboard/static/rb/js/views/fileAttachmentThumbnailView.js
        reviewboard/static/rb/js/resources/collections/tests/repositoryCommitsCollectionTests.js
        reviewboard/static/rb/js/resources/collections/repositoryCommitsCollection.js
        reviewboard/static/rb/js/views/commentDialogView.js
        reviewboard/static/rb/js/resources/models/repositoryBranchModel.js
        reviewboard/static/rb/js/diffviewer/views/diffReviewableView.js
        reviewboard/static/rb/js/models/baseResourceModel.js
        reviewboard/static/rb/js/models/diffModel.js
        reviewboard/static/rb/js/models/draftResourceModelMixin.js
        reviewboard/static/rb/js/utils/linkifyUtils.js
        reviewboard/static/rb/js/views/reviewDialogView.js
        reviewboard/static/rb/js/views/tests/reviewRequestEditorViewTests.js
        reviewboard/static/rb/js/views/tests/reviewReplyEditorViewTests.js
        reviewboard/static/rb/js/models/baseCommentReplyModel.js
        reviewboard/static/rb/js/views/reviewBoxView.js
        reviewboard/static/rb/js/pages/views/diffViewerPageView.js
        reviewboard/static/rb/js/models/baseCommentModel.js
        reviewboard/static/rb/js/models/screenshotCommentModel.js
        reviewboard/static/rb/js/utils/tests/linkifyUtilsTests.js
        reviewboard/static/rb/js/models/fileAttachmentCommentModel.js
        reviewboard/static/rb/js/diffviewer/views/tests/diffReviewableViewTests.js
        reviewboard/static/rb/js/views/tests/draftReviewBannerViewTests.js
        reviewboard/static/rb/js/views/tests/fileAttachmentThumbnailViewTests.js
        reviewboard/static/rb/js/utils/apiUtils.js
        reviewboard/static/rb/js/utils/consoleUtils.js
        reviewboard/static/rb/js/models/commentEditorModel.js
        reviewboard/static/rb/js/views/tests/reviewReplyDraftBannerViewTests.js
        reviewboard/static/rb/js/repositoryform.js
        reviewboard/static/rb/js/views/tests/commentDialogViewTests.js
        reviewboard/static/rb/js/models/tests/reviewReplyModelTests.js
        reviewboard/static/rb/js/models/tests/draftReviewRequestModelTests.js
        reviewboard/static/rb/js/models/abstractCommentBlockModel.js
        reviewboard/static/rb/js/models/tests/baseResourceModelTests.js
        reviewboard/static/rb/js/utils/keyBindingUtils.js
        reviewboard/static/rb/js/.jshintrc
        reviewboard/static/rb/js/models/reviewReplyEditorModel.js
        reviewboard/static/rb/js/admin.js
        reviewboard/static/rb/js/common.js
        reviewboard/static/rb/js/models/abstractReviewableModel.js
        reviewboard/static/rb/js/models/tests/commentEditorModelTests.js
        reviewboard/static/rb/js/views/diffFragmentQueueView.js
    
    
  2. 
      
david
  1. 
      
  2. reviewboard/static/rb/js/common.js (Diff revision 1)
     
     
    Show all issues
    Just an aside--should we be using hasOwnProperty here?
    1. Probably should. Planning to redo this whole thing though. Ideally, this entire widget goes away.
  3. reviewboard/static/rb/js/common.js (Diff revision 1)
     
     
     
     
     
     
     
     
    Show all issues
    You should be able to wrap this nicer now:
    
    .load(url, function(responseText) {
        ...
    });
    1. I'm going to redo this entire thing. I'm not going to be too invasive here on this change.
    2. For some reason I read this totally wrong. Sleepy. Fixing.
  4. Show all issues
    Do you want to do /* rsp */ here, like you did elsewhere?
    1. Oh, yep. Good catch.
  5. 
      
chipx86
reviewbot
  1. This is a review from Review Bot.
      Tool: PEP8 Style Checker
      Processed Files:
      Ignored Files:
        reviewboard/static/rb/js/views/tests/reviewBoxListViewTests.js
        reviewboard/static/rb/js/views/draftReviewBannerView.js
        reviewboard/static/rb/js/views/issueSummaryTableView.js
        reviewboard/static/rb/js/models/tests/draftReviewModelTests.js
        reviewboard/static/rb/js/views/abstractCommentBlockView.js
        reviewboard/static/rb/js/collections/resourceCollection.js
        reviewboard/static/rb/js/resources/models/tests/repositoryBranchModelTests.js
        reviewboard/static/rb/js/views/tests/reviewDialogViewTests.js
        reviewboard/static/rb/js/views/reviewRequestEditorView.js
        reviewboard/static/rb/js/models/tests/reviewModelTests.js
        reviewboard/static/rb/js/views/reviewReplyEditorView.js
        reviewboard/static/rb/js/utils/compatUtils.js
        reviewboard/static/rb/js/models/diffCommentModel.js
        reviewboard/static/rb/js/views/commentIssueBarView.js
        reviewboard/static/rb/js/utils/tests/keyBindingUtilsTests.js
        reviewboard/static/rb/js/views/collectionView.js
        reviewboard/static/rb/js/utils/propertyUtils.js
        reviewboard/static/rb/js/models/reviewRequestEditorModel.js
        reviewboard/static/rb/js/models/userSessionModel.js
        reviewboard/static/rb/js/resources/collections/tests/repositoryBranchesCollectionTests.js
        reviewboard/static/rb/js/views/fileAttachmentThumbnailView.js
        reviewboard/static/rb/js/resources/collections/tests/repositoryCommitsCollectionTests.js
        reviewboard/static/rb/js/resources/collections/repositoryCommitsCollection.js
        reviewboard/static/rb/js/views/commentDialogView.js
        reviewboard/static/rb/js/resources/models/repositoryBranchModel.js
        reviewboard/static/rb/js/diffviewer/views/diffReviewableView.js
        reviewboard/static/rb/js/models/baseResourceModel.js
        reviewboard/static/rb/js/models/diffModel.js
        reviewboard/static/rb/js/models/draftResourceModelMixin.js
        reviewboard/static/rb/js/utils/linkifyUtils.js
        reviewboard/static/rb/js/views/reviewDialogView.js
        reviewboard/static/rb/js/views/tests/reviewRequestEditorViewTests.js
        reviewboard/static/rb/js/views/tests/reviewReplyEditorViewTests.js
        reviewboard/static/rb/js/models/baseCommentReplyModel.js
        reviewboard/static/rb/js/views/reviewBoxView.js
        reviewboard/static/rb/js/pages/views/diffViewerPageView.js
        reviewboard/static/rb/js/models/baseCommentModel.js
        reviewboard/static/rb/js/models/screenshotCommentModel.js
        reviewboard/static/rb/js/utils/tests/linkifyUtilsTests.js
        reviewboard/static/rb/js/models/fileAttachmentCommentModel.js
        reviewboard/static/rb/js/diffviewer/views/tests/diffReviewableViewTests.js
        reviewboard/static/rb/js/views/tests/draftReviewBannerViewTests.js
        reviewboard/static/rb/js/views/tests/fileAttachmentThumbnailViewTests.js
        reviewboard/static/rb/js/utils/apiUtils.js
        reviewboard/static/rb/js/utils/consoleUtils.js
        reviewboard/static/rb/js/models/commentEditorModel.js
        reviewboard/static/rb/js/views/tests/reviewReplyDraftBannerViewTests.js
        reviewboard/static/rb/js/repositoryform.js
        reviewboard/static/rb/js/views/tests/commentDialogViewTests.js
        reviewboard/static/rb/js/models/tests/reviewReplyModelTests.js
        reviewboard/static/rb/js/models/tests/draftReviewRequestModelTests.js
        reviewboard/static/rb/js/models/abstractCommentBlockModel.js
        reviewboard/static/rb/js/models/tests/baseResourceModelTests.js
        reviewboard/static/rb/js/utils/keyBindingUtils.js
        reviewboard/static/rb/js/.jshintrc
        reviewboard/static/rb/js/models/reviewReplyEditorModel.js
        reviewboard/static/rb/js/admin.js
        reviewboard/static/rb/js/common.js
        reviewboard/static/rb/js/models/abstractReviewableModel.js
        reviewboard/static/rb/js/models/tests/commentEditorModelTests.js
        reviewboard/static/rb/js/views/diffFragmentQueueView.js
    
    
  2. 
      
reviewbot
  1. This is a review from Review Bot.
      Tool: Pyflakes
      Processed Files:
      Ignored Files:
        reviewboard/static/rb/js/views/tests/reviewBoxListViewTests.js
        reviewboard/static/rb/js/views/draftReviewBannerView.js
        reviewboard/static/rb/js/views/issueSummaryTableView.js
        reviewboard/static/rb/js/models/tests/draftReviewModelTests.js
        reviewboard/static/rb/js/views/abstractCommentBlockView.js
        reviewboard/static/rb/js/collections/resourceCollection.js
        reviewboard/static/rb/js/resources/models/tests/repositoryBranchModelTests.js
        reviewboard/static/rb/js/views/tests/reviewDialogViewTests.js
        reviewboard/static/rb/js/views/reviewRequestEditorView.js
        reviewboard/static/rb/js/models/tests/reviewModelTests.js
        reviewboard/static/rb/js/views/reviewReplyEditorView.js
        reviewboard/static/rb/js/utils/compatUtils.js
        reviewboard/static/rb/js/models/diffCommentModel.js
        reviewboard/static/rb/js/views/commentIssueBarView.js
        reviewboard/static/rb/js/utils/tests/keyBindingUtilsTests.js
        reviewboard/static/rb/js/views/collectionView.js
        reviewboard/static/rb/js/utils/propertyUtils.js
        reviewboard/static/rb/js/models/reviewRequestEditorModel.js
        reviewboard/static/rb/js/models/userSessionModel.js
        reviewboard/static/rb/js/resources/collections/tests/repositoryBranchesCollectionTests.js
        reviewboard/static/rb/js/views/fileAttachmentThumbnailView.js
        reviewboard/static/rb/js/resources/collections/tests/repositoryCommitsCollectionTests.js
        reviewboard/static/rb/js/resources/collections/repositoryCommitsCollection.js
        reviewboard/static/rb/js/views/commentDialogView.js
        reviewboard/static/rb/js/resources/models/repositoryBranchModel.js
        reviewboard/static/rb/js/diffviewer/views/diffReviewableView.js
        reviewboard/static/rb/js/models/baseResourceModel.js
        reviewboard/static/rb/js/models/diffModel.js
        reviewboard/static/rb/js/models/draftResourceModelMixin.js
        reviewboard/static/rb/js/utils/linkifyUtils.js
        reviewboard/static/rb/js/views/reviewDialogView.js
        reviewboard/static/rb/js/views/tests/reviewRequestEditorViewTests.js
        reviewboard/static/rb/js/views/tests/reviewReplyEditorViewTests.js
        reviewboard/static/rb/js/models/baseCommentReplyModel.js
        reviewboard/static/rb/js/views/reviewBoxView.js
        reviewboard/static/rb/js/pages/views/diffViewerPageView.js
        reviewboard/static/rb/js/models/baseCommentModel.js
        reviewboard/static/rb/js/models/screenshotCommentModel.js
        reviewboard/static/rb/js/utils/tests/linkifyUtilsTests.js
        reviewboard/static/rb/js/models/fileAttachmentCommentModel.js
        reviewboard/static/rb/js/diffviewer/views/tests/diffReviewableViewTests.js
        reviewboard/static/rb/js/views/tests/draftReviewBannerViewTests.js
        reviewboard/static/rb/js/views/tests/fileAttachmentThumbnailViewTests.js
        reviewboard/static/rb/js/utils/apiUtils.js
        reviewboard/static/rb/js/utils/consoleUtils.js
        reviewboard/static/rb/js/models/commentEditorModel.js
        reviewboard/static/rb/js/views/tests/reviewReplyDraftBannerViewTests.js
        reviewboard/static/rb/js/repositoryform.js
        reviewboard/static/rb/js/views/tests/commentDialogViewTests.js
        reviewboard/static/rb/js/models/tests/reviewReplyModelTests.js
        reviewboard/static/rb/js/models/tests/draftReviewRequestModelTests.js
        reviewboard/static/rb/js/models/abstractCommentBlockModel.js
        reviewboard/static/rb/js/models/tests/baseResourceModelTests.js
        reviewboard/static/rb/js/utils/keyBindingUtils.js
        reviewboard/static/rb/js/.jshintrc
        reviewboard/static/rb/js/models/reviewReplyEditorModel.js
        reviewboard/static/rb/js/admin.js
        reviewboard/static/rb/js/common.js
        reviewboard/static/rb/js/models/abstractReviewableModel.js
        reviewboard/static/rb/js/models/tests/commentEditorModelTests.js
        reviewboard/static/rb/js/views/diffFragmentQueueView.js
    
    
  2. 
      
david
  1. Ship It!
  2. 
      
chipx86
Review request changed
Status:
Completed