-
-
Notifications
You must be signed in to change notification settings - Fork 4.6k
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
Enable Top Level Await #13178
Comments
Hi @mudgen, thanks for the issue! I assume you're getting parsing errors. ESLint's default parser will support this syntax if and when it reaches stage 4, per our policy about experimental features. In the meantime, you can use |
Unfortunately, it looks like there wasn't enough interest from the team Thanks for contributing to ESLint and we appreciate your understanding. |
@mdjermanovic - We don't use babel, but node.js just added support for top-level await. What is the recommended course if we want to use this feature of node without using Babel? |
@mjsalinger our default parser supports only stage 4 proposals. You could use |
Although it is still in stage 3, it has now shipped unflagged in Node and other common JS environments, so might be worth reconsidering |
Hi, Could help me? package.json {
"name": "test",
"version": "1.0.0",
"description": "",
"main": "index.js",
"type": "module",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"fastify": "^3.4.1"
},
"devDependencies": {
"@babel/core": "^7.11.6",
"@babel/eslint-parser": "^7.11.5",
"@babel/plugin-syntax-top-level-await": "^7.10.4",
"eslint": "^7.9.0",
"eslint-config-airbnb-base": "^14.2.0",
"eslint-plugin-import": "^2.22.0",
"eslint-plugin-node": "^11.1.0"
}
} .eslintrc.cjs module.exports = {
parserOptions: {
ecmaVersion: 2021,
sourceType: 'module',
parser: "@babel/eslint-parser"
}
}; babel.config.json {
"plugins": ["@babel/plugin-syntax-top-level-await"]
} Thank's |
Hi @boggddan!
module.exports = {
parser: "@babel/eslint-parser",
parserOptions: {
ecmaVersion: 2021,
sourceType: 'module'
}
}; |
+1 for enabling top level await even if it is not stage 4. Not everything is black and white. We should not be too constrained to rules. Also another option solution without using babel-parser would also be welcoming, like disabling this specific parse error ? |
The Alternative solutions could be:
|
(what is RTM?) |
Please describe what the rule should do:
Provide a setting or rule that enables top level await in code without an error or warning.
V8 now supports top level await: https://v8.dev/features/top-level-await
As a standard top level await is in stage 3: https://github.com/tc39/proposal-top-level-await
I am currently using deno which has top level await, so this new setting/rule would be very useful for me.
The text was updated successfully, but these errors were encountered: