jshint complains: 'Ember' is not defined

blueFast picture blueFast · Apr 8, 2013 · Viewed 7.9k times · Source

I have a standard Ember main.js file, which starts like this:

this.App = Ember.Application.create({
    LOG_TRANSITIONS: true,
    VERSION: '1.0.0',
    ready: function () {
        console.log('App version: ' + App.VERSION + ' is ready.');
    }
});

Running this through jshint complains about Ember not being defined, which is true for this particular file in the server, during the deployment phase. Because of this, lots of error messages are shown.

Ember is made available in the browser by the script tag in index.html:

<script src="scripts/vendor/ember-1.0.0-rc.2.js"></script>

How can I tell jshint about Ember?

Answer

mavilein picture mavilein · Apr 8, 2013

The following should do it:

/*global Ember */
this.App = Ember.Application.create({
    LOG_TRANSITIONS: true,
    VERSION: '1.0.0',
    ready: function () {
        console.log('App version: ' + App.VERSION + ' is ready.');
    }
});

Found in JS Hint Docs