cartant / eslint-plugin-rxjs

ESLint rules for RxJS
MIT License
312 stars 37 forks source link

rxjs/finnish counter-intuitive for functions assigned to variables/properties/params #105

Open jimivdw opened 2 years ago

jimivdw commented 2 years ago

Given the following configuration:

{
    "rxjs/finnish": [
        "error",
        {
            "strict": true
        }
    ]
}

We would currently get the following results:

function fun$(): Observable<never> { return EMPTY; }   // OK
const var$ = (): Observable<never> => EMPTY;           // ERROR shouldNotBeFinnish

class Cls {
  prop$ = (): Observable<never> => EMPTY;              // ERROR shouldNotBeFinnish
  mthd$(): Observable<never> { return EMPTY; }         // OK
  mthd2(par$: () => Observable<never>): void {}        // ERROR shouldNotBeFinnish
}

const var2$ = fun$;                                    // ERROR shouldNotBeFinnish
const var3$ = new Cls().mthd$;                         // ERROR shouldNotBeFinnish

To me, this feels counterintuitive. If a function/method should be in finnish notation if it returns an Observable, the same should be true when it is disguised as a variable/property/param.

Am I correct here? Or is this just not how the rule is meant to work.

Thanks in advance! And thanks in general to @cartant for maintaining this nice set of lint rules.