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

Non-top-level imports are basically part of the ES6 specs, take out warning #11708

Closed
mercmobily opened this issue May 10, 2019 · 6 comments
Closed
Labels
archived due to age This issue has been archived; please open a new issue for any further discussion question This issue asks a question about ESLint

Comments

@mercmobily
Copy link

What rule do you want to change?

"Import and export may only appear at the top level" (sorry, can't find the ID)

This is because now, in 2019, import()s are pervasively used, and basically part of the specs -- the last comment in particular from yesterday reads "Investigated. Discussed in the SES meeting today. We are happy to see this proceed to stage 4."

Does this change cause the rule to produce more or fewer warnings?

Fewer.

How will the change be implemented? (New option, new default behavior, etc.)?

Disable a rule when linting ES6

Please provide some example code that this change will affect:

    case 'view1':
      import('../components/my-view1.js').then((module) => {
        // Put code in here that you want to run every time when
        // navigating to view1 after my-view1.js is loaded.
      });
      break;

What does the rule currently do for this code?

Gives a warning

What will the rule do after it's changed?

Stop giving the warning

Are you willing to submit a pull request to implement this change?

Sorry, I don't know eslint's code base at all

@mercmobily mercmobily added enhancement This change enhances an existing feature of ESLint rule Relates to ESLint's core rules triage An ESLint team member will look at this issue soon labels May 10, 2019
@mercmobily mercmobily changed the title non-top-level imports are basically part of the ES6 specs Non-top-level imports are basically part of the ES6 specs, take out warning May 10, 2019
@not-an-aardvark
Copy link
Member

Hi, thanks for creating an issue.

Dynamic import is still a stage 3 proposal, so we don't support it yet. Based on the link you shared, it seems like it will probably reach stage 4 soon, which is great news. As with all other features, we'll start supporting it once it reaches stage 4.

@not-an-aardvark not-an-aardvark added question This issue asks a question about ESLint and removed enhancement This change enhances an existing feature of ESLint rule Relates to ESLint's core rules triage An ESLint team member will look at this issue soon labels May 11, 2019
@mercmobily
Copy link
Author

From the horse's mouth:

"I expect it to happen at the upcoming tc39 meeting June 4,5,6 2019"

Is a PR ready for it? (maybe one of the ones that was rejected because it wasn't stage 4 yet?)
I am hoping this change will make it to the codebase as soon as imports are promoted to stage 4. I am happy to do whatever to facilitate that.

@platinumazure
Copy link
Member

@mercmobily If this is really likely to make stage 4, contributions would be great! Here's a (likely incomplete) list of what would be needed:

  • Is there an ESTree spec for this? (I hope the tc39 champion would write a PR there, but worth checking.)
  • Does Acorn support this? If not, need to ensure Acorn can parse. (Best would be if it happened in mainline Acorn, but if they are unlikely to get it in soon, espree could maybe consume an Acorn plugin- see next.)
  • Espree would need to consume new Acorn (upgrade dependency, or maybe consume plugin if needed). Espree would also need to convert Acorn output to match ESTree spec, add unit tests, etc.
  • ESLint would need to consume new espree version once it is released. Additionally, rules might need to be updated (e.g., make sure no-undef doesn't report import as an identifier with no declaration.

My suggestion is to start upstream and see what's in place already, then work down to ESLint. Some of the upstream repositories might be willing to accept PRs early.

Hope this helps!

@mercmobily
Copy link
Author

Hi,

OK, let's do this!
Hopefully, this will help things speed up a little.

"Is there an ESTree spec for this? (I hope the tc39 champion would write a PR there, but worth checking.)"

YES. It looks merged too. estree/estree#137

"Does Acorn support this? If not, need to ensure Acorn can parse. (Best would be if it happened in mainline Acorn, but if they are unlikely to get it in soon, espree could maybe consume an Acorn plugin- see next.)"

YES. It does so via a Acorn plugin for dynamic imports. I opened a ticket to see if they will move the dynamic imports plugin to the main codebase

For the last 2 points... does it all relate to Eslint's codebase?

Merc.

@mysticatea
Copy link
Member

mysticatea commented May 17, 2019

I would make the umbrella issue for ES2020 after the next TC39 meeting if the syntaxes really arrived at Stage 4, like I have done so in the past.


YES. It looks merged too. estree/estree#137

It's in the experimental directory that ESLint core doesn't support. It's needed to move it to the es2020.md.

For the last 2 points... does it all relate to Eslint's codebase?

Yes.

@mysticatea
Copy link
Member

Hi. Please track #11803.

@eslint-deprecated eslint-deprecated bot locked and limited conversation to collaborators Dec 2, 2019
@eslint-deprecated eslint-deprecated bot added the archived due to age This issue has been archived; please open a new issue for any further discussion label Dec 2, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
archived due to age This issue has been archived; please open a new issue for any further discussion question This issue asks a question about ESLint
Projects
None yet
Development

No branches or pull requests

4 participants