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

AMP Runtime: allow usage of iterator/destructure/spread/rest #35694

Open
3 of 5 tasks
samouri opened this issue Aug 16, 2021 · 7 comments
Open
3 of 5 tasks

AMP Runtime: allow usage of iterator/destructure/spread/rest #35694

samouri opened this issue Aug 16, 2021 · 7 comments

Comments

@samouri
Copy link
Member

samouri commented Aug 16, 2021

Description

Awhile back we decided to start allowing for iterator to be used (#34249). The logic was that it only adds 0.12kb to any bundle which uses it, and only .js builds as opposed to .mjs builds. We started implementation of this change, but ran into roadblocks (#34282 (review))

To do:

Update these plugins/rules to handle ArrayExpression:

Can be removed:

cc @ampproject/wg-performance

@samouri samouri changed the title Allow iterator polyfill AMP Runtime: allow usage of iterator/destructure Aug 16, 2021
@samouri samouri changed the title AMP Runtime: allow usage of iterator/destructure AMP Runtime: allow usage of iterator/destructure/spread Aug 16, 2021
@samouri
Copy link
Member Author

samouri commented Aug 16, 2021

After local testing I believe:

  • prefer-destructuring is optional and we can update at our leisure
  • no-unused-privates does not need any updating, and already works through the ClassBody MemberExpression visitor

@samouri samouri self-assigned this Aug 16, 2021
@samouri samouri changed the title AMP Runtime: allow usage of iterator/destructure/spread AMP Runtime: allow usage of iterator/destructure/spread/rest Aug 16, 2021
@jridgewell
Copy link
Contributor

no-unused-privates does not need any updating, and already works through the ClassBody MemberExpression visitor

This won't catch uses like [this.#foo] = [1]. Honestly, we should just ban any patterns that don't use Identifier.

@samouri
Copy link
Member Author

samouri commented Aug 17, 2021

no-unused-privates does not need any updating, and already works through the ClassBody MemberExpression visitor

This won't catch uses like [this.#foo] = [1]. Honestly, we should just ban any patterns that don't use Identifier.

Sure. That sounds like a new eslint rule. Also I've never seen anyone use destructure to assign to a property before...its terrifying

@samouri
Copy link
Member Author

samouri commented Aug 17, 2021

no-unused-privates does not need any updating, and already works through the ClassBody MemberExpression visitor

This won't catch uses like [this.#foo] = [1]. Honestly, we should just ban any patterns that don't use Identifier.

On closer inspection, doesn't it still work? The case you just highlighted is about using an ArrayPattern to assign to a property. I think we'd want to throw when only seeing a private only used as an lvalue

@jridgewell
Copy link
Contributor

The case you just highlighted is about using an ArrayPattern to assign to a property.

It doesn't detect that it's being written, it thinks it's being read. Which will incorrectly flag the field as being used.

@samouri
Copy link
Member Author

samouri commented Aug 19, 2021

I'm going to descope prefer-destructuring as a nice-to-have, and say once unused-private-field is updated that this issue can be closed.

@stale
Copy link

stale bot commented Oct 1, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions.

@stale stale bot added the Stale Inactive for one year or more label Oct 1, 2022
@samouri samouri removed their assignment Oct 1, 2022
@stale stale bot removed the Stale Inactive for one year or more label Oct 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants