Future of ecmaFeatures.globalReturn
See original GitHub issueProblem: 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?
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:5 (5 by maintainers)
Top Results From Across the Web
Issues · eslint/espree - GitHub
Future of ecmaFeatures.globalReturn accepted breaking enhancement. #525 opened on Nov 29, 2021 by nzakas.
Read more >Language Options - ESLint - Pluggable JavaScript Linter
ecmaFeatures - an object indicating which additional language features you'd like to use: globalReturn - allow return statements in the global scope ......
Read more >Configuring ESLint - ESLint - Pluggable JavaScript linter
ecmaFeatures - an object indicating which additional language features you'd like to use: globalReturn - allow return statements in the global scope ......
Read more >astro-eslint-parser - npm
Astro component parser for ESLint. Latest version: 0.9.0, last published: 7 days ago. Start using astro-eslint-parser in your project by ...
Read more >IaC for vRealize: Documenting Code with JSDoc and Syntax ...
“ecmaVersion”: 5, “ecmaFeatures”: { “globalReturn”: true } ... Do you plan to write about defining globals in a future post?
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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 setsourceType: "commonjs"
instead.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.