Bug: warning about using async await outside function: nodejs16 project
See original GitHub issueEnvironment
Node version: 16.13.1 npm version: 8.1.2 Local ESLint version: 8.5.0 Global ESLint version: 8.5.0 Operating System: Linux(zorinoslite16, ubuntu 20.04 based)
What parser are you using?
Default (Espree)
What did you do?
Configuration
package.json:
"type": "module",
eslintrc.json: `{ “env”: { “node”: true, “es2021”: true }, “extends”: “eslint:recommended”, “parserOptions”: { “ecmaVersion”: 12, “sourceType”: “module” }, “rules”: {
}
}`
jsconfig.json
{ "compilerOptions": { "target": "es2021", "module": "es2020", }, "exclude": [ "dist/", "node_modules", "**/node_modules/*", ".vscode/", ] }
const express = require('express')
const { default: express } = await import('express') // Parsing error
.....
await runtime.init() // Parsing error
app.listen(port, () =>
console.log(`Porta ${port} (${process.env.NODE_ENV})`),
)
What did you expect to happen?
a warning about using require() on esmodule / non-commonjs nodejs v16 project
and no warning about using async await outside functon in a nodejs project “Parsing error: Cannot use keyword ‘await’ outside an async function eslint”
What actually happened?
Eslint didint acuse anything about using require
Eslint acuse Parsing error: Cannot use keyword ‘await’ outside an async function
Participation
- I am willing to submit a pull request for this issue.
Additional comments
No babel, no other parser
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (3 by maintainers)
Top GitHub Comments
looks like that way - es2022 does not have new vars.
Re the
require
, you could removenode: true
in the envs, or config like eslint-plugin-nodeyou’ll need to set
ecmaVersion: 2022/13
to use TLA.