[wp-trac] [WordPress Trac] #33021: Global javascript variables incorrectly defined

WordPress Trac noreply at wordpress.org
Fri Jul 17 23:21:25 UTC 2015


#33021: Global javascript variables incorrectly defined
------------------------------+------------------------------
 Reporter:  johnjamesjacoby   |       Owner:
     Type:  defect (bug)      |      Status:  new
 Priority:  normal            |   Milestone:  Awaiting Review
Component:  Build/Test Tools  |     Version:
 Severity:  normal            |  Resolution:
 Keywords:  has-patch         |     Focuses:  javascript
------------------------------+------------------------------

Comment (by johnjamesjacoby):

 According to the JSLint documentation, [http://jslint.com/help.html#global
 global] is actually the correct term to use in the context of the `.js`
 files themselves, where as `globals` is what's expected in JSHint's
 `.jshintrc` file itself.

 As far as `_` and `Backbone`, you are correct that both are declared in
 `.jshintrc`, but I think they need declaring in the files they are used
 independently so IDE's can parse them appropriately. See also the many
 places where `jQuery`, `wp`, and others are redeclared in other `.js`
 files.

 I don't think either of us are wrong, just that you're pointing to one
 reference for solving the automated testing JSHint performs, and I'm
 pointing to another reference for assisting developers who are writing
 code in IDEs with built in JSLint support (PHPStorm, Netbeans, etc...)

 See also the [https://make.wordpress.org/core/handbook/best-practices
 /coding-standards/javascript/#globals WordPress core handbook] page on
 Javascript coding standards and defining globals, where `global` is the
 suggested and recommended keyword for this purpose.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/33021#comment:3>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list