Skip to content

Conversation

@mdevils
Copy link
Contributor

@mdevils mdevils commented May 17, 2025

Summary

Added the new rule noNestedComponentDefinitions,
which disallows nested component definitions in React components.

Closes #4989

This rule is useful for preventing potential performance issues and improving code readability by ensuring that components are defined at the top level.

Example (Invalid):

function ParentComponent() {
  function ChildComponent() {
    return <div>Hello</div>;
  }
  return <ChildComponent />;
}

Example (Valid):

function ChildComponent() {
  return <div>Hello</div>;
}
function ParentComponent() {
  return <ChildComponent />;
}

Test Plan

Tests are included.

@github-actions github-actions bot added A-CLI Area: CLI A-Project Area: project A-Linter Area: linter L-JavaScript Language: JavaScript and super languages A-Diagnostic Area: diagnostocis labels May 17, 2025
@codspeed-hq
Copy link

codspeed-hq bot commented May 17, 2025

CodSpeed Performance Report

Merging #6053 will not alter performance

Comparing mdevils:feat/no-nested-component-definitions (2784a0a) with main (a57a018)

Summary

✅ 95 untouched benchmarks

Copy link
Contributor

@dyc3 dyc3 left a comment

Choose a reason for hiding this comment

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

Great work, as always!

Copy link
Contributor

@dyc3 dyc3 left a comment

Choose a reason for hiding this comment

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

Looks great!

Looking forward to the follow up PR, as discussed here: https://github.com/biomejs/biome/pull/6053/files#r2094610735

And, if you're looking for what to work on after that, I think you could take on #50.

@mdevils
Copy link
Contributor Author

mdevils commented May 18, 2025

@dyc3 yep, I'll create a PR with react component detection improvements soon.

#50 is an interesting task, feel free to assign it to me.

@dyc3 dyc3 merged commit 64ca243 into biomejs:main May 18, 2025
14 checks passed
@dyc3
Copy link
Contributor

dyc3 commented May 18, 2025

@mdevils I'll need you to comment on that issue for me to assign it. Github doesn't let you assign non-participants if they aren't a member of the org.

@mdevils mdevils deleted the feat/no-nested-component-definitions branch May 19, 2025 12:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-CLI Area: CLI A-Diagnostic Area: diagnostocis A-Linter Area: linter A-Project Area: project L-JavaScript Language: JavaScript and super languages

Projects

None yet

Development

Successfully merging this pull request may close these issues.

📎 Implement noNestedComponentDefinitions

3 participants