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 dynamic imports #3457

Closed
Abrifq opened this issue Mar 30, 2020 · 5 comments
Closed

Add support for dynamic imports #3457

Abrifq opened this issue Mar 30, 2020 · 5 comments
Labels

Comments

@Abrifq
Copy link

Abrifq commented Mar 30, 2020

Using Visual Studio Code 1.43.2

Extension: "dbaeumer.jshint" using global installation of jshint from npm

JSHint Installed: 2.11.0@npm

Expected Behaviour: Recognize import() as a function.

Actual Behaviour

JSHint doesn't recognize

import("module/path.mjs") //Returns Promise of export object

as a function and throws E053 and E021.

This function is used in importing modules for scripts doesn't end with ".mjs".
More info about can be seen in this MDN page.

I don't know if this function is in proposals, it just works in major browsers (Firefox,Chrome, etc.) and node.js.

Config Values

Not using .jshintrc file, using a global extension setting. ```js { "jshint.lintHTML": true, "jshint.options": { "esversion": 9, "varstmt": true, "unused": true, "undef": true, "singleGroups": true, "eqeqeq": true, "freeze": true, "lastsemic": true, "leanswitch": true, "latedef": true, "maxdepth": 4, "noreturnawait": true, "nonbsp": true, "noarg": true, "maxparams": 3, "maxerr": 10, "maxcomplexity": 15, "node": true } } ```
@jugglinmike
Copy link
Member

Thanks for the report! We haven't implemented support for dynamic imports, but we plan to (it definitely satisfies our policy on new language features). That makes this more of a feature request than a bug report, so I've modified the issue's title a bit--hope you don't mind.

If you (or anyone else) would like to try implementing this, then I'd gladly give guidance!

@jugglinmike jugglinmike changed the title JSHint doesn't support dynamic imports Add support for dynamic imports Apr 6, 2020
@almercier
Copy link

almercier commented Jun 6, 2020

@jugglinmike Considering this is an es2020 proposal, how would you envision somone be able to toggle this feature? I'm assuming there would be an esversion: 11 which I assume would require all of the other es2020 proposals (nullish coalescing, optional chaining, etc...) to be supported as well.

I may look into implementing support for this specific proposal as it would help up quite a bit.

@jugglinmike
Copy link
Member

esversion: 11 sounds about right to me, @almercier! Implementing all of the new language features is a big undertaking, and I wouldn't expect anyone to take all of that on by themselves. If you wanted to focus on the import expression, then we could tackle the other features in parallel (or publish a release with partial support for the new language edition).

@jugglinmike
Copy link
Member

I've updated our submodule for Test262 so that we have better coverage for the new language features. I've also created a tracking branch for a new minor release; that's where we should land new features.

@jugglinmike
Copy link
Member

JSHint version 2.13.0, released today, includes support for dynamic imports. Be sure to update your configuration to opt in to the new language feature via esversion: 11 or later.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants