solidjs-community / solidjs-community/eslint-plugin-solid

Add support for destructuring @solidjs/router hooks

Open
#72 1 comment 0 reactions 1 assignee View on GitHub

@joshwilsonvu is already working on this.

Since Feb 4, 2023.

enhancement reactivity v2
Dominant language
TypeScript
Stars
266
Forks
52
Avg merge
1d 10h
Merged PRs (30d)
9

Description

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?

  • I would be willing to contribute a PR to implement this feature

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.