A small test app is set up like this:
init.js:
//@codekit-prepend "vendor/jquery-1.7.2.js"
//@codekit-prepend "vendor/underscore.js"
//@codekit-prepend "vendor/backbone.js"
// Setup namespace for the app
window.app = window.app || {};
//@codekit-append "models/Ride.js"
Ride.js:
(function() {
window.app.Ride = Backbone.Model.extend({
initialize: function() {
console.log("Ride initialized");
}
});
})();
CodeKit’s JSHint check reports that both Backbone and console are not defined. What am I missing here?
JSHint doesn’t run your code so it doesn’t know about any modules you included in other files. You have to specifically tell it about all global variables you plan to use in
Ride.js. In your case it will be:/*global Backbone */.consoleis disallowed by default because it is not a very good idea to ship your software with filledconsole.logcalls. To remove this warning you can use/*jshint devel:true */.So in the end your file should look like this to pass JSHint check:
More info here: http://www.jshint.com/options/