question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Future of ecmaFeatures.globalReturn

See original GitHub issue

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:

  1. We could remove ecmaFeatures.globalReturn altogether. I think this is the cleanest solution now that we have sourceType: commonjs, however, we would probably want to throw an error if ecmaFeatures.globalReturn is specified to let people know that it has been removed.
  2. We could keep ecmaFeatures.globalReturn but throw an error if it is used with sourceType: 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:open
  • Created 2 years ago
  • Reactions:1
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
btmillscommented, Dec 31, 2021

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.

1reaction
nzakascommented, Jun 1, 2022

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found