Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.
Sign upusing `return` in the top level of a node.js script #510
Comments
This comment has been minimized.
This comment has been minimized.
|
I thought that this had been the case for a long time. I would recommend using |
This comment has been minimized.
This comment has been minimized.
|
@LinusU if |
This comment has been minimized.
This comment has been minimized.
|
Yes, this has been an issue for a long time. This is an unfortunate side effect of two bad decisions made by TC39:
The decision to have two modes means that every piece of tooling that parses JS has to expose this decision to the user. To keep If we assumed "script" then many more things would not work, so this is the right compromise I think. |
feross
closed this
May 4, 2016
feross
added
the
question
label
May 4, 2016
This comment has been minimized.
This comment has been minimized.
|
could you leave the "module" or "script" mode decision to the user with a The current behaviour prevents me using Standard in test suites or CI as it will always fail when linting my top-level scripts (which typically contain |
This comment has been minimized.
This comment has been minimized.
|
It's an intentional decision to not have modes or options in We'll have to find a better long-term workaround for this. For now, consider not linting the files which contain top-level return. |
75lb commentedMay 4, 2016
using standard v7, trying to validate this node.js script:
throws this issue:
In node.js, the top level script is wrapped by a function. Even though it might look like use of
returnoutside a function, it is not..what to do here? This is a valid use of
return..