File tree Expand file tree Collapse file tree 1 file changed +18
-3
lines changed Expand file tree Collapse file tree 1 file changed +18
-3
lines changed Original file line number Diff line number Diff line change @@ -23,10 +23,13 @@ Examples of **correct** code for this rule:
2323
2424``` ts
2525import { Subject } from " rxjs" ;
26+
2627class Answers {
27- private _answers: Subject <string >;
28- get answers() {
29- return this ._answers .asObservable ();
28+ private answersSubject = new Subject <string >();
29+ public answers$ = this .answersSubject .asObservable ();
30+
31+ public nextAnswer(a : string ) {
32+ this .answersSubject .next (a );
3033 }
3134}
3235```
@@ -51,3 +54,15 @@ This rule accepts a single option which is an object with an `allowProtected` pr
5154 ]
5255}
5356```
57+
58+ ## When Not To Use It
59+
60+ If you don't care about encapsulating subjects in your project, then you don't need this rule.
61+ However, be aware that anyone can call ` next() ` or ` complete() ` on the exposed subject, which may cause bugs or less readable code.
62+
63+ Type checked lint rules are more powerful than traditional lint rules, but also require configuring type checked linting.
64+
65+ ## Resources
66+
67+ - [ Rule source] ( https://github.com/JasonWeinzierl/eslint-plugin-rxjs-x/blob/main/src/rules/no-exposed-subjects.ts )
68+ - [ Test source] ( https://github.com/JasonWeinzierl/eslint-plugin-rxjs-x/blob/main/tests/rules/no-exposed-subjects.test.ts )
You can’t perform that action at this time.
0 commit comments