Skip to content

benchmark,lib: var to const - #26915

Closed
BridgeAR wants to merge 1 commit into
nodejs:masterfrom
BridgeAR:var-const
Closed

benchmark,lib: var to const#26915
BridgeAR wants to merge 1 commit into
nodejs:masterfrom
BridgeAR:var-const

Conversation

@BridgeAR

@BridgeARBridgeAR commented Mar 26, 2019

Copy link
Copy Markdown
Member

This came up recently again. I just ran a modified eslint rule against lib and benchmark and I have no strong opinion about actually doing this and I am absolutely fine with closing this again. It's just there to resolve a comment in the referenced PR.

Note: I did not update any eslint rules as there is no explicit rule to do this. Instead, I just modified the prefer-const rule to match against var instead of let.

Refs: #26679

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • documentation is changed or added
  • commit message follows commit guidelines

@BridgeAR
BridgeAR requested a review from TrottMarch 26, 2019 04:24
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@nodejs-github-botnodejs-github-bot added the lib / src Issues and PRs related to general changes in the lib or src directory. label Mar 26, 2019
@gengjiawen

Copy link
Copy Markdown
Member

I am +1 on this.
Any thought on var to let ? Maybe in the end ,we can add https://eslint.org/docs/rules/no-var.

@tniessentniessen left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I know we have shot these PRs down multiple times, but this one is only 343 lines and if that's all it takes to make all possible varconst replacements, I think we should do it.

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@BridgeARBridgeAR added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Mar 26, 2019
@Trott

Copy link
Copy Markdown
Member

Note: I did not update any eslint rules as there is no explicit rule to do this. Instead, I just modified the prefer-const rule to match against var instead of let.

const and let have the same scoping rules so that ESLint rule makes sense. But var is different. Is there a chance that this introduces subtle bugs where some code expects a variable to be hoisted but now it isn't? I'm guessing there isn't a problem because all the tests are passing, but an extra careful eye in review and maybe even a CITGM run might be worthwhile. (Not saying it's semver major--just saying extra test exercising via CITGM might be a good extra-cautious measure.)

@BridgeAR

Copy link
Copy Markdown
MemberAuthor

@Trott eslint itself should warn in case the scope is not correct anymore. There could in theory also be changes that can not be auto detected but that's unlikely. Especially with our test suite.

@Trott

Copy link
Copy Markdown
Member

@Trott eslint itself should warn in case the scope is not correct anymore.

Ah, yes, of course.

There could in theory also be changes that can not be auto detected but that's unlikely. Especially with our test suite.

👍

@BridgeAR

Copy link
Copy Markdown
MemberAuthor

Rebased due to conflicts.

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@nodejs-github-bot

nodejs-github-bot commented Mar 29, 2019

Copy link
Copy Markdown
Collaborator

@targos

Copy link
Copy Markdown
Member

Landed in f86f573

@targostargos closed this Mar 30, 2019
targos pushed a commit that referenced this pull request Mar 30, 2019
Refs: #26679
PR-URL: #26915
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Refael Ackermann <refack@gmail.com>
@BridgeARBridgeAR mentioned this pull request Apr 1, 2019
2 tasks
BethGriggs pushed a commit that referenced this pull request Apr 5, 2019
Refs: #26679
PR-URL: #26915
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Refael Ackermann <refack@gmail.com>
BethGriggs pushed a commit that referenced this pull request Apr 8, 2019
Refs: #26679
PR-URL: #26915
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Refael Ackermann <refack@gmail.com>
Signed-off-by: Beth Griggs <Bethany.Griggs@uk.ibm.com>
@BethGriggsBethGriggs mentioned this pull request Apr 9, 2019
@ZYSzysZYSzys mentioned this pull request Jun 6, 2019
2 tasks
@BridgeAR
BridgeAR deleted the var-const branch January 20, 2020 11:27
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

author readyPRs that have at least one approval, no pending requests for changes, and a CI started.lib / srcIssues and PRs related to general changes in the lib or src directory.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants

@BridgeAR@nodejs-github-bot@gengjiawen@Trott@targos@refack@tniessen@hezhijun80