Navigation Menu

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

Convert var/let to let/const #238

Closed
wants to merge 4 commits into from
Closed

Conversation

aminya
Copy link

@aminya aminya commented Mar 31, 2021

This PR converts the usage of var/let to let/const using Eslint.

Method

Eslint parses the AST and performs scope analysis and reference counting to verify that these changes are safe.

The example of conversion for lib folder:

eslint ./lib --rule 'no-var: 2' --fix
eslint ./lib --rule 'prefer-const: 2' --fix

Benefits

  • Using var results in unwanted behavior because its scope is leaked upwards. This PR prevents these kinds of bugs. JsCodeshift already finds the cases where the conversion is not safe and var is leaked intentionally and leaves them as is.

  • This allows the JavaScript engine to perform better optimizations for the code

```
eslint ./lib --rule 'no-var: 2' --fix
```
```
eslint ./lib --rule 'prefer-const: 2' --fix
```
```
eslint ./tests/es6 --rule 'prefer-const: 2' --fix
```
Julusian added a commit that referenced this pull request May 10, 2022
@Julusian
Copy link
Collaborator

I have re-run those commands on master to make the change avoiding the conflicts this pr had

@Julusian Julusian closed this May 10, 2022
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

2 participants