Skip to content

Global return error #148

Closed
Closed

Description

@dcousens

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?

Activity

  1. feross commented on May 30, 2015

    @feross
    Member

    Yes, this is meant to be allowed.

  2. feross commented on May 30, 2015

    @feross
    Member

    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).

  3. added a commit that references this issue on May 30, 2015
  4. feross commented on May 30, 2015

    @feross
    Member

    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.

  5. feross commented on May 30, 2015

    @feross
    Member
  6. dcousens commented on May 30, 2015

    @dcousens
    MemberAuthor

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

  7. feross commented on May 30, 2015

    @feross
    Member

    @dcousens cool, sounds good

  8. feross commented on Jun 1, 2015

    @feross
    Member

    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.

  9. dcousens commented on Jun 2, 2015

    @dcousens
    MemberAuthor

    @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.

  10. Cuel commented on Jun 2, 2015

    @Cuel

    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?

  11. dcousens commented on Jun 2, 2015

    @dcousens
    MemberAuthor

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

  12. feross commented on Jun 6, 2015

    @feross
    Member

    @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.

  13. dcousens commented on Jun 6, 2015

    @dcousens
    MemberAuthor

    @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.

  14. feross commented on Jun 7, 2015

    @feross
    Member

    Agreed.

  15. locked as resolved and limited conversation to collaborators on May 11, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions