solidjs-community / eslint-plugin-solid

Solid-specific linting rules for ESLint.
MIT License
209 stars 24 forks source link

Add support for destructuring @solidjs/router hooks #72

Open blarfoon opened 1 year ago

blarfoon commented 1 year ago

Describe the need At the moment, the destructuring error only appears for props. It's an issue for any reactive value being destructured though. This happened to me while using @solidjs/router's useParams

const MyComponent = () => {
  const { id } = useParams();
  ...

which should not be destructured. I understand it's impossible to detect what is reactive and what not from the eslint plugin, but maybe adding support for @solidjs/router would be a cool addition.

Suggested Solution Add support for @solidjs/router, by detecting destructures on its hooks.

Possible Alternatives Maybe detect function hooks being called inside a component that start with create or use? Pretty heuristic though. Another solution could be to prevent all destructures in the form of let/consts/var {...} = ..., maybe though an option in eslint config?

Yes, even tho I would need a few indications on how to approach the problem