jambit / eslint-plugin-typed-redux-saga

These are eslint rules to help with typed-redux-saga
MIT License
17 stars 3 forks source link

Added yield-effects rule #5

Closed dejesus2010 closed 2 years ago

dejesus2010 commented 2 years ago

This rule checks to ensure all effects imported are yielded.

It is ported over from the untyped project eslint-plugin-redux-saga.

In this commit I added mocha tests for the new rule and moved existing files under a /lib/rules directory as an attempt to tidy up the project directory a bit.

danielweck commented 2 years ago

great, thank you :)

dejesus2010 commented 2 years ago

Thanks for the reply @SantoJambit. I have updated the commit with your suggestions

dejesus2010 commented 2 years ago

So while updating delegate-effects.js to use the shared tracker I created in the recent change, I realized delegate-effects.js does what this PR is doing... That is: if we're calling a typed effect, ensure that yield* is inserted before the effect if no yield exists. I missed that when I was reading through the project.

I added tests to test delegate-effects.js and the tests fail when we call an effect without a yield/yield*, which is correct. But in my project eslint isn't picking it up... It only picks up the replacement of yield to yield*.

Any ideas what could be the issue here?

Here's my .eslintrc.json:

{
  "extends": ["next/core-web-vitals", "prettier"],
  "plugins": ["@jambit/typed-redux-saga"],
  "overrides": [
    {
      "files": ["./**/*.ts"],
      "excludedFiles": ["./**/*.spec.ts"],
      "rules": {
        "@jambit/typed-redux-saga/use-typed-effects": ["error", "macro"],
        "@jambit/typed-redux-saga/delegate-effects": "error"
      }
    }
  ]
}

I'm using the 'typed-redux-saga/macro' import

dejesus2010 commented 2 years ago

I submitted a commit that includes the tests I added. I'll wait for your response to decide how to proceed.

SantoJambit commented 2 years ago

Thanks