Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Support for Top-level await #14632

Closed
7 tasks done
NemoStein opened this issue May 25, 2021 · 19 comments · Fixed by #14591
Closed
7 tasks done

Add Support for Top-level await #14632

NemoStein opened this issue May 25, 2021 · 19 comments · Fixed by #14591
Labels
accepted There is consensus among the team that this change meets the criteria for inclusion core Relates to ESLint's core APIs and features enhancement This change enhances an existing feature of ESLint new syntax This issue is related to new syntax that has reached stage 4

Comments

@NemoStein
Copy link

NemoStein commented May 25, 2021

Today Top-level await reached Stage 4.
This brings new depth to async modules, and I'm looking forward to seeing it implemented in ESLint in the near future.

@NemoStein NemoStein added core Relates to ESLint's core APIs and features enhancement This change enhances an existing feature of ESLint triage An ESLint team member will look at this issue soon labels May 25, 2021
@eslint-github-bot eslint-github-bot bot added this to Needs Triage in Triage May 25, 2021
@janosh
Copy link

janosh commented May 25, 2021

For reference, the relevant comment in the tc39 proposal.

@ljharb
Copy link
Sponsor Contributor

ljharb commented May 25, 2021

(The canonical source of truth is here: tc39/proposals@99fa42a)

@aladdin-add aladdin-add added accepted There is consensus among the team that this change meets the criteria for inclusion new syntax This issue is related to new syntax that has reached stage 4 and removed triage An ESLint team member will look at this issue soon labels May 26, 2021
@aladdin-add aladdin-add pinned this issue May 26, 2021
@nzakas nzakas moved this from Needs Triage to Ready to Implement in Triage May 28, 2021
@nzakas
Copy link
Member

nzakas commented May 28, 2021

Thanks for opening this. We can definitely start implanting it and would love some help to get started.

@ota-meshi
Copy link
Member

I opened a pull request in acorn.
acornjs/acorn#1040

@Nantris
Copy link

Nantris commented Jun 1, 2021

Related (but old and outdated) #13178

@nimit2801
Copy link

What is the status of this feature, I want to use eslint with my project and want a way to wave of the error?
Can someone suggest to me what should I do from the following

1. Add rules or something to ignore this error if yes any examples
2. If this is supported what things should I mention in `.eslintrc.json` to use this feature

Question: what version of ecma does top-level await joins in?
Thank You

@saschanaz
Copy link
Contributor

Probably blocked by #14591?

@nzakas
Copy link
Member

nzakas commented Jul 28, 2021

Yup. Support will be released in v8.0.0. We are finishing up that work now.

@nzakas nzakas moved this from Pull Request Opened to Planned in v8.0.0 Jul 28, 2021
@ktx-mega
Copy link

Do you have an idea of the release date ?

@nzakas nzakas linked a pull request Jul 29, 2021 that will close this issue
8 tasks
@nzakas nzakas moved this from Planned to Ready for Merge in v8.0.0 Jul 29, 2021
@nzakas
Copy link
Member

nzakas commented Jul 30, 2021

Nothing firm. We will likely release a beta within the next two weeks and the final version will depend on the feedback we get during the beta.

Public Roadmap automation moved this from In Progress to Complete Aug 5, 2021
Triage automation moved this from Ready to Implement to Complete Aug 5, 2021
v8.0.0 automation moved this from Ready for Merge to Done Aug 5, 2021
@joshunger
Copy link

joshunger commented Aug 30, 2021

Happy afternoon (or morning)! Will this fix Parsing error: Can not use keyword 'await' outside an async function and what specific 8.0 beta version? I just tried v8.0.0-beta.1 with an mjs file and it did not work. Thanks.

@nzakas
Copy link
Member

nzakas commented Aug 31, 2021

@joshunger it should. Be sure you have ecmaVersion set to 2022 and sourceType set to module. If you’re still having trouble, please stop by the chat.

@joshunger
Copy link

@nzakas thanks for the help I missed the ecmaVersion. It is working great!

@AndreiSoroka
Copy link

Hi!

> eslint . --ext .mjs --fix


Oops! Something went wrong! :(

ESLint: 8.0.0-beta.1

Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './lib/util/glob-util' is not defined by "exports" in /Users/andreisoroka/git/other/faststartservice/node_modules/eslint/package.json
    at throwExportsNotFound (internal/modules/esm/resolve.js:285:9)
    at packageExportsResolve (internal/modules/esm/resolve.js:508:3)
    at resolveExports (internal/modules/cjs/loader.js:450:36)
    at Function.Module._findPath (internal/modules/cjs/loader.js:490:31)
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:888:27)
    at Function.Module._load (internal/modules/cjs/loader.js:746:27)
    at Module.require (internal/modules/cjs/loader.js:974:19)
    at require (/Users/andreisoroka/git/other/faststartservice/node_modules/v8-compile-cache/v8-compile-cache.js:159:20)
    at Object.<anonymous> (/Users/andreisoroka/git/other/faststartservice/node_modules/eslint-plugin-import/lib/rules/no-unused-modules.js:43:34)
    at Module._compile (/Users/andreisoroka/git/other/faststartservice/node_modules/v8-compile-cache/v8-compile-cache.js:192:30)
npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! fuststartservice@0.0.0 lint:fix: `eslint . --ext .mjs --fix`
npm ERR! Exit status 2
npm ERR! 
npm ERR! Failed at the fuststartservice@0.0.0 lint:fix script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

package.json

{
  "scripts": {
    "lint": "eslint . --ext .mjs",
    "lint:fix": "eslint . --ext .mjs --fix"
  },
  "devDependencies": {
    // "eslint": "^7.32.0", // was
    "eslint": "^8.0.0-beta.1",
    "eslint-config-airbnb-base": "^14.2.1",
    "eslint-plugin-import": "^2.24.2"
  }
}
{
  "env": {
    // "es2021": true, (and with 2021 don't work)
    "es2022": true,
    "node": true
  },
  "extends": [
    "airbnb-base"
  ],
  "parserOptions": {
    // "ecmaVersion": 12, // was
    "ecmaVersion": 2022,
    "sourceType": "module"
  },
  "settings": {
    "import/resolver": {
      "node": {
        "extensions": [
          ".js",
          ".mjs"
        ]
      }
    }
  },
  "rules": {
    "no-console": "off",
    "no-underscore-dangle": "off",
    "import/extensions": [
      "error",
      "always"
    ]
  }
}

@mdjermanovic
Copy link
Member

Hi @AndreiSoroka!

ESLint: 8.0.0-beta.1

Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './lib/util/glob-util' is not defined by "exports" in /Users/andreisoroka/git/other/faststartservice/node_modules/eslint/package.json
    at throwExportsNotFound (internal/modules/esm/resolve.js:285:9)
    at packageExportsResolve (internal/modules/esm/resolve.js:508:3)
    at resolveExports (internal/modules/cjs/loader.js:450:36)
    at Function.Module._findPath (internal/modules/cjs/loader.js:490:31)
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:888:27)
    at Function.Module._load (internal/modules/cjs/loader.js:746:27)
    at Module.require (internal/modules/cjs/loader.js:974:19)
    at require (/Users/andreisoroka/git/other/faststartservice/node_modules/v8-compile-cache/v8-compile-cache.js:159:20)
    at Object.<anonymous> (/Users/andreisoroka/git/other/faststartservice/node_modules/eslint-plugin-import/lib/rules/no-unused-modules.js:43:34)

This is a problem in eslint-plugin-import, it's using some internal APIs that have been removed in ESLint 8.

Can you please report this problem to https://github.com/import-js/eslint-plugin-import ?

Thanks for testing ESLint prereleases and let us know if you find any other problems! Just please open separate issue(s) so we could track them, this one is only about adding support for top-level await.

@AndreiSoroka
Copy link

Thanks! I check issues and find import-js/eslint-plugin-import#2211

@AndreiSoroka
Copy link

FYI: @ljharb

@ljharb
Copy link
Sponsor Contributor

ljharb commented Sep 6, 2021

I’m aware; most of the ecosystem doesn’t support eslint 8 yet, which is fine since it’s not actually out yet.

@nzakas
Copy link
Member

nzakas commented Sep 7, 2021

Please open new issues if you find problems with ESLint 8 functionality.

@eslint eslint locked as resolved and limited conversation to collaborators Sep 7, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
accepted There is consensus among the team that this change meets the criteria for inclusion core Relates to ESLint's core APIs and features enhancement This change enhances an existing feature of ESLint new syntax This issue is related to new syntax that has reached stage 4
Projects
Public Roadmap
  
Complete
Archived in project
v8.0.0
  
Done
Triage
Complete
Development

Successfully merging a pull request may close this issue.