Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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: system/system.cron.js, system/system.js
Comment | File | Size | Author |
---|---|---|---|
#16 | core_js-jshint_system-1684872-16.patch | 3.08 KB | pascalduez |
#8 | 1684872_system-jshint_8.patch | 3.09 KB | frega |
#6 | system-jshint.patch | 3.05 KB | droplet |
#5 | system-jshint.patch | 3.19 KB | droplet |
#3 | system-jshint.patch | 3.1 KB | droplet |
Comments
Comment #1
nod_Comment #2
nod_removed first half of the warnings.
Comment #3
droplet CreditAttribution: droplet commentedComment #4
nod_there is an issue with fieldSettings it's not going to work out like you think. When learning JS that's actually the typical case where you'll first encounter closures.
dateTimeHnalder needs to get the fieldSettings, source, suffix as parameters and return a function. I might get some time to reroll the patch tomorrow to show what I mean.
Comment #5
droplet CreditAttribution: droplet commentedComment #6
droplet CreditAttribution: droplet commentedremove unused var.
Comment #7
nod_the blur thing won't work, custom data needs to be sent with the event binding.
Comment #8
frega CreditAttribution: frega commentedFixed lacking custom data. jshint passes.
Note: further improvement as copyFieldValue "targetIds" is always (i.e. the *one* time it's used: drupal_add_js(array('copyFieldValue' => array('edit-site-mail' => array('edit-account-mail'))), 'setting');)
Then we could replace "for (var delta in targetIds)" in the code (assuming looping over properties of an object) with a "proper" iteration of an array.
Comment #9
nod_Looks good to me, needs someone else to review :) I touched the patch too.
Comment #11
nod_#8: 1684872_system-jshint_8.patch queued for re-testing.
Comment #12
pivica CreditAttribution: pivica commentedRelated to https://drupal.org/node/492720#comment-6376408, we should merge this two patches.
Comment #13
pascalduez CreditAttribution: pascalduez commentedReviewed, tested. Looks good to me.
on line 46
$('#' + sourceId, context)
should maybe be converted to
$(context).find('#' + sourceId)
.bind('blur'
should maybe be converted to
.on('blur'
on line 64
.keyup(function ()
should maybe be converted to
.on('keyup', function()
Comment #14
pascalduez CreditAttribution: pascalduez commentedComment #15
nod_actually,
$('#' + sourceId)
would be better.The .on change should be handled in the other issue.
Comment #16
pascalduez CreditAttribution: pascalduez commented$('#' + sourceId, context)
converted to$('#' + sourceId)
.Comment #17
pivica CreditAttribution: pivica commentedPatch http://drupal.org/files/refactoring-system.js-492720.patch from #492720: Refactor system.js file and use Drupal form states and form ajax removes most of current js code from system.js, so most of this patch will not be needed. If you can please review that patch also because it is affecting this issue.
Comment #18
nod_let's wait for the split up issue to get in and check back afterwards with jshint
Comment #19
nod_