solidjs-community / eslint-plugin-solid

Solid-specific linting rules for ESLint.
MIT License
216 stars 26 forks source link

Spreading out a property of an object causes an error #30

Closed Zachiah closed 1 year ago

Zachiah commented 2 years ago

Describe the bug If there is code where the user is spreading a property access, or function call expression (<Comp {...props.x} />), the eslint plugin throws an error, however this works

To Reproduce Try this code:

import { render } from "solid-js/web";
import { createSignal } from "solid-js";

const Comp1 = (props: { text: string; num: number }) => {
  return (
    <p>
      {props.text} {props.num}
    </p>
  );
};

const Comp2 = (props: { p: { text: string; num: number } }) => {
  return <Comp1 {...props.p} />;
};

const App = () => {
  const [num, setNum] = createSignal(1);
  const [text, setText] = createSignal("");

  return (
    <div>
      <input
        value={num()}
        type="number"
        onInput={(e) => setNum(+e.currentTarget.value)}
      />
      <input
        value={text()}
        onInput={(e) => setText(e.currentTarget.value)}
      />

      <Comp2
        p={{
          text: text(),
          num: num(),
        }}
      />
    </div>
  );
};

render(() => <App />, document.getElementById("app")!);

Expected behavior I expected there to not be an error (:

Desktop (please complete the following information):

Zachiah commented 2 years ago

A playground to demonstrate the code working: https://playground.solidjs.com/?hash=-1217724377&version=1.4.1

joshwilsonvu commented 2 years ago

You're right, it works! I'll try to get a fix into the next release, thanks for the issue.

joshwilsonvu commented 1 year ago

The warnings you're seeing should be gone in v0.7.4. Thanks again!