Skip to content

feat(ESLint): prefer early return - #8784

Closed
mxdvl wants to merge 2 commits into
mainfrom
mxdvl/prefer-early-return
Closed

mxdvl wants to merge 2 commits into
mainfrom
mxdvl/prefer-early-return

Conversation

@mxdvl

@mxdvl mxdvl commented Sep 7, 2023 •

Copy link
Copy Markdown
Contributor

What does this change?

This is a proposal, feedback welcome.

Enforces early returns over nested methods via a linting rule.

Why?

Avoiding nesting helps readability on narrower screens.

Currently, there’s 50 instances where we would need to adjust the code should this rule be adopted. This shows a handful of examples of what the changes might look like.

Screenshots

N/A – see 2560fbe

@mxdvl
mxdvl force-pushed the mxdvl/prefer-early-return branch from acd4d98 to 2560fbe Compare September 7, 2023 09:10
@github-actions

github-actions Bot commented Sep 7, 2023 •

Copy link
Copy Markdown

Size Change: 0 B 🆕

Total Size: 0 B

compressed-size-action

@mxdvl mxdvl added question Dependencies Pull requests that update a dependency file Health labels Sep 7, 2023
avoiding nesting helps readability on narrower screens
@mxdvl
mxdvl force-pushed the mxdvl/prefer-early-return branch from 2560fbe to d3f778e Compare September 7, 2023 09:39
@mxdvl
mxdvl changed the base branch from main to mxdvl/conditional-import-web-vitals September 7, 2023 09:39
Base automatically changed from mxdvl/conditional-import-web-vitals to main September 7, 2023 10:11
@cemms1 cemms1 modified the milestone: Health Oct 4, 2023
@cemms1 cemms1 removed the Health label Oct 4, 2023
@mxdvl

mxdvl commented Mar 18, 2025 •

Copy link
Copy Markdown
Contributor Author
if(Date.now() - PR.opened.getTime() > 31_000_000_000) {
  return await PR.close();
}

await PR.requestReviews();

@mxdvl mxdvl closed this Mar 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Dependencies Pull requests that update a dependency file dotcom-rendering question

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants