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

Global return error #148

Closed
dcousens opened this issue May 30, 2015 · 13 comments

Comments

@dcousens
Copy link
Member

commented May 30, 2015

Despite globalReturn being true, I still get Illegal return statement when I use return in a self-contained translation unit (file/module).

return

Isn't this behaviour is meant to be allowed?

@feross

This comment has been minimized.

Copy link
Member

commented May 30, 2015

Yes, this is meant to be allowed.

@feross

This comment has been minimized.

Copy link
Member

commented May 30, 2015

I found the issue with git bisect. Bug in eslint. Issue reported: eslint/eslint#2636

I'm going to just remove support for ES6 modules until this is fixed, since it's marked "experimental" in eslint. If people really want ES6 modules, they can use a custom parser like babel-eslint (now supported).

feross added a commit to standard/eslint-config-standard that referenced this issue May 30, 2015

remove experimental "modules" support
This was causing a bug: standard/standard#148

It's really an eslint bug: eslint/eslint#2636

I'm going to just remove support for ES6 modules until this is fixed,
since it's marked "experimental" in eslint. If people really want ES6
modules, they can use a custom parser like babel-eslint (now supported).
@feross

This comment has been minimized.

Copy link
Member

commented May 30, 2015

Hm, actually removing support for modules is likely to be more disruptive than just leaving this bug in there. It's been around since 3.0.0.

@feross feross added the blocked label May 30, 2015

@feross

This comment has been minimized.

Copy link
Member

commented May 30, 2015

@dcousens

This comment has been minimized.

Copy link
Member Author

commented May 30, 2015

I'm happy to wait for this to be fixed in eslint, this is an edge case to begin with anyway.

@feross

This comment has been minimized.

Copy link
Member

commented May 30, 2015

@dcousens cool, sounds good

@feross

This comment has been minimized.

Copy link
Member

commented Jun 1, 2015

ESLint says this is working as intended:

Modules can't be wrapped in function scope, so a global return isn't possible.

@dcousens Open to suggestions about how to proceed.

@dcousens

This comment has been minimized.

Copy link
Member Author

commented Jun 2, 2015

@feross well if it isn't possible, I say we stay entirely agnostic and set globalReturn to false?

At least then it will be consistent across development environments (node, browserify or otherwise).

IMHO anyway.

@Cuel

This comment has been minimized.

Copy link

commented Jun 2, 2015

What if I in index.js wanted to do like this

return console.error('missing parameter')

As in I'd like to exit without throwing an error. It woudn't be allowed in standard?

@dcousens

This comment has been minimized.

Copy link
Member Author

commented Jun 2, 2015

@Cuel more to the point, it isn't allowed in eslint, due to a broad definition of module AFAIK.

@feross

This comment has been minimized.

Copy link
Member

commented Jun 6, 2015

@Cuel @dcousens I left a comment asking for more clever behavior from eslint here: eslint/eslint#2636 (comment) Feel free to support / share your opinion.

@dcousens

This comment has been minimized.

Copy link
Member Author

commented Jun 6, 2015

@feross ES6 makes this difficult.

Perhaps we should just change globalReturn: false?
This is only going to become more annoying as time goes on, and that does seem to be the current behaviour so it isn't a breaking change.

@feross

This comment has been minimized.

Copy link
Member

commented Jun 7, 2015

Agreed.

@lock lock bot locked as resolved and limited conversation to collaborators May 11, 2018

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
3 participants
You can’t perform that action at this time.