Skip to content

Inner render function triggers solid/components-return-once #116

Closed
@tronikelis

Description

@tronikelis

Describe the bug
Inner render functions trigger the early return rule, but they shouldn't

To Reproduce
https://playground.solidjs.com/anonymous/7d1abcec-af91-4975-8058-dfd1983f2ff7

function Counter(props: ComponentProps<"button">) {
  const [c, setC] = createSignal(0);

  setInterval(() => setC((c) => c + 1), 500);

  const renderContent = () => {
    if (c() < 10) {
      return (
        <div>
          <p>{10}</p>
        </div>
      );
    }

    if (c() >= 10 && c() < 20) {
      return <p>20</p>;
    }

    return <p>out of bounds</p>;
  };

  return <div>{renderContent()}</div>;
}

Expected behavior
As I understand this is supported in solid as renderContent is within an effect inside the JSX which reacts to changes, so this shouldnt trigger this rule solid/components-return-once

Environment (please complete the following information):

  • OS: Windows 10
  • Node version 20.10.0
  • eslint-plugin-solid version 0.13.0
  • eslint version 8.56.0
  • I would be willing to contribute a PR to fix this issue

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions