orenelbaum / babel-plugin-solid-undestructure

A Babel plugin for SolidJS that allows you to destructure component props without losing reactivity.
95 stars 3 forks source link

Add new component detection mode based on eslint-plugin-solid's no-destructure rule #13

Open orenelbaum opened 1 year ago

orenelbaum commented 1 year ago

Right now the plugin knows which functions to transform by finding functions annotated with the Component type or the component compile time function. I came across this lint rule that warns when props are destructured in components. If I understand correctly detects components by looking for every function that has JSX somewhere in the body of the function, with a few exceptions. This suggestion is about adding a detection mode that works the same way or in a similar way to detect components that will be transformed, and thus when enabled, annotating components in other ways won't be necessary.

Right now I can see are 2 main drawbacks to this:

Even with those drawbacks I think that this heuristic would probably work for a lot of people or even most people, so probably worth adding as a separate mode.