jshint is throwing an error when defining an angular module (or directive, or factory) as recommended by the Angular style guides (by John Papa or Todd Motto). For example, for a controller like this:
(function () {
'use strict';
angular
.module('myApp')
.controller('myAppCtrl', theController);
function theController() {...}
})();
... jshint throws this error:
'theController' was used before it was defined.
The angular app works perfectly despite these errors. However I don't know why jshint protests...
What am I missing? I wonder if jshint is a good evaluator of the quality of the angular code (despite it is included with popular packages as generator-angular) or it's me that I am doing something wrong (although my app works).
Thanks in advance!
Use the latedef
property and set it to false
. This allows hoisting of functions, which IMO is fine. But still reports hoisting of vars, which is bad IMO