Skip to:
Content

bbPress.org

Opened 5 years ago

Closed 5 years ago

#2578 closed defect (fixed)

Grunt task `grunt jshint` should complete without error

Reported by: netweb Owned by: netweb
Milestone: 2.6 Priority: normal
Severity: normal Version: trunk
Component: Tools - Code Improvements Keywords:
Cc:

Attachments (1)

2578.diff (397 bytes) - added by netweb 5 years ago.

Download all attachments as: .zip

Change History (7)

#1 @johnjamesjacoby
5 years ago

In 5334:

Improve output of grunt jshint task. See #2578.

#2 @johnjamesjacoby
5 years ago

The remaining 18 errors will be difficult to solve, since they reference variables created by WordPress dependencies or API's, that we shouldn't be trying to shim or stub for the sake of passing jshint.

Running "jshint:grunt" (jshint) task
>> 1 file lint free.

Running "jshint:core" (jshint) task

   src/includes/admin/js/common.js
      5 |    bbp_author_id.suggest( ajaxurl + '?action=bbp_suggest_user', {
                                    ^ 'ajaxurl' is not defined.
   src/includes/admin/js/replies.js
      5 |    bbp_topic_id.suggest( ajaxurl + '?action=bbp_suggest_topic', {
                                   ^ 'ajaxurl' is not defined.
   src/templates/default/js/editor.js
      5 |        edButtons[110] = new QTags.TagButton( 'code', 'code', '`', '`', 'c' );
                 ^ 'edButtons' is not defined.
      5 |        edButtons[110] = new QTags.TagButton( 'code', 'code', '`', '`', 'c' );
                                      ^ 'QTags' is not defined.
      6 |        QTags._buttonsInit();
                 ^ 'QTags' is not defined.
     17 |                if ( ! tinymce.activeEditor.isHidden() ) {
                                ^ 'tinymce' is not defined.
     18 |                    var editor = tinymce.activeEditor.editorContainer;
                                          ^ 'tinymce' is not defined.
     39 |                if ( ! tinymce.activeEditor.isHidden() ) {
                                ^ 'tinymce' is not defined.
     40 |                    var editor = tinymce.activeEditor.editorContainer;
                                          ^ 'tinymce' is not defined.
   src/templates/default/js/forum.js
     10 |        $.post( bbpForumJS.bbp_ajaxurl, $data, function ( response ) {
                         ^ 'bbpForumJS' is not defined.
     15 |                    response.content = bbpForumJS.generic_ajax_error;
                                                ^ 'bbpForumJS' is not defined.
     24 |        bbp_ajax_call( 'forum_subscription', $( this ).attr( 'data-forum' ), bbpForumJS.subs_nonce, '#subscription-toggle' );
                                                                                      ^ 'bbpForumJS' is not defined.
   src/templates/default/js/reply.js
      1 |addReply = {
         ^ 'addReply' is not defined.
     27 |            var t = addReply, temp = t.I('bbp-temp-form-div'), respond = t.I(t.respondId);
                             ^ 'addReply' is not defined.
   src/templates/default/js/topic.js
     10 |        $.post( bbpTopicJS.bbp_ajaxurl, $data, function ( response ) {
                         ^ 'bbpTopicJS' is not defined.
     15 |                    response.content = bbpTopicJS.generic_ajax_error;
                                                ^ 'bbpTopicJS' is not defined.
     24 |        bbp_ajax_call( 'favorite', $( this ).attr( 'data-topic' ), bbpTopicJS.fav_nonce, '#favorite-toggle' );
                                                                            ^ 'bbpTopicJS' is not defined.
     29 |        bbp_ajax_call( 'subscription', $( this ).attr( 'data-topic' ), bbpTopicJS.subs_nonce, '#subscription-toggle' );
                                                                                ^ 'bbpTopicJS' is not defined.

>> 18 errors in 8 files

@netweb
5 years ago

#3 @netweb
5 years ago

In 2578.diff modify our .jshintrc to not check for undefined variables.
Ref http://jshint.com/docs/options/#undef

We can either do the above which now results in grunt jshint passing without error.

The other option per the docs above is to use the /*global ... */ directive to tell JSHint about it.

I'm not really sure which method we should use and the ramifications of each method.

I will learn Javascript one of these days...

This ticket was mentioned in IRC in #bbpress-dev by netweb. View the logs.


5 years ago

#5 @johnjamesjacoby
5 years ago

Global directives are fine, as that's what's currently causing the errors.

Patch also looks good. Feel free to commit at your convenience!

#6 @netweb
5 years ago

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

In 5336:

In .jshintrc ignore undefined variables so grunt jshint task completes without error.
(reference variables created by WordPress dependencies or API's)

  • Props netweb. Fixes #2578
Note: See TracTickets for help on using tickets.