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

allow use before define #9361

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

allow use before define #9361

wants to merge 2 commits into from

Conversation

turadg
Copy link
Member

@turadg turadg commented May 13, 2024

no ticket

Description

The no-use-before-define rule was motivated by when variables could hoist up in surprising ways. We always use let and const which have the Temporal Dead Zone that will throw an error if used before declaration.

So we don't need this rule anymore and it's mostly noise.

Security Considerations

n/a, lint

Scaling Considerations

n/a, lint

Documentation Considerations

reduces need for docs

Testing Considerations

CI

Upgrade Considerations

n/a, lint

@turadg turadg mentioned this pull request May 13, 2024
Copy link

cloudflare-pages bot commented May 13, 2024

Deploying agoric-sdk with  Cloudflare Pages  Cloudflare Pages

Latest commit: 31d3f7d
Status: ✅  Deploy successful!
Preview URL: https://4471299f.agoric-sdk.pages.dev
Branch Preview URL: https://ta-allow-use-before-define.agoric-sdk.pages.dev

View logs

@turadg turadg requested review from warner and kriskowal May 13, 2024 17:27
@dckc
Copy link
Member

dckc commented May 13, 2024

... We always use let and const

We haven't removed all use of function. It looks like hundreds of them remain.

https://github.com/Agoric/agoric-sdk/blob/master/packages/SwingSet/src/controller/controller.js
https://github.com/Agoric/agoric-sdk/blob/master/packages/SwingSet/src/kernel/kernel.js

function convert(data) {

etc.

I don't think we even have a lint rule to avoid it.

@turadg
Copy link
Member Author

turadg commented May 13, 2024

We haven't removed all use of function. It looks like hundreds of them remain.

Good point. But as you also point out this rule doesn't pertain to those.

Any reason to keep this rule?

@dckc
Copy link
Member

dckc commented May 13, 2024

We haven't removed all use of function. It looks like hundreds of them remain.

Good point. But as you also point out this rule doesn't pertain to those.

use-before-defined does apply to functions, IIUC.

What I meant was: we don't have a rule to say "use const instead of function".

@turadg turadg force-pushed the ta/allow-use-before-define branch from 7ad4373 to c4d7f8d Compare May 13, 2024 19:07
@turadg turadg requested review from erights and removed request for kriskowal May 13, 2024 19:19
@@ -34,7 +34,6 @@
"@agoric/assert": "^0.6.0",
"@agoric/ertp": "^0.16.2",
"@agoric/internal": "^0.3.2",
"@agoric/network": "^0.1.0",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An unrelated drive-by? (no objection. Just making sure I understand.)

Copy link
Member Author

@turadg turadg May 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep, c4d7f8d, to improve the tred graph

@@ -24,7 +24,6 @@
"dependencies": {
"@agoric/internal": "^0.3.2",
"@agoric/notifier": "^0.6.2",
"@agoric/spawner": "^0.6.8",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An unrelated drive-by? (no objection. Just making sure I understand.)

@turadg turadg force-pushed the ta/allow-use-before-define branch from c4d7f8d to 6f1744c Compare May 15, 2024 20:11
@turadg turadg force-pushed the ta/allow-use-before-define branch from 6f1744c to 31d3f7d Compare May 16, 2024 22:11
@turadg turadg requested a review from erights May 16, 2024 22:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants