Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Identify subjects] Doesn't work with BehaviorSubject, EtcSubject #88

Closed
splincode opened this issue Nov 17, 2021 · 6 comments
Closed
Labels
bug Something isn't working

Comments

@splincode
Copy link

{
  "rxjs/suffix-subjects": [
    "error",
    {
      "parameters": true,
      "properties": true,
      "suffix": "$$",
      "variables": true,
    }
  ]
}
const answers1 = new BehaviorSubject<number>(0); // no eslint error

class MySuperSubject extends Subject {}
class MySuperBehaviorSubject extends BehaviorSubject {}

const answers2 = new MySuperSubject<number>(); // no eslint error
const answers3 = new MySuperBehaviorSubject<number>(0); // no eslint error
@cartant
Copy link
Owner

cartant commented Nov 17, 2021

Works in the tests I just added:

fromFixture(
stripIndent`
// BehaviorSubject without suffix
import { BehaviorSubject } from "rxjs";
const source = new BehaviorSubject<number>(42);
~~~~~~ [forbidden { "suffix": "Subject" }]
`
),
fromFixture(
stripIndent`
// MySubject without suffix
import { Subject } from "rxjs";
class MySubject<T> extends Subject<T> {}
const source = new MySubject<number>();
~~~~~~ [forbidden { "suffix": "Subject" }]
`
),

Also, this is not valid, as Subject has a type parameter:

class MySuperSubject extends Subject {}

@splincode
Copy link
Author

what about test suffix is "$$", when I have const answer$ = new BehaviorSubject();?

@cartant cartant added the bug Something isn't working label Nov 18, 2021
@cartant
Copy link
Owner

cartant commented Nov 18, 2021

The suffix option is escaped in 4.0.3, so the $$ suffix thing should be fixed in that version.

@cartant cartant closed this as completed Nov 18, 2021
@cotneit
Copy link

cotneit commented Jan 24, 2022

what about test suffix is "$$", when I have const answer$ = new BehaviorSubject();?

Same config, including "$$" suffix
In 5.0.1 (also tried 4.0.3 and 4.0.4 with the same results) this seems to still be an issue for class properties

const destroy$: Subject<void> = new Subject<void>(); // eslint error

const obj = {
    destroy$: new Subject<void>(), // eslint error
}

function fn(destroy$: Subject<void>) {} // eslint error

export class OrderListComponent {
    private destroy: Subject<void> = new Subject<void>(); // eslint error
    private destroy$: Subject<void> = new Subject<void>(); // no eslint error   <---
}

cartant added a commit that referenced this issue Jan 26, 2022
@cartant
Copy link
Owner

cartant commented Jan 26, 2022

@cotneit Should be fixed in 5.0.2. In future, please open a new issue instead of commenting on a closed issue. You can reference the closed issue from the new issue. In general, that's something you should do for all repos - not just this one. It's easy to overlook such comments.

@cotneit
Copy link

cotneit commented Jan 26, 2022

@cartant Thank you! Appreciate the advice, will do so in the future!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants