Skip to content

Avoid duplicate code in interactive example #40249

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

Merged
merged 2 commits into from
Jul 9, 2025
Merged

Conversation

meeque
Copy link
Contributor

@meeque meeque commented Jul 8, 2025

Description

Instead of having two identical lines in the example, add grouping parentheses to one of the code locations.
Thus make the interactive example more consistent with an example further down in the same page.

Motivation

I think the duplicate code is not helpful to readers of this interactive example.

Additional details

I think the duplicate code may have been introduced by some automated formatting that removed unnecessary grouping.

Not sure, if the proposed change will pass linting.
Would it help to use js-nolint instead of js for the changed code block?
Would js-nolint play nicely interactive-example?

Related issues and pull requests

Not aware of any. Since this is a minor/cosmetic change, I have not raised a corresponding issue yet.

Instead, add grouping parentheses to one of the code locations.
Thus make the interactive example more consistent with an example further down in the same page.
@meeque meeque requested a review from a team as a code owner July 8, 2025 10:52
@meeque meeque requested review from Josh-Cena and removed request for a team July 8, 2025 10:52
@github-actions github-actions bot added Content:JS JavaScript docs size/xs [PR only] 0-5 LoC changed labels Jul 8, 2025
Use `js-nolint` instead of `js` for the example code block.
Otherwise the linter would complain about unnecessary grouping parenthesis.
@meeque
Copy link
Contributor Author

meeque commented Jul 8, 2025

Indeed my original commit caused a linting error.
Added another commit to fix this, as proposed in the PR description.

Copy link
Contributor

github-actions bot commented Jul 8, 2025

Copy link
Member

@Josh-Cena Josh-Cena left a comment

Choose a reason for hiding this comment

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

Great catch. Thank you!

@Josh-Cena Josh-Cena merged commit 86976a4 into mdn:main Jul 9, 2025
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Content:JS JavaScript docs size/xs [PR only] 0-5 LoC changed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants