Enable customizing reactive rule to treat certain custom functions as reactive #112
Closed
1 task done
Labels
enhancement
New feature or request
Describe the need
I am making a library for my team which handles data fetching with our custom protocol. The library will take in the arguments to the API call and return a signal, very similar to the native
createResource
.Our library's interface looks something like:
This works great and we are very careful to use that signal accessor that is passed to the
query
method only in a reactive scope. The problem is that to a user who is using thesolid/reactivity
rule, it marksquery(mySignal)
as an error. We need a way to indicate that our function, despite being custom, is safe to pass a signal to so that the ESLint rule doesn't improperly warn about it. (But it should still warn if the user instead doesquery(mySignal())
which would break reactivity.Suggested Solution
This seems to be already discussed in Implementation v2 under the "Non-extensible" problem bullet point.
Possible Alternatives
We can hack around the limitations of the rule by changing the function signature to
function query(arg: () => Accessor): Accessor
which then the reactivity rule no longer errors. But this is an already known bug and we don't want to design our API surface around relying on a bug in a linter.The other option is to disable the rule entirely, or for every occurrence of someone using our
query
method. This is a slippery slope and will likely hide other actual issues.Additional context
It'd be great if the rule had an option which could be set in the ESLint config similar to jest/expect-expect.
Our full API calls actually look like
client.something.something.something.query(mySignal)
with any number of arbitrary something's in the middle (because tRPC). So it'd be ideal if the configuration option checked just the function callquery(mySignal)
ignoring whatever the user-defined namespace is.The text was updated successfully, but these errors were encountered: