Bug 9284 - JavaScript should conform to coding guidelines recommended by JSHint
Summary: JavaScript should conform to coding guidelines recommended by JSHint
Status: CLOSED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: Templates (show other bugs)
Version: master
Hardware: All All
: P5 - low normal (vote)
Assignee: Owen Leonard
QA Contact: Jonathan Druart
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-12-13 20:54 UTC by Owen Leonard
Modified: 2014-05-26 21:04 UTC (History)
3 users (show)

See Also:
Change sponsored?: ---
Patch complexity: Trivial patch
Who signed the patch off:
Text to go in the release notes:
Version(s) released in:


Attachments
Bug 9284 - JavaScript should follow rules recommended by JSHint (9.46 KB, patch)
2012-12-14 16:46 UTC, Owen Leonard
Details | Diff | Splinter Review
Bug 9284 - JavaScript should follow rules recommended by JSHint (9.48 KB, patch)
2012-12-21 16:59 UTC, Kyle M Hall
Details | Diff | Splinter Review
Bug 9284 - JavaScript should follow rules recommended by JSHint (9.54 KB, patch)
2012-12-26 10:40 UTC, Jonathan Druart
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Owen Leonard 2012-12-13 20:54:56 UTC
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 '+'.
Comment 1 Owen Leonard 2012-12-14 16:46:28 UTC Comment hidden (obsolete)
Comment 2 Kyle M Hall 2012-12-21 16:59:46 UTC Comment hidden (obsolete)
Comment 3 Jonathan Druart 2012-12-26 10:40:07 UTC
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.
Comment 4 Jonathan Druart 2012-12-26 10:40:41 UTC
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>
Comment 5 Jared Camins-Esakov 2012-12-28 00:02:42 UTC
This patch has been pushed to master.
Comment 6 Chris Cormack 2013-01-01 18:20:08 UTC
Pushed to 3.8.x and 3.10.x will be in 3.8.9 and 3.10.2