Follow-up of #1664940: [Policy, patch] Decide on JSHint configuration and part of #1415788: Javascript winter clean-up
Run jshint on the files with the configuration from the parent issue or use jshint.com with the following options:
/*jshint forin:true, noarg:true, eqeqeq:true, undef:true, curly:true, browser:true, expr:true, latedef:true, newcap:true, trailing:true */
/*global Drupal, jQuery */
Fix any warnings or errors the tool finds.
Check manually that the fixes did not break any functionalities
Create patch and upload for the testbot.
Files: drupal.js
Comments
Comment #1
nod_Comment #2
nod_Comment #3
droplet commentedIt works fine. It can have a better description or comment out to avoid JSHint warning
Comment #4
nod_You just need to remove the
case '%':line, this is what's called fall through and that's not needed here.Comment #5
nod_Comment #6
droplet commentedComment #8
droplet commentedSeems like a random string test fails.
Comment #9
droplet commentedComment #10
droplet commented#5: core-js-jshint-drupal.patch queued for re-testing.
Comment #11
catchCommitted/pushed to 8.x, thanks.
Comment #13
nod_Comment #14
foopang commentedI'm not sure how it should be fixed, but I wanna give it a try. Please review the patch attached.
Comment #15
droplet commentedRedefinition ??
Comment #16
jelle_sI think this has to do with the configuration (#1664940: [Policy, patch] Decide on JSHint configuration). I'm not sure if you can use a different config for just one file, but it seems that, because we define
Drupalas 'predefined', jsHint isn't happy when we "redefine" it.For more background info see http://jslinterrors.com/redefinition-of-a/
Not sure if the patch in #14 is the correct way to deal with it...
Comment #17
nod_doesn't seem like there is much we can do about that for now.
Patch makes the error go away as per Jelle_S link's instructions. Not sure that's the best option though.
Comment #18
droplet commentedahh. never know it
export Drupal to window it seems to be a better approach. ( window.Drupal === Drupal // TRUE )
Comment #19
nod_New version of jshint (2.0) allows for warnings to be turned on and off, this patch works.
Comment #20
nod_Comment #21
alexpottThe problem is we have to say we need the latest and greatest jshint... otherwise you get
And this warning is then suppressed...
So is there anyway to declare / document the dependency on jshint > 2.0.0 in the .jshint file?
Comment #22
nod_Since the .jshintrc file is a JSON file we can't comment it. I've looked around and there isn't another way to restrict jshint version.
I updated the doc page saying the latest stable version of JSHint should be used: http://drupal.org/node/1972428 (and updated the config changes from #1995996: Update JSHint configuration as well as the change notice: http://drupal.org/node/1972428).
But all that doesn't matter, droplet had the solution in #18. Updated patch that doesn't need special comments or a specific version of jshint.
Comment #24
nod_Let's pretend that never happened :)
Comment #25
nod_Comment #26
alexpott#22: core-jshint-drupal-1684800-22.patch queued for re-testing.
Comment #27
alexpottCommitted c785642 and pushed to 8.x. Thanks!