Skip to content

Commit eb16d5a

Browse files
committed
chore(eslint): add no-negated-condition rule
1 parent a4f7d83 commit eb16d5a

File tree

8 files changed

+54
-53
lines changed

8 files changed

+54
-53
lines changed

.eslint.common.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ const eslintCommon = {
6464
curly: "error",
6565
"no-multi-str": "warn",
6666
"no-native-reassign": "warn",
67+
"no-negated-condition": "error",
6768
"no-negated-in-lhs": "warn",
6869
"no-new-func": "warn",
6970
"no-new-object": "warn",

desktop/renderer-app/src/api-middleware/rtm.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,18 @@ export class Rtm extends EventEmitter {
352352
return;
353353
}
354354

355-
if (peerId !== undefined) {
355+
if (peerId === undefined) {
356+
await this.commands.sendMessage(
357+
{
358+
messageType: AgoraRTM.MessageType.TEXT,
359+
text: JSON.stringify({ t: type, v: value }),
360+
},
361+
{ enableHistoricalMessaging: keepHistory },
362+
);
363+
if (NODE_ENV === "development") {
364+
console.log("[RTM] send group command: ", type, value);
365+
}
366+
} else {
356367
await polly()
357368
.waitAndRetry(retry)
358369
.executeForPromise(async (): Promise<void> => {
@@ -371,17 +382,6 @@ export class Rtm extends EventEmitter {
371382
return Promise.reject("peer not received");
372383
}
373384
});
374-
} else {
375-
await this.commands.sendMessage(
376-
{
377-
messageType: AgoraRTM.MessageType.TEXT,
378-
text: JSON.stringify({ t: type, v: value }),
379-
},
380-
{ enableHistoricalMessaging: keepHistory },
381-
);
382-
if (NODE_ENV === "development") {
383-
console.log("[RTM] send group command: ", type, value);
384-
}
385385
}
386386
}
387387

desktop/renderer-app/src/pages/DeviceCheckPages/MicrophoneCheckPage/index.tsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -172,13 +172,7 @@ export const MicrophoneCheckPage = (): React.ReactElement => {
172172
}
173173

174174
function renderFooter(): React.ReactNode {
175-
if (!isSuccess) {
176-
return (
177-
<Button type="primary" onClick={resetCheck} className="device-check-modal-btn">
178-
{t("test-again")}
179-
</Button>
180-
);
181-
} else {
175+
if (isSuccess) {
182176
return (
183177
<Button
184178
type="primary"
@@ -188,6 +182,12 @@ export const MicrophoneCheckPage = (): React.ReactElement => {
188182
{t("ok")}
189183
</Button>
190184
);
185+
} else {
186+
return (
187+
<Button type="primary" onClick={resetCheck} className="device-check-modal-btn">
188+
{t("test-again")}
189+
</Button>
190+
);
191191
}
192192
}
193193

packages/flat-components/src/components/ErrorPage/index.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ export const ErrorPage: React.FC = () => {
1515
const { t } = useTranslation();
1616

1717
const goHome = (): void => {
18-
if (location.pathname !== "/") {
19-
history.push("/");
20-
} else {
18+
if (location.pathname === "/") {
2119
window.location.reload();
20+
} else {
21+
history.push("/");
2222
}
2323
};
2424

packages/flat-components/src/components/InviteModal/index.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@ export const InviteModal: React.FC<InviteModalProps> = ({
4141

4242
const formatBeginTime = completeTimeFormat(beginTime);
4343
const formatEndTime =
44-
differenceInCalendarDays(beginTime, endTime) !== 0
45-
? completeTimeFormat(endTime)
46-
: onlySuffixTimeFormat(endTime);
44+
differenceInCalendarDays(beginTime, endTime) === 0
45+
? onlySuffixTimeFormat(endTime)
46+
: completeTimeFormat(endTime);
4747

4848
return `${formatBeginTime}~${formatEndTime}`;
4949
}, [beginTime, endTime]);

packages/flat-components/src/components/LoginPage/LoginContent/index.tsx

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,16 @@ export const LoginContent: React.FC<LoginContentProps> = ({ onLogin, privacyURL,
2828
classNames="slider-in"
2929
unmountOnExit
3030
>
31-
{!inPageLogin ? (
31+
{inPageLogin ? (
32+
<div className="login-content-container">
33+
<div className="qr-code-container">
34+
<div className="qr-code">{inPageLogin}</div>
35+
<a className="qr-code-link" onClick={() => setInPageLogin(void 0)}>
36+
{t("login-using-other-methods")}
37+
</a>
38+
</div>
39+
</div>
40+
) : (
3241
<div className="login-content-container">
3342
<div className="login-content-logo">
3443
<img src={logoSVG} />
@@ -40,10 +49,10 @@ export const LoginContent: React.FC<LoginContentProps> = ({ onLogin, privacyURL,
4049
<div className="login-content-channel">
4150
<LoginChannel
4251
onLogin={loginChannel => {
43-
if (!isChecked) {
44-
void message.info(t("agree-terms"));
45-
} else {
52+
if (isChecked) {
4653
setInPageLogin(onLogin(loginChannel));
54+
} else {
55+
void message.info(t("agree-terms"));
4756
}
4857
}}
4958
/>
@@ -64,15 +73,6 @@ export const LoginContent: React.FC<LoginContentProps> = ({ onLogin, privacyURL,
6473
</Checkbox>
6574
</div>
6675
</div>
67-
) : (
68-
<div className="login-content-container">
69-
<div className="qr-code-container">
70-
<div className="qr-code">{inPageLogin}</div>
71-
<a className="qr-code-link" onClick={() => setInPageLogin(void 0)}>
72-
{t("login-using-other-methods")}
73-
</a>
74-
</div>
75-
</div>
7676
)}
7777
</CSSTransition>
7878
</SwitchTransition>

packages/flat-components/src/containers/CloudStorageContainer/index.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,10 @@ export const CloudStorageContainer = observer<CloudStorageContainerProps>(
7878
</div>
7979
)}
8080
<div className="cloud-storage-container-file-list fancy-scrollbar">
81-
{!store.totalUsageHR ? (
82-
<CloudStorageSkeletons isCompactMode={store.compact} />
83-
) : (
81+
{store.totalUsageHR ? (
8482
<CloudStorageFileListContainer store={store} />
83+
) : (
84+
<CloudStorageSkeletons isCompactMode={store.compact} />
8585
)}
8686
</div>
8787
<CSSTransition

web/flat-web/src/api-middleware/Rtm.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,18 @@ export class Rtm extends EventEmitter<keyof RTMEvents> {
352352
return;
353353
}
354354

355-
if (peerId !== undefined) {
355+
if (peerId === undefined) {
356+
await this.commands.sendMessage(
357+
{
358+
messageType: AgoraRTM.MessageType.TEXT,
359+
text: JSON.stringify({ t: type, v: value }),
360+
},
361+
{ enableHistoricalMessaging: keepHistory },
362+
);
363+
if (NODE_ENV === "development") {
364+
console.log("[RTM] send group command: ", type, value);
365+
}
366+
} else {
356367
await polly()
357368
.waitAndRetry(retry)
358369
.executeForPromise(async (): Promise<void> => {
@@ -371,17 +382,6 @@ export class Rtm extends EventEmitter<keyof RTMEvents> {
371382
return Promise.reject("peer not received");
372383
}
373384
});
374-
} else {
375-
await this.commands.sendMessage(
376-
{
377-
messageType: AgoraRTM.MessageType.TEXT,
378-
text: JSON.stringify({ t: type, v: value }),
379-
},
380-
{ enableHistoricalMessaging: keepHistory },
381-
);
382-
if (NODE_ENV === "development") {
383-
console.log("[RTM] send group command: ", type, value);
384-
}
385385
}
386386
}
387387

0 commit comments

Comments
 (0)