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

Support for dynamic imports in body #1122

Closed
corvana-nbaker opened this issue May 2, 2018 · 5 comments

Comments

@corvana-nbaker
Copy link

commented May 2, 2018

We're leveraging dynamic imports and standard keeps complaining: "Parsing error: 'import' and 'export' may only appear at the top level"

Eslint supports suppressing this via the "allowImportExportEverywhere" parser option, but standard doesn't seem to read the .eslintrc file. /* eslint-disable /* doesn't work either.

Is anyone aware of a way to ignore this check?

@LinusU

This comment has been minimized.

Copy link
Member

commented May 2, 2018

/* eslint-disable */ should work...

May I ask how your setup is? I thought that dynamic imports where made via a function call (e.g. import('./foobar').then(() => /* ... */)) instead of using the import keyword?

@corvana-nbaker

This comment has been minimized.

Copy link
Author

commented May 2, 2018

That's the syntax we're using yes.

@feross

This comment has been minimized.

Copy link
Member

commented May 2, 2018

@corvana-nbaker Are you referring to the allowImportExportEverywhere option that babel-eslint takes?

@corvana-nbaker

This comment has been minimized.

Copy link
Author

commented May 3, 2018

Yes! How can I get "allowImportExportEverywhere" to take effect with standard?

@feross

This comment has been minimized.

Copy link
Member

commented May 10, 2018

It appears that the allowImportExportEverywhere option is specifically for allowing import and export statements to work anywhere, effectively emulating how require() can appear anywhere (not just top-level).

I don't think this should be necessary if you're using the dynamic import() syntax.

Using babel-eslint@8 and standard@11, I am unable to reproduce this issue. It lints import() perfectly fine as far as I can tell.

Also, this appears related to: #1041

@feross feross closed this May 10, 2018

@feross feross added the question label May 10, 2018

@lock lock bot locked as resolved and limited conversation to collaborators Aug 8, 2018

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
3 participants
You can’t perform that action at this time.