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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dynamic Imports and BigInt have arrived at Stage 4 馃帀 #11803

Closed
5 of 6 tasks
mysticatea opened this issue Jun 4, 2019 · 25 comments 路 Fixed by #12701
Closed
5 of 6 tasks

Dynamic Imports and BigInt have arrived at Stage 4 馃帀 #11803

mysticatea opened this issue Jun 4, 2019 · 25 comments 路 Fixed by #12701
Labels
accepted There is consensus among the team that this change meets the criteria for inclusion archived due to age This issue has been archived; please open a new issue for any further discussion core Relates to ESLint's core APIs and features feature This change adds a new feature to ESLint new syntax This issue is related to new syntax that has reached stage 4 rule Relates to ESLint's core rules
Projects

Comments

@mysticatea
Copy link
Member

mysticatea commented Jun 4, 2019

Dynamic Imports and BigInt have arrived at Stage 4.
This is the tracking issue to support the new syntaxes.

@mysticatea mysticatea added rule Relates to ESLint's core rules core Relates to ESLint's core APIs and features accepted There is consensus among the team that this change meets the criteria for inclusion feature This change adds a new feature to ESLint labels Jun 4, 2019
@g-plane
Copy link
Member

g-plane commented Jun 4, 2019

I have opened an issue at Acorn's repo: acornjs/acorn#833 .

@mercmobily
Copy link

While this gets implemented (thank you!), is there a way to get around it with an ignore?
At the moment, if you have:

import(resolvedPageUrl)

you get:

Parsing error: 'import' and 'export' may only appear at the top level

The problem is that this is a parsing error... so the file doesn't get linted at all.
Is there a workaround while we wait for this to actually land? (It looks like it may be a little while!)

@g-plane
Copy link
Member

g-plane commented Jun 9, 2019

You can use babel-eslint as parser.

@dandv
Copy link
Contributor

dandv commented Jun 27, 2019

You can use babel-eslint as parser.

I'm trying to be babel-free.

Please revisit #11189 as well.

@g-plane
Copy link
Member

g-plane commented Jun 27, 2019

Don't worry. Dynamic imports will be supported by ESLint itself finally. However, this is still in progress, so you need babel-eslint at present.

@mysticatea
Copy link
Member Author

Yeah, it's working in progress. As the issue description says, we are awaiting ESTree spec to be determined because we cannot implement it until the spec gets stable.

@mdjermanovic
Copy link
Member

I guess no-octal doesn't need any changes, apart from a couple of test cases perhaps?

typeof node.value === "number" condition will ignore bigints in all environments.

This rule disallows 017, not 0o17, so 0o17n should be fine.

017n should be already a syntax error,

@mysticatea
Copy link
Member Author

Oh, you are right.

@mysticatea
Copy link
Member Author

We are still awaiting ESTree's decide. I'm wondering that we should fork the AST spec because that PR has been inactive since two months ago.

@mysticatea
Copy link
Member Author

Yay, that PR has been merged!

@mercmobily
Copy link

acornjs/acorn#844 has been merged too

@mercmobily
Copy link

#11802 has also been merged

@abdonrd
Copy link

abdonrd commented Aug 13, 2019

eslint/eslint-visitor-keys#8 has also been merged!

@NemoStein
Copy link

Now that we have estree/estree@9a38106 in ESTree spec, what is the status of this issue?

@platinumazure
Copy link
Member

@NemoStein Please look at the task list in the initial post. At this point, we have updated espree and just need to release espree and consume in ESLint, and then we can review and merge PRs like #11983.

I'm hoping we can make big strides in this area for our users with the upcoming ESLint minor release sometime this weekend. But I can't promise anything. 馃槃

kaicataldo pushed a commit that referenced this issue Aug 18, 2019
* upgrade deps

* make CodePathAnalyzer handling ImportExpression as throwable

* fix new-cap rule

* fix astUtils.getPrecedence

* fix astUtils.isNullLiteral

* add env.es2020

* fix func-call-spacing rule

* fix function-paren-newline rule

* fix indent rule

* fix no-extra-parens rule

* Upgrade: espree@^6.1.0, eslint-visitor-keys@^1.1.0

* Chore: Ignore tools/internal-rules/node_modules

* Upgrade: acorn@^7.0.0

This avoids a dependency deduplication conflict for developers
@jesperkristensen
Copy link

I noticed today that dynamic imports now works with the latest eslint release, even though this issue has not been updated.

@mercmobily
Copy link

mercmobily commented Sep 1, 2019 via email

@mysticatea
Copy link
Member Author

This issue is updated. See the issue description; we have not done the last item "ESLint Update 2: the following stuff look like to need update, but breaking changes.", we will do it on 7.0.0 release.

The syntax support is not completed, but you can use ecmaVersion:2020 since ESLint 6.2.0.
See https://eslint.org/blog/2019/08/eslint-v6.2.0-released

@jesperkristensen
Copy link

Oh, the issue was updated, it's just GitHub that only sends notifications when a new comment is added, but not when a comment is edited.

@mercmobily
Copy link

Question: is everything except "ESLint Update 2: the following stuff look like to need update, but breaking changes." been released in the NPM distributed package?

@mysticatea
Copy link
Member Author

Yes. Those are in 6.2.0.

@tituswoo
Copy link

tituswoo commented Sep 24, 2019

Edit: This answered my question: #12310 馃槃


馃憢 Hey folks! I've been trying to get dynamic imports working with eslint 6.4.0 but haven't had luck getting it to work. It's my understanding from this issue, this PR, and v6.2.0 changelog that dynamic imports should be working as of eslint 6.2, right? However eslint v6.4.0 is still throwing the following error for me whenever I attempt to use a dynamic import 馃槶

0:0 error  Parsing error: Invalid ecmaVersion

Also, @mysticatea I'm probably missing something really obvious, 馃槄 but in my .eslintrc.json, eslint is complaining about 2020 not being a valid ecmaVersion:

"parserOptions": {
    "sourceType": "module",
    "ecmaVersion": 2020
},

This issue is updated. See the issue description; we have not done the last item "ESLint Update 2: the following stuff look like to need update, but breaking changes.", we will do it on 7.0.0 release.

The syntax support is not completed, but you can use ecmaVersion:2020 since ESLint 6.2.0.
See https://eslint.org/blog/2019/08/eslint-v6.2.0-released

Thanks for the help! 馃檹

@mysticatea
Copy link
Member Author

You are looking using old ESLint or at least old parser. Please open a new issue with our issue template.

@mysticatea mysticatea moved this from Memorandum to Needs discussion in v7.0.0 Nov 7, 2019
@mysticatea mysticatea moved this from Needs discussion to Accepted, ready to implement in v7.0.0 Nov 7, 2019
@mysticatea mysticatea added the new syntax This issue is related to new syntax that has reached stage 4 label Dec 8, 2019
@mdjermanovic
Copy link
Member

no-compare-neg-zero rule: should recognize BigInt literals.

BigInt type doesn't have negative zero value?

Object.is(-0n, 0n); // true

So perhaps no-compare-neg-zero shouldn't report bigint literals? Or maybe it still should, for the case if user might be unaware of this fact. But then it could be useful to report any occurrence of -0n in the code (not just comparisons), maybe behind an option or in a new rule?

no-extend-native rule: should recognize BigInt function.

This seems to already work by itself:

I guess it works with a manually added BigInt ESLint global since v11.6.0 of the globals package.

@ljharb
Copy link
Sponsor Contributor

ljharb commented Dec 10, 2019

It should probably warn on any occurrence if -0n

@mysticatea mysticatea moved this from Accepted, ready to implement to Issues which have PR in v7.0.0 Dec 22, 2019
v7.0.0 automation moved this from Issues which have PR to Done Jan 17, 2020
kaicataldo pushed a commit that referenced this issue Jan 17, 2020
* update no-magic-numbers to recognize bigint

* update yoda to recognize bigint

* add a no-extend-native test

* update ci.yml temporary (this PR is blocked by #12700)

* add astUtils.isNumericLiteral and use it in some rules

* update no-dupe-class-members

* update no-magic-number to support bigint in options

* update some rules to use getStaticPropertyName

* update quote-props

* revert no-useless-computed-key change

* revert "allowing {type: 'bigint'}" and update no-magic-number

* no-magic-number 'ignores' allows negative bigint
montmanu pushed a commit to montmanu/eslint that referenced this issue Mar 4, 2020
鈥lint#12701)

* update no-magic-numbers to recognize bigint

* update yoda to recognize bigint

* add a no-extend-native test

* update ci.yml temporary (this PR is blocked by eslint#12700)

* add astUtils.isNumericLiteral and use it in some rules

* update no-dupe-class-members

* update no-magic-number to support bigint in options

* update some rules to use getStaticPropertyName

* update quote-props

* revert no-useless-computed-key change

* revert "allowing {type: 'bigint'}" and update no-magic-number

* no-magic-number 'ignores' allows negative bigint
@eslint-deprecated eslint-deprecated bot locked and limited conversation to collaborators Jul 17, 2020
@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 Jul 17, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
accepted There is consensus among the team that this change meets the criteria for inclusion archived due to age This issue has been archived; please open a new issue for any further discussion core Relates to ESLint's core APIs and features feature This change adds a new feature to ESLint new syntax This issue is related to new syntax that has reached stage 4 rule Relates to ESLint's core rules
Projects
No open projects
v7.0.0
  
Done
Development

Successfully merging a pull request may close this issue.