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
mysticatea opened this issue Jun 4, 2019 · 25 comments
Closed

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

mysticatea opened this issue Jun 4, 2019 · 25 comments

Comments

@mysticatea
Copy link
Member

@mysticatea mysticatea commented Jun 4, 2019

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

  • estree/estree#198 ESTree Spec Update
  • acornjs/acorn#844 Acorn Update
  • eslint/eslint-visitor-keys#8 eslint-visitor-keys Update
  • eslint/espree#415 espree Update
  • ESLint Update 1: the following stuff look like to need update.
    • #11983 envs should have new globals (BigInt, BigInt64Array, and BigUint64Array)
    • #11983 CodePathAnalyzer: should recognize ImportExpression node as a throwable node.
    • #11983 astUtils.getPrecedence(node): should recognize ImportExpression literals.
    • #11983 astUtils.isNullLiteral(node): should recognize BigInt literals.
    • #11983 func-call-spacing rule: should recognize ImportExpression node. (or new rule?)
    • #11983 function-paren-newline rule: should recognize ImportExpression node. (or new rule?)
    • #11983 indent rule: should recognize ImportExpression node.
    • #11983 new-cap rule: should recognize BigInt function.
    • #11983 no-extra-parens rule: should recognize ImportExpression node.
    • #11802 valid-typeof rule: should recognize BigInt type.
  • ESLint Update 2: the following stuff look like to need update, but breaking changes.
    • no-compare-neg-zero rule: should recognize BigInt literals.
    • #12701 no-extend-native rule: should recognize BigInt function.
    • #12701 no-magic-number rule: should recognize BigInt literals.
    • #12701 yoda rule: should recognize BigInt literals.
@g-plane

This comment has been minimized.

Copy link
Member

@g-plane g-plane commented Jun 4, 2019

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

@mercmobily

This comment has been minimized.

Copy link

@mercmobily mercmobily commented Jun 9, 2019

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

This comment has been minimized.

Copy link
Member

@g-plane g-plane commented Jun 9, 2019

You can use babel-eslint as parser.

@dandv

This comment has been minimized.

Copy link
Contributor

@dandv 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

This comment has been minimized.

Copy link
Member

@g-plane 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

This comment has been minimized.

Copy link
Member Author

@mysticatea mysticatea commented Jun 27, 2019

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

This comment has been minimized.

Copy link
Member

@mdjermanovic mdjermanovic commented Jul 14, 2019

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

This comment has been minimized.

Copy link
Member Author

@mysticatea mysticatea commented Jul 14, 2019

Oh, you are right.

@mysticatea

This comment has been minimized.

Copy link
Member Author

@mysticatea mysticatea commented Aug 12, 2019

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

This comment has been minimized.

Copy link
Member Author

@mysticatea mysticatea commented Aug 12, 2019

Yay, that PR has been merged!

@mercmobily

This comment has been minimized.

Copy link

@mercmobily mercmobily commented Aug 12, 2019

acornjs/acorn#844 has been merged too

@mercmobily

This comment has been minimized.

Copy link

@mercmobily mercmobily commented Aug 12, 2019

#11802 has also been merged

@abdonrd

This comment has been minimized.

Copy link

@abdonrd abdonrd commented Aug 13, 2019

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

@NemoStein

This comment has been minimized.

Copy link

@NemoStein NemoStein commented Aug 16, 2019

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

@platinumazure

This comment has been minimized.

Copy link
Member

@platinumazure platinumazure commented Aug 16, 2019

@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 added 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
zaygraveyard added a commit to zaygraveyard/flow-comments that referenced this issue Aug 30, 2019
Until eslint/eslint#11803 is resolved and dynamic imports get supported
@jesperkristensen

This comment has been minimized.

Copy link

@jesperkristensen jesperkristensen commented Sep 1, 2019

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

@mercmobily

This comment has been minimized.

Copy link

@mercmobily mercmobily commented Sep 1, 2019

@mysticatea

This comment has been minimized.

Copy link
Member Author

@mysticatea mysticatea commented Sep 1, 2019

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

This comment has been minimized.

Copy link

@jesperkristensen jesperkristensen commented Sep 1, 2019

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

This comment has been minimized.

Copy link

@mercmobily mercmobily commented Sep 1, 2019

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

This comment has been minimized.

Copy link
Member Author

@mysticatea mysticatea commented Sep 1, 2019

Yes. Those are in 6.2.0.

@tituswoo

This comment has been minimized.

Copy link

@tituswoo 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

This comment has been minimized.

Copy link
Member Author

@mysticatea mysticatea commented Sep 24, 2019

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
@mdjermanovic

This comment has been minimized.

Copy link
Member

@mdjermanovic mdjermanovic commented Dec 10, 2019

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

This comment has been minimized.

Copy link
Contributor

@ljharb 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 added 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 added 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
v7.0.0
  
Done
Linked pull requests

Successfully merging a pull request may close this issue.

You can鈥檛 perform that action at this time.