JSHint can be used to check JavaScript for errors and potential problems. It can be installed on a variety of platforms and integrated into various editors: http://www.jshint.com/platforms/ I propose that we use JSHint with default settings as a set of coding guidelines for JavaScript in Koha, and that patches correcting errors be attached to this omnibus bug. Some typical JSHint errors for example: js/additem.js: line 3, col 52, Missing radix parameter. js/additem.js: line 5, col 41, Use '!==' to compare with '0'. js/additem.js: line 68, col 25, Use '===' to compare with 'undefined'. js/additem.js: line 122, col 58, Missing semicolon. js/additem.js: line 206, col 21, Bad line breaking before '+'.
Created attachment 14145 [details] [review] Bug 9284 - JavaScript should follow rules recommended by JSHint Coding style corrections to members.js: - Mixed tab/space indentation converted to spaces. - Converted "!=" and "==" to "!==" and "===" for comparisons with ''. - Adding missing semicolons. To test, create or edit a patron and confirm that validation hasn't been broken by the changes to members.js: Invalid date, empty required fields, guarantor popup, restricted-until field display, etc. http://bugs.koha-community.org/show_bug.cgi?id=9281
Created attachment 14249 [details] [review] Bug 9284 - JavaScript should follow rules recommended by JSHint Coding style corrections to members.js: - Mixed tab/space indentation converted to spaces. - Converted "!=" and "==" to "!==" and "===" for comparisons with ''. - Adding missing semicolons. To test, create or edit a patron and confirm that validation hasn't been broken by the changes to members.js: Invalid date, empty required fields, guarantor popup, restricted-until field display, etc. http://bugs.koha-community.org/show_bug.cgi?id=9281 Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
QA Comments: This patch only changes 7 lines substituting the js comparison operators (!= with !== and == with ===) in the members.js file. No behaviour changed. Marked as Passed QA.
Created attachment 14260 [details] [review] Bug 9284 - JavaScript should follow rules recommended by JSHint Coding style corrections to members.js: - Mixed tab/space indentation converted to spaces. - Converted "!=" and "==" to "!==" and "===" for comparisons with ''. - Adding missing semicolons. To test, create or edit a patron and confirm that validation hasn't been broken by the changes to members.js: Invalid date, empty required fields, guarantor popup, restricted-until field display, etc. http://bugs.koha-community.org/show_bug.cgi?id=9281 Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com>
This patch has been pushed to master.
Pushed to 3.8.x and 3.10.x will be in 3.8.9 and 3.10.2