Search code examples
ember.jsember-clijshint

Is it possible to remove the "Expected '{' and instead saw" error from Ember Cli?


I've just started working with Ember cli, and every time I change a file, it spits out JSLint errors found in that file.

This is extremely helpful, except for the fact that it considers the following to be in valid:

var isValidJS = true;

if (isValidJS) console.log("This is totally valid JS");

It responds with this error: Expected '{' and instead saw 'console'

Is there anyway to silence only the errors specific to missing curly braces?


Solution

  • The tool reporting this error is actually JSHint, not JSLint or Ember. JSHint comes standard in Ember CLI project templates and comes with a certain set of rules. From what I can tell, the curly option is causing your current issue. Open up the .jshintrc file in the root of your project and set curly to false (or delete it entirely).

    For what it's worth, I generally remove JSHint completely from my Ember projects. You can either avoid code hinting completely or replace it with the much more configurable eslint.