espree
espree copied to clipboard
Future of ecmaFeatures.globalReturn
Problem: globalReturn
can't be used with sourceType:module
, and right now in ESLint we will detect this combination and set globalReturn
to false
. Arguably, this behavior is undesirable because ESLint is silently fixing a problem rather than letting the user know that it happened.
We recently just implemented sourceType: commonjs
, which effectively makes ecmaFeatures.globalReturn
obsolete, so there are several options we could pursue going forward:
- We could remove
ecmaFeatures.globalReturn
altogether. I think this is the cleanest solution now that we havesourceType: commonjs
, however, we would probably want to throw an error ifecmaFeatures.globalReturn
is specified to let people know that it has been removed. - We could keep
ecmaFeatures.globalReturn
but throw an error if it is used withsourceType: module
. This error would bubble up to ESLint and to the user, allowing them to fix their configuration.
In either case, we could remove the logic from ESLint completely.
Thoughts?
Option 1 seems cleanest to me as well. We'd be able to give a very clear and actionable error message: ecmaFeatures.globalReturn
is gone, so you should set sourceType: "commonjs"
instead.
If we are not aware of any use cases for globalReturn = true
other than commonjs modules, then option 1 seems best to me.
Marking as accepted.
I would like to work on this. Is this ready to implement?
Just to confirm my understanding is correct the changes are
- Need to remove gloablReturn completely from espree
- Throw an error when
ecmaFeatures: { globalReturn: true/false }
specified in the options
We aren’t quite ready to implement this yet. We will need to wait for the new config system to roll out and give advance notice before we remove any existing functionality.
Is it good to go now?
Not yet. This will need to happen in the v10.0.0 timeframe, once the old config system has been removed.