WordPress.org

Make WordPress Core

Opened 5 months ago

Closed 5 months ago

Last modified 5 months ago

#25979 closed defect (bug) (fixed)

jshint shouldn't throw errors: wp-admin/js/edit-comments.js

Reported by: adamsilverstein Owned by: nacin
Milestone: 3.8 Priority: normal
Severity: normal Version:
Component: Build/Test Tools Keywords: needs-patch
Focuses: Cc:

Description

51 errors:

Linting src/wp-admin/js/edit-comments.js ...ERROR
[L32:C13] W081: Too many var statements.
    var diff = $('#' + settings.element).is('.' + settings.dimClass) ? 1 : -1;
Linting src/wp-admin/js/edit-comments.js ...ERROR
[L83:C106] W033: Missing semicolon.
          $('#comment-' + id).css('backgroundColor', '').fadeIn(300, function(){ $(this).show() });
Linting src/wp-admin/js/edit-comments.js ...ERROR
[L147:C43] W041: Use '===' to compare with '0'.
      a.closest('.awaiting-mod')[ 0 == n ? 'addClass' : 'removeClass' ]('count-0');
Linting src/wp-admin/js/edit-comments.js ...ERROR
[L228:C52] W041: Use '===' to compare with '0'.
    if ( ! theExtraList || theExtraList.size() == 0 || theExtraList.children().size() == 0 || untrash || unspam ) {
Linting src/wp-admin/js/edit-comments.js ...ERROR
[L228:C91] W041: Use '===' to compare with '0'.
    if ( ! theExtraList || theExtraList.size() == 0 || theExtraList.children().size() == 0 || untrash || unspam ) {
Linting src/wp-admin/js/edit-comments.js ...ERROR
[L286:C72] W033: Missing semicolon.
        $('#undo-' + id).fadeIn(300, function(){ $(this).show() });
Linting src/wp-admin/js/edit-comments.js ...ERROR
[L358:C47] W033: Missing semicolon.
      c.fadeIn(300, function(){ c.show() }).css('backgroundColor', '');
Linting src/wp-admin/js/edit-comments.js ...ERROR
[L406:C70] W033: Missing semicolon.
        $('#replyrow').fadeIn(300, function(){ $(this).show() });
Linting src/wp-admin/js/edit-comments.js ...ERROR
[L413:C1] W099: Mixed spaces and tabs.
     } else {
Linting src/wp-admin/js/edit-comments.js ...ERROR
[L414:C1] W099: Mixed spaces and tabs.
       replyButton = $('#replybtn', editRow);
Linting src/wp-admin/js/edit-comments.js ...ERROR
[L425:C66] W033: Missing semicolon.
      $('#replyrow').fadeIn(300, function(){ $(this).show() });
Linting src/wp-admin/js/edit-comments.js ...ERROR
[L516:C20] W033: Missing semicolon.
    $(c).hide()
Linting src/wp-admin/js/edit-comments.js ...ERROR
[L575:C14] W033: Missing semicolon.
      }
Linting src/wp-admin/js/edit-comments.js ...ERROR
[L593:C14] W033: Missing semicolon.
      }
Linting src/wp-admin/js/edit-comments.js ...ERROR
[L6:C1] W117: 'setCommentsList' is not defined.
setCommentsList = function() {
Linting src/wp-admin/js/edit-comments.js ...ERROR
[L22:C34] W117: 'adminCommentsL10n' is not defined.
        replyButton.text(adminCommentsL10n.replyApprove);
Linting src/wp-admin/js/edit-comments.js ...ERROR
[L27:C34] W117: 'adminCommentsL10n' is not defined.
        replyButton.text(adminCommentsL10n.reply);
Linting src/wp-admin/js/edit-comments.js ...ERROR
[L54:C13] W117: 'note' is not defined.
      note = $('#' + action + '-undo-holder').html();
Linting src/wp-admin/js/edit-comments.js ...ERROR
[L58:C53] W117: 'commentReply' is not defined.
      if ( el.siblings('#replyrow').length && commentReply.cid == id )
Linting src/wp-admin/js/edit-comments.js ...ERROR
[L59:C17] W117: 'commentReply' is not defined.
        commentReply.close();
Linting src/wp-admin/js/edit-comments.js ...ERROR
[L64:C129] W117: 'note' is not defined.
        h = $('<tr id="undo-' + id + '" class="undo un' + action + '" style="display:none;"><td colspan="' + n + '">' + note + '</td></tr>');
Linting src/wp-admin/js/edit-comments.js ...ERROR
[L67:C106] W117: 'note' is not defined.
        h = $('<div id="undo-' + id + '" style="display:none;" class="undo un' + action + '">' + note + '</div>');
Linting src/wp-admin/js/edit-comments.js ...ERROR
[L134:C22] W117: 'thousandsSeparator' is not defined.
        n1 = thousandsSeparator + n.substr(n.length - 3) + n1;
Linting src/wp-admin/js/edit-comments.js ...ERROR
[L216:C17] W117: 'total_items_i18n' is not defined.
        total_items_i18n = settings.parsed.responses[0].supplemental.total_items_i18n || '';
Linting src/wp-admin/js/edit-comments.js ...ERROR
[L217:C22] W117: 'total_items_i18n' is not defined.
        if ( total_items_i18n ) {
Linting src/wp-admin/js/edit-comments.js ...ERROR
[L218:C48] W117: 'total_items_i18n' is not defined.
          $('.displaying-num').text( total_items_i18n );
Linting src/wp-admin/js/edit-comments.js ...ERROR
[L265:C26] W117: 'list_args' is not defined.
      'list_args': list_args,
Linting src/wp-admin/js/edit-comments.js ...ERROR
[L270:C18] W117: 'ajaxurl' is not defined.
      url: ajaxurl,
Linting src/wp-admin/js/edit-comments.js ...ERROR
[L290:C1] W117: 'commentReply' is not defined.
commentReply = {
Linting src/wp-admin/js/edit-comments.js ...ERROR
[L297:C54] W117: 'commentReply' is not defined.
    $('a.cancel', row).click(function() { return commentReply.revert(); });
Linting src/wp-admin/js/edit-comments.js ...ERROR
[L298:C52] W117: 'commentReply' is not defined.
    $('a.save', row).click(function() { return commentReply.send(); });
Linting src/wp-admin/js/edit-comments.js ...ERROR
[L301:C17] W117: 'commentReply' is not defined.
        commentReply.send();
Linting src/wp-admin/js/edit-comments.js ...ERROR
[L309:C13] W117: 'commentReply' is not defined.
      commentReply.toggle($(this).parent());
Linting src/wp-admin/js/edit-comments.js ...ERROR
[L314:C17] W117: 'commentReply' is not defined.
        commentReply.close();
Linting src/wp-admin/js/edit-comments.js ...ERROR
[L327:C17] W117: 'commentReply' is not defined.
        commentReply.toggle($(this).parent());
Linting src/wp-admin/js/edit-comments.js ...ERROR
[L343:C13] W117: 'commentReply' is not defined.
      commentReply.close();
Linting src/wp-admin/js/edit-comments.js ...ERROR
[L363:C13] W117: 'QTags' is not defined.
      QTags.closeAllTags('replycontent');
Linting src/wp-admin/js/edit-comments.js ...ERROR
[L420:C34] W117: 'adminCommentsL10n' is not defined.
        replyButton.text(adminCommentsL10n.replyApprove);
Linting src/wp-admin/js/edit-comments.js ...ERROR
[L422:C34] W117: 'adminCommentsL10n' is not defined.
        replyButton.text(adminCommentsL10n.reply);
Linting src/wp-admin/js/edit-comments.js ...ERROR
[L434:C59] W117: 'self' is not defined.
      vp = document.documentElement.clientHeight || self.innerHeight || 0;
Linting src/wp-admin/js/edit-comments.js ...ERROR
[L444:C21] W117: 'commentReply' is not defined.
          commentReply.revert(); // close on Escape
Linting src/wp-admin/js/edit-comments.js ...ERROR
[L472:C19] W117: 'ajaxurl' is not defined.
      url : ajaxurl,
Linting src/wp-admin/js/edit-comments.js ...ERROR
[L474:C37] W117: 'commentReply' is not defined.
      success : function(x) { commentReply.show(x); },
Linting src/wp-admin/js/edit-comments.js ...ERROR
[L475:C35] W117: 'commentReply' is not defined.
      error : function(r) { commentReply.error(r); }
Linting src/wp-admin/js/edit-comments.js ...ERROR
[L489:C13] W117: 'wpAjax' is not defined.
    r = wpAjax.parseAjaxResponse(xml);
Linting src/wp-admin/js/edit-comments.js ...ERROR
[L491:C38] W117: 'wpAjax' is not defined.
      t.error({'responseText': wpAjax.broken});
Linting src/wp-admin/js/edit-comments.js ...ERROR
[L562:C5] W117: 'setCommentsList' is not defined.
  setCommentsList();
Linting src/wp-admin/js/edit-comments.js ...ERROR
[L563:C5] W117: 'commentReply' is not defined.
  commentReply.init();
Linting src/wp-admin/js/edit-comments.js ...ERROR
[L602:C32] W117: 'adminCommentsL10n' is not defined.
      { highlight_first: adminCommentsL10n.hotkeys_highlight_first, highlight_last: adminCommentsL10n.hotkeys_highlight_last,
Linting src/wp-admin/js/edit-comments.js ...ERROR
[L602:C91] W117: 'adminCommentsL10n' is not defined.
      { highlight_first: adminCommentsL10n.hotkeys_highlight_first, highlight_last: adminCommentsL10n.hotkeys_highlight_last,
Linting src/wp-admin/js/edit-comments.js ...ERROR
>> Too many errors. (98% scanned).

Attachments (3)

25979.diff (5.5 KB) - added by adamsilverstein 5 months ago.
25979.2.diff (5.9 KB) - added by adamsilverstein 5 months ago.
25979.2.2.diff (5.9 KB) - added by adamsilverstein 5 months ago.

Download all attachments as: .zip

Change History (10)

adamsilverstein5 months ago

comment:1 adamsilverstein5 months ago

25979.diff​ notes:

  • verified self actually set @L434 in debugger, added as global
  • verified all globals listed valid: passed via php directly or using wp_localize_script (all present on page) except QTags, set in quicktags.js

comment:2 nacin5 months ago

  • Owner set to nacin
  • Resolution set to fixed
  • Status changed from new to closed

In 26156:

Avoid jshint errors in edit-comment.js.

props adamsilverstein.
fixes #25979.

comment:3 nacin5 months ago

Per IRC — self could become window there.

adamsilverstein5 months ago

adamsilverstein5 months ago

comment:4 nacin5 months ago

In 26157:

JSHint: Make commentReply a declared global from elsewhere.

props adamsilverstein.
see #25979, [26156].

comment:5 nacin5 months ago

  • Milestone changed from Awaiting Review to 3.8

comment:6 nacin5 months ago

In 26208:

Residual JSHint fixes in common.js and edit-comments.js.

see #25912, #25979.

comment:7 SergeyBiryukov5 months ago

#25617 was marked as a duplicate.

Note: See TracTickets for help on using tickets.