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

Parse errors with ES6 export {} declaration #2567

Closed
gustavderdrache opened this issue Jul 19, 2015 · 7 comments · May be fixed by ajesse11x/cjdns#1 or ajesse11x/amplify-js#5
Closed

Parse errors with ES6 export {} declaration #2567

gustavderdrache opened this issue Jul 19, 2015 · 7 comments · May be fixed by ajesse11x/cjdns#1 or ajesse11x/amplify-js#5

Comments

@gustavderdrache
Copy link

Both of these lines cause an error about an expected identifier, but the grammar indicates they should be allowed:

/* jshint esnext:true */

export {};
export {x,};
@nicolo-ribaudo
Copy link
Contributor

I think JSHint should warn at line 3: it is valid, but it is probably a mistake.

@lukeapage
Copy link
Member

I think you could argue that both are possibly mistakes.. the 2nd case could be covered by elision but then possibly so should

/* jshint elision: false */
var [a,] = [a];
var {x,} = a;

neither of which give warnings.

@lukeapage
Copy link
Member

you could argue that both are possibly mistakes.

(but to clarify they shouldn't error, they should possibly warn)

nicolo-ribaudo added a commit to nicolo-ribaudo/jshint that referenced this issue Jul 19, 2015
Now JSHint correctly parses this code:
  import { a, } from "source";
  export { a, };
  export {};
but warns `Empty export.` at line 3

This commit fixes jshint#2567
nicolo-ribaudo added a commit to nicolo-ribaudo/jshint that referenced this issue Jul 19, 2015
Now JSHint correctly parses this code:
  import { a, } from "source";
  export { a, };
  export {};
but warns `Empty export.` at line 3

This commit fixes jshint#2567
nicolo-ribaudo added a commit to nicolo-ribaudo/jshint that referenced this issue Jul 20, 2015
Now JSHint correctly parses this code:
  export { a, };
  export {};
but warns `Empty export.` at line 2

This commit fixes jshint#2567
@nicolo-ribaudo
Copy link
Contributor

the 2nd case could be covered by elision but then possibly so should

JSHint doesn't warn about trailing commas, as they are ignored. I think this is more JSCS territory.

var a = [ 1, ]; // No warnings
var b = [ 1, , 2]; // Empty array elements require elision=true.

@lukeapage
Copy link
Member

JSHint doesn't warn about trailing commas, as they are ignored. I think this is more JSCS territory.

You're right, it didn't occur to me it could be a style choice.

I agree on a warning for line 3.

@gustavderdrache
Copy link
Author

It'd probably be good to warn on the equivalent import statement, too:

import {} from 'module';

It's more likely that the user messed up since there's the syntax import "module" for including a module only for its side-effects.

@lukeapage
Copy link
Member

@gustavderdrache, @nicolo-ribaudo already did this on the pr ;) but its a breaking change so likely one for v3

nicolo-ribaudo added a commit to nicolo-ribaudo/jshint that referenced this issue Aug 16, 2015
Now JSHint correctly parses this code:
  export { a, };
  export {};
but warns `Empty export.` at line 2

This commit fixes jshint#2567
jugglinmike pushed a commit to jugglinmike/jshint that referenced this issue Sep 17, 2017
Now JSHint correctly parses this code:
  export { a, };
  export {};
but warns `Empty export.` at line 2

This commit fixes jshint#2567
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants