0

I just started to use jslint with backbone. At the beginning of project I create object:

 App = {
  Models: {},
  Views: {},
  Controller: {}
 }

and get error:" 'App' was used before it was defined." Then later I use it as:

 App.Models.Task = Backbone.Model.extend({})

and at this point jslint can't pass me through. it says

unexpected 'App'. App.Models.Task = Backbone.Model.extend({}) // Line 17, Pos 1 #8 Stopping. (7% scanned).

I've read that probably jslint sees it as critical error because it stopped but it is not an error. what should I do?

1 Answer 1

0

It should be var App (or window.App, depending on your goals; but, in my opinion, even global variables are better defined as local ones first, then exported into outer space within a single statement). Otherwise JSLint (quite rightly) thinks that you just forgot to define this variable in some other place OR made a typo in its name.

3
  • it helps only to solve first error after adding var or window i still get error: unexpected 'App'. App.Models.Task = Backbone.Model.extend({})
    – Kriss
    Feb 5, 2013 at 11:23
  • Can you show the whole code then (at least, lines preceding the one with 'App.Models.Task'? These two lines by themselves are Ok with JSLint.
    – raina77ow
    Feb 5, 2013 at 11:23
  • Ok the problem was line before - i forgot to add ; after }. Thanks a lot.
    – Kriss
    Feb 5, 2013 at 11:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.