Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

esnext: System.import -> Expected an identifier #2120

Closed
piuccio opened this issue Jan 21, 2015 · 7 comments
Closed

esnext: System.import -> Expected an identifier #2120

piuccio opened this issue Jan 21, 2015 · 7 comments

Comments

@piuccio
Copy link

piuccio commented Jan 21, 2015

I'm using jshint 2.5.11 to lint this code

System.import('app/app').then(function (app) {
    app.start();
});

Using

    "esnext"   : true,

And I get the error

^ Expected an identifier and instead saw 'import' (a reserved word).

System JS

@rwaldron
Copy link
Member

Can you share the entire JSHint configuration? JSHint allows ReservedWords as properties by default for ES5+ (ES5 is the default).

@jugglinmike
Copy link
Member

I can't reproduce that here. The following passes in JSHint 2.5.11

/*jshint esnext: true */
'use strict';
System.import('app/app').then(function (app) {
   app.start();
});

I can reproduce that error if I enable es3 instead:

/*jshint esnext: true */
'use strict';
System.import('app/app').then(function (app) {
   app.start();
});

...but that also triggers a warning about the System global (as expected) "line 3, col 1, 'System' is not defined.". It doesn't sound like you're seeing that second warning, though. I can think of a few reasons for this:

  • undef: false
  • globals System: true
  • paradoxically, es3: true, esnext: true

@piuccio
Copy link
Author

piuccio commented Jan 22, 2015

This is my .jshintrc

{
    // http://www.jshint.com/docs/options/

    // Enforcing options
    "bitwise"  : true,
    "curly"    : true,
    "eqeqeq"   : true,
    "es3"      : true,
    "immed"    : true,
    "latedef"  : true,
    "newcap"   : true,
    "noarg"    : true,
    "noempty"  : true,
    "nonew"    : true,
    "quotmark" : "single",
    "unused"   : true,
    "undef"    : true,
    "trailing" : true,

    // Relaxing options
    "expr"     : true,
    "laxbreak" : true,
    "maxerr"   : 100,
    "esnext"   : true,

    // Environments
    "browser"  : true,
    "jquery"   : false,

    "globals"   : {
        "define": false
    }
}

If I remove esnext it complains that System is not defined.

@jugglinmike
Copy link
Member

The problem is that you are using both esnext and es3. If you are writing code for an ECMAScript 6-supporting environment, then the restrictions of an ES3 environment (in this case: reserve words as property names) do not apply. Remove "es3" : true from your RC file and you should be all set!

@rwaldron
Copy link
Member

Should JSHint 3 try to fix things like this?

@jugglinmike
Copy link
Member

@rwaldron I think it's an API design problem that JSHint 3 can avoid altogether: #2124

@rwaldron
Copy link
Member

Awesome.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants