Comments (3)
@olsonpm, eslint-plugin-import has no parser, eslint has it. And eslint supports top-level await without any issues. Could you please provide a more details / steps to reproduce?
Generally speaking, it's ok to fix some library a bit to provide compatibility with popular tools, but we need to understand the root cause.
from esmock.
looks like I needed to add ecmaVersion: 2022
or later so you were right, it had to do with my configuration of the eslint parser.
I haven't encountered this issue before I think because typically eslint rules are specific to a projects' own files. Looks like the import plugin parses other module's files (necessarily of course), which then means the parser configuration needs to support other library's code.
Sorry for the noise
from esmock.
Here's a reproduction
$ git clone [email protected]:olsonpm/repro.git
$ cd repro
$ git checkout esmock-issue-288
$ npm ci
$ npx eslint index.mjs
/path/to/repro/index.mjs
1:20 error Parse errors in imported module 'esmock': Cannot use keyword 'await' outside an async function (2:8171) import/namespace
1:20 error Parse errors in imported module 'esmock': Cannot use keyword 'await' outside an async function (2:8171) import/default
1:20 warning Parse errors in imported module 'esmock': Cannot use keyword 'await' outside an async function (2:8171) import/no-named-as-default
1:20 warning Parse errors in imported module 'esmock': Cannot use keyword 'await' outside an async function (2:8171) import/no-named-as-default-member
✖ 4 problems (2 errors, 2 warnings)
I'll look into the parser detail you mention to better understand the issue
edit: okay I fixed the repro and updated the error text
from esmock.
Related Issues (20)
- yarn pnp issues HOT 14
- Is it possible to mock json imports with assert? HOT 6
- Support Yarn PnP resolver out of the box HOT 11
- Get rid of old Node versions support HOT 8
- resolve error introduced with 2.5.2 HOT 10
- Error when mocking a file that exports an array. HOT 1
- c8 incorrect branch coverage; modules and `import` globals HOT 11
- how to mock globalThis HOT 4
- import('node:fs/promises') called within a library does not seem to be replaced HOT 30
- Path alias support HOT 1
- Unexpected strict mode reserved word syntax error when mocking express HOT 2
- No support for subpath patterns? HOT 14
- Version 2.6.3 changed the way to mock libraries HOT 7
- ESMock seems to wrongfully alter Sinon stubs. HOT 1
- Using `import:` to mock globals messes up coverage (with c8) HOT 7
- [Question] Is it possible to mock indirect imports? HOT 10
- Scoped mocks failing with pnpm but working with npm HOT 9
- esmock static import for classes not matching HOT 3
- upstream issue, worker threads unable to register loader HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from esmock.