Skip to content

Commit 7fd3443

Browse files
authored
Add rxjs/recommend eslint rules (#2724)
We will probably want to tweak these as we get more used to them.
1 parent c45f724 commit 7fd3443

File tree

5 files changed

+290
-32
lines changed

5 files changed

+290
-32
lines changed

.eslintrc.cjs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,13 @@ Please see LICENSE in the repository root for full details.
88
`;
99

1010
module.exports = {
11-
plugins: ["matrix-org"],
11+
plugins: ["matrix-org", "rxjs"],
1212
extends: [
1313
"plugin:matrix-org/react",
1414
"plugin:matrix-org/a11y",
1515
"plugin:matrix-org/typescript",
1616
"prettier",
17+
"plugin:rxjs/recommended",
1718
],
1819
parserOptions: {
1920
ecmaVersion: "latest",

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@
7373
"eslint-plugin-matrix-org": "^1.2.1",
7474
"eslint-plugin-react": "^7.29.4",
7575
"eslint-plugin-react-hooks": "^5.0.0",
76+
"eslint-plugin-rxjs": "^5.0.3",
7677
"eslint-plugin-unicorn": "^56.0.0",
7778
"global-jsdom": "^25.0.0",
7879
"history": "^4.0.0",

src/state/MediaViewModel.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,10 @@ abstract class BaseMediaViewModel extends ViewModel {
245245
encryptionSystem.kind !== E2eeType.NONE &&
246246
(a.publication?.isEncrypted === false ||
247247
v.publication?.isEncrypted === false),
248-
).pipe(distinctUntilChanged(), shareReplay(1));
248+
).pipe(
249+
distinctUntilChanged(),
250+
shareReplay({ bufferSize: 1, refCount: false }),
251+
);
249252

250253
if (participant.isLocal || encryptionSystem.kind === E2eeType.NONE) {
251254
this.encryptionStatus = of(EncryptionStatus.Okay).pipe(

src/state/ObservableScope.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,11 @@ export class ObservableScope {
3232
}
3333

3434
private readonly stateImpl: MonoTypeOperator = (o) =>
35-
o.pipe(this.bind(), distinctUntilChanged(), shareReplay(1));
35+
o.pipe(
36+
this.bind(),
37+
distinctUntilChanged(),
38+
shareReplay({ bufferSize: 1, refCount: false }),
39+
);
3640

3741
/**
3842
* Transforms an Observable into a hot state Observable which replays its

0 commit comments

Comments
 (0)