Opened 10 years ago
Closed 10 years ago
#2578 closed defect (bug) (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: |
Description
When running the Grunt task grunt jshint
should complete with no errors
- /src/includes/admin/js/common.js
- /src/includes/admin/js/topics.js
- /src/includes/admin/js/replies.js
- /src/templates/default/js/editor.js
- /src/templates/default/js/forum.js
- /src/templates/default/js/topic.js
- /src/templates/default/js/reply.js
- /src/templates/default/js/user.js
Related #2542 - Modernize trunk with Unit Tests, Travis, and Grunt
Attachments (1)
Change History (7)
#2
@
10 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
#3
@
10 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...
In 5334: