solidjs-community / eslint-plugin-solid

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

"This tracked scope should not be async." on onMount() #7

Closed Brawl345 closed 2 years ago

Brawl345 commented 2 years ago

Describe the bug Using "onMount()" with an async function throws:

ESLint: This tracked scope should not be async. Solid's reactivity only tracks synchronously.(solid/reactivity)

I used the example code from the official tutorial to verify: https://www.solidjs.com/tutorial/lifecycles_onmount?solved

To Reproduce Steps to reproduce the behavior:

  1. Go to https://www.solidjs.com/tutorial/lifecycles_onmount?solved
  2. Copy the code and paste it in a file
  3. Check it with ESLint
  4. See error

Expected behavior No error should be shown because it still works.

Screenshots image

Desktop (please complete the following information):

+-- eslint-config-prettier@8.3.0
| `-- eslint@8.7.0 deduped
+-- eslint-plugin-solid@0.4.1
| +-- @typescript-eslint/experimental-utils@5.10.0
| | +-- @typescript-eslint/utils@5.10.0
| | | `-- eslint@8.7.0 deduped
| | `-- eslint@8.7.0 deduped
| `-- eslint@8.7.0 deduped
+-- eslint-plugin-unicorn@40.1.0
| +-- eslint-utils@3.0.0
| | `-- eslint@8.7.0 deduped
| `-- eslint@8.7.0 deduped
`-- eslint@8.7.0

Additional context N/A

joshwilsonvu commented 2 years ago

Thanks for the report and for trying out this plugin. This is a bug, and once I have it fixed I'll add this code to the tests.

I think I'm going to change the implementation so it only warns if a signal is actually used past an await, with exceptions for onMount and a few other functions. That should cover it, I'll update you when the fix is released.

For now I hope disabling the rule for each line this affects won't be too much of an inconvenience.

Brawl345 commented 2 years ago

Thanks, take your time, no problem :)

joshwilsonvu commented 2 years ago

Got to it tonight, should be fixed in v0.4.3. Pretty simple change. Thanks again!

Brawl345 commented 2 years ago

Works, thanks! :+1: