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

Replace var in javascript with let/const #5558

Merged
merged 2 commits into from
Feb 16, 2025

Conversation

tomhughes
Copy link
Member

This updates the eslint config to prohibit use of var and to prefer const over let and then fixes all uses of var to respect that.

Copy link

1 Warning
⚠️ Number of updated lines of code is too large to be in one PR. Perhaps it should be separated into two or more?

Generated by 🚫 Danger

@AntonKhorev
Copy link
Collaborator

and then fixes all uses of var to respect that

Not in unmerged pull requests.

@tomhughes tomhughes force-pushed the var-let-const branch 2 times, most recently from 728d991 to 4e28e7f Compare January 29, 2025 18:45
@AntonKhorev
Copy link
Collaborator

If this is merged, I'll have to rewrite #5064 again. That's a bugfix PR. People are still complaining about bugs it fixes.

@hlfan
Copy link
Contributor

hlfan commented Jan 31, 2025

@AntonKhorev I'd still say merge sooner rather than later just because all the arising issues can be autofixed.

@tomhughes tomhughes force-pushed the var-let-const branch 5 times, most recently from 99fb2a9 to f6416cd Compare February 8, 2025 17:46
Comment on lines 45 to 43
url: content_path,
url: path,
Copy link
Contributor

Choose a reason for hiding this comment

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

If you're already cleaning up after me, you can define the function as function (url, callback) for even more conciseness.

Copy link
Contributor

Choose a reason for hiding this comment

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

Or maybe not given #5663

Copy link
Contributor

@nertc nertc left a comment

Choose a reason for hiding this comment

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

All occurrences of var are changed with let/const. Checked all changed variables and let and const are set accordingly (every variable that is not changed after declaration, is const). Also spent some time on website to test it generally, if any page threw error in the console. Everything I checked works as expected, there are no errors.

@hlfan
Copy link
Contributor

hlfan commented Feb 14, 2025

All occurrences of var are changed with let/const. Checked all changed variables and let and const are set accordingly (every variable that is not changed after declaration, is const).

ESLint concurs (after 1.88 seconds)

@tomhughes tomhughes force-pushed the var-let-const branch 2 times, most recently from 83dde9e to 61760af Compare February 15, 2025 15:14
@HolgerJeromin
Copy link
Contributor

Can we merge this please?
At least I hesitate to do small things which only creates conflicts with this PR

Copy link
Collaborator

@gravitystorm gravitystorm left a comment

Choose a reason for hiding this comment

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

Needs rebase, but otherwise looks good to me. I agree it would be good to merge this as soon as we can.

@tomhughes
Copy link
Member Author

I've rebased this now.

@gravitystorm gravitystorm merged commit d095dfe into openstreetmap:master Feb 16, 2025
22 checks passed
@gravitystorm
Copy link
Collaborator

Merged, thanks!

@tomhughes tomhughes deleted the var-let-const branch February 16, 2025 11:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants