Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jshint complains: 'Ember' is not defined

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?

like image 934
blueFast Avatar asked Apr 08 '13 21:04

blueFast


2 Answers

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

like image 84
mavilein Avatar answered Jan 01 '23 04:01

mavilein


If you're using the new ES6, for example from ember-cli, you must import Ember:

import Ember from 'ember';

I was following Evil Trout's Ember Reddit tutorial and saw the following error in the tests:

my-new-app/routes/subreddit.js should pass jshint.
my-new-app/routes/subreddit.js: line 3, col 16, 'Ember' is not defined.

adding the above line to the top of my-new-app/routes/subreddit.js passed the tests.

like image 40
Andy Hayden Avatar answered Jan 01 '23 03:01

Andy Hayden