[Refactoring] ESLint: Prevent falsy zero render (#2251)
This commit is contained in:
parent
a6f7c64174
commit
c6ae1062b7
@ -6,6 +6,7 @@
|
|||||||
"airbnb-typescript"
|
"airbnb-typescript"
|
||||||
],
|
],
|
||||||
"plugins": [
|
"plugins": [
|
||||||
|
"jsx-expressions",
|
||||||
"no-async-without-await",
|
"no-async-without-await",
|
||||||
"teactn",
|
"teactn",
|
||||||
"no-null"
|
"no-null"
|
||||||
@ -88,6 +89,12 @@
|
|||||||
"ignoreDOMComponents": true
|
"ignoreDOMComponents": true
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
"jsx-expressions/strict-logical-expressions": [
|
||||||
|
"error",
|
||||||
|
{
|
||||||
|
"allowString": true
|
||||||
|
}
|
||||||
|
],
|
||||||
"jsx-a11y/click-events-have-key-events": "off",
|
"jsx-a11y/click-events-have-key-events": "off",
|
||||||
"jsx-a11y/no-static-element-interactions": "off",
|
"jsx-a11y/no-static-element-interactions": "off",
|
||||||
"jsx-a11y/label-has-associated-control": "off",
|
"jsx-a11y/label-has-associated-control": "off",
|
||||||
|
|||||||
23
package-lock.json
generated
23
package-lock.json
generated
@ -59,6 +59,7 @@
|
|||||||
"eslint-plugin-flowtype": "^8.0.3",
|
"eslint-plugin-flowtype": "^8.0.3",
|
||||||
"eslint-plugin-import": "^2.26.0",
|
"eslint-plugin-import": "^2.26.0",
|
||||||
"eslint-plugin-jsx-a11y": "^6.6.1",
|
"eslint-plugin-jsx-a11y": "^6.6.1",
|
||||||
|
"eslint-plugin-jsx-expressions": "^1.3.1",
|
||||||
"eslint-plugin-no-async-without-await": "^1.2.0",
|
"eslint-plugin-no-async-without-await": "^1.2.0",
|
||||||
"eslint-plugin-no-null": "^1.0.2",
|
"eslint-plugin-no-null": "^1.0.2",
|
||||||
"eslint-plugin-react": "^7.31.11",
|
"eslint-plugin-react": "^7.31.11",
|
||||||
@ -7313,6 +7314,28 @@
|
|||||||
"node": ">=6.0"
|
"node": ">=6.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/eslint-plugin-jsx-expressions": {
|
||||||
|
"version": "1.3.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/eslint-plugin-jsx-expressions/-/eslint-plugin-jsx-expressions-1.3.1.tgz",
|
||||||
|
"integrity": "sha512-7PTIx62Oy4l3Igtat361C/SCrJ4yXNNJRh/pzXMbzvPzFkvOpHBkTXITkH8PMLDu1RAdilDpjaOUv1m14DbY7w==",
|
||||||
|
"dev": true,
|
||||||
|
"dependencies": {
|
||||||
|
"@typescript-eslint/experimental-utils": "^5.5.0",
|
||||||
|
"tsutils": "^3.21.0"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": "12.x || 14.x || >= 16"
|
||||||
|
},
|
||||||
|
"peerDependencies": {
|
||||||
|
"@typescript-eslint/parser": "^4.0.0 || ^5.0.0",
|
||||||
|
"eslint": "^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0"
|
||||||
|
},
|
||||||
|
"peerDependenciesMeta": {
|
||||||
|
"typescript": {
|
||||||
|
"optional": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/eslint-plugin-no-async-without-await": {
|
"node_modules/eslint-plugin-no-async-without-await": {
|
||||||
"version": "1.2.0",
|
"version": "1.2.0",
|
||||||
"resolved": "https://registry.npmjs.org/eslint-plugin-no-async-without-await/-/eslint-plugin-no-async-without-await-1.2.0.tgz",
|
"resolved": "https://registry.npmjs.org/eslint-plugin-no-async-without-await/-/eslint-plugin-no-async-without-await-1.2.0.tgz",
|
||||||
|
|||||||
@ -79,6 +79,7 @@
|
|||||||
"eslint-plugin-flowtype": "^8.0.3",
|
"eslint-plugin-flowtype": "^8.0.3",
|
||||||
"eslint-plugin-import": "^2.26.0",
|
"eslint-plugin-import": "^2.26.0",
|
||||||
"eslint-plugin-jsx-a11y": "^6.6.1",
|
"eslint-plugin-jsx-a11y": "^6.6.1",
|
||||||
|
"eslint-plugin-jsx-expressions": "^1.3.1",
|
||||||
"eslint-plugin-no-async-without-await": "^1.2.0",
|
"eslint-plugin-no-async-without-await": "^1.2.0",
|
||||||
"eslint-plugin-no-null": "^1.0.2",
|
"eslint-plugin-no-null": "^1.0.2",
|
||||||
"eslint-plugin-react": "^7.31.11",
|
"eslint-plugin-react": "^7.31.11",
|
||||||
|
|||||||
@ -312,7 +312,7 @@ const Audio: FC<OwnProps> = ({
|
|||||||
<p className="title" dir="auto" title={renderFirstLine()}>{renderText(renderFirstLine())}</p>
|
<p className="title" dir="auto" title={renderFirstLine()}>{renderText(renderFirstLine())}</p>
|
||||||
|
|
||||||
<div className="message-date">
|
<div className="message-date">
|
||||||
{date && (
|
{Boolean(date) && (
|
||||||
<Link
|
<Link
|
||||||
className="date"
|
className="date"
|
||||||
onClick={handleDateClick}
|
onClick={handleDateClick}
|
||||||
@ -469,7 +469,7 @@ function renderAudio(
|
|||||||
<span className="performer" dir="auto" title={performer}>{renderText(performer)}</span>
|
<span className="performer" dir="auto" title={performer}>{renderText(performer)}</span>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
{date && (
|
{Boolean(date) && (
|
||||||
<>
|
<>
|
||||||
<span className="bullet">•</span>
|
<span className="bullet">•</span>
|
||||||
<Link className="date" onClick={handleDateClick}>
|
<Link className="date" onClick={handleDateClick}>
|
||||||
|
|||||||
@ -146,7 +146,7 @@ const File: FC<OwnProps> = ({
|
|||||||
{isTransferring && transferProgress ? `${Math.round(transferProgress * 100)}%` : sizeString}
|
{isTransferring && transferProgress ? `${Math.round(transferProgress * 100)}%` : sizeString}
|
||||||
</span>
|
</span>
|
||||||
{sender && <span className="file-sender">{renderText(sender)}</span>}
|
{sender && <span className="file-sender">{renderText(sender)}</span>}
|
||||||
{!sender && timestamp && (
|
{!sender && Boolean(timestamp) && (
|
||||||
<>
|
<>
|
||||||
<span className="bullet" />
|
<span className="bullet" />
|
||||||
<Link onClick={onDateClick}>{formatMediaDateTime(lang, timestamp * 1000, true)}</Link>
|
<Link onClick={onDateClick}>{formatMediaDateTime(lang, timestamp * 1000, true)}</Link>
|
||||||
@ -154,7 +154,7 @@ const File: FC<OwnProps> = ({
|
|||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{sender && timestamp && (
|
{sender && Boolean(timestamp) && (
|
||||||
<Link onClick={onDateClick}>{formatPastTimeShort(lang, timestamp * 1000)}</Link>
|
<Link onClick={onDateClick}>{formatPastTimeShort(lang, timestamp * 1000)}</Link>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -243,7 +243,7 @@ const ForumPanel: FC<OwnProps & StateProps> = ({
|
|||||||
sensitiveArea={TOPIC_LIST_SENSITIVE_AREA}
|
sensitiveArea={TOPIC_LIST_SENSITIVE_AREA}
|
||||||
beforeChildren={<div ref={scrollTopHandlerRef} className={styles.scrollTopHandler} />}
|
beforeChildren={<div ref={scrollTopHandlerRef} className={styles.scrollTopHandler} />}
|
||||||
>
|
>
|
||||||
{viewportIds?.length && (
|
{Boolean(viewportIds?.length) && (
|
||||||
renderTopics()
|
renderTopics()
|
||||||
)}
|
)}
|
||||||
{isLoading && !viewportIds?.length && (
|
{isLoading && !viewportIds?.length && (
|
||||||
|
|||||||
@ -191,8 +191,7 @@ const SettingsHeader: FC<OwnProps> = ({
|
|||||||
return (
|
return (
|
||||||
<div className="settings-main-header">
|
<div className="settings-main-header">
|
||||||
<h3>{lang('FilterEdit')}</h3>
|
<h3>{lang('FilterEdit')}</h3>
|
||||||
|
{Boolean(editedFolderId) && (
|
||||||
{editedFolderId && (
|
|
||||||
<DropdownMenu
|
<DropdownMenu
|
||||||
className="settings-more-menu"
|
className="settings-more-menu"
|
||||||
trigger={SettingsMenuButton}
|
trigger={SettingsMenuButton}
|
||||||
|
|||||||
@ -51,7 +51,7 @@ const GiftOption: FC<OwnProps> = ({
|
|||||||
<div className={styles.month}>{lang('Months', months)}</div>
|
<div className={styles.month}>{lang('Months', months)}</div>
|
||||||
<div className={styles.perMonth}>
|
<div className={styles.perMonth}>
|
||||||
{lang('PricePerMonth', formatCurrency(perMonth, currency, lang.code))}
|
{lang('PricePerMonth', formatCurrency(perMonth, currency, lang.code))}
|
||||||
{discount && (
|
{Boolean(discount) && (
|
||||||
<span className={styles.discount} title={lang('GiftDiscount')}> −{discount}% </span>
|
<span className={styles.discount} title={lang('GiftDiscount')}> −{discount}% </span>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -60,7 +60,7 @@ const MediaViewerFooter: FC<OwnProps> = ({
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={classNames} onClick={stopEvent}>
|
<div className={classNames} onClick={stopEvent}>
|
||||||
{text && (
|
{Boolean(text) && (
|
||||||
<div className="media-viewer-footer-content" onClick={!IS_SINGLE_COLUMN_LAYOUT ? onClick : undefined}>
|
<div className="media-viewer-footer-content" onClick={!IS_SINGLE_COLUMN_LAYOUT ? onClick : undefined}>
|
||||||
<p className={`media-text custom-scroll ${isMultiline ? 'multiline' : ''}`} dir="auto">{text}</p>
|
<p className={`media-text custom-scroll ${isMultiline ? 'multiline' : ''}`} dir="auto">{text}</p>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -147,7 +147,7 @@ const ReactorListModal: FC<OwnProps & StateProps> = ({
|
|||||||
onClick={() => setChosenTab(undefined)}
|
onClick={() => setChosenTab(undefined)}
|
||||||
>
|
>
|
||||||
<i className="icon-heart" />
|
<i className="icon-heart" />
|
||||||
{reactors?.count && formatIntegerCompact(reactors.count)}
|
{Boolean(reactors?.count) && formatIntegerCompact(reactors.count)}
|
||||||
</Button>
|
</Button>
|
||||||
{allReactions.map((reaction) => {
|
{allReactions.map((reaction) => {
|
||||||
const count = reactions?.results
|
const count = reactions?.results
|
||||||
@ -166,7 +166,7 @@ const ReactorListModal: FC<OwnProps & StateProps> = ({
|
|||||||
className="reaction-filter-emoji"
|
className="reaction-filter-emoji"
|
||||||
availableReactions={availableReactions}
|
availableReactions={availableReactions}
|
||||||
/>
|
/>
|
||||||
{count && formatIntegerCompact(count)}
|
{Boolean(count) && formatIntegerCompact(count)}
|
||||||
</Button>
|
</Button>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
|
|||||||
@ -1280,7 +1280,7 @@ const Composer: FC<OwnProps & StateProps> = ({
|
|||||||
<i className="icon-schedule" />
|
<i className="icon-schedule" />
|
||||||
</Button>
|
</Button>
|
||||||
)}
|
)}
|
||||||
{botKeyboardMessageId && !activeVoiceRecording && !editingMessage && (
|
{Boolean(botKeyboardMessageId) && !activeVoiceRecording && !editingMessage && (
|
||||||
<ResponsiveHoverButton
|
<ResponsiveHoverButton
|
||||||
className={isBotKeyboardOpen ? 'activated' : ''}
|
className={isBotKeyboardOpen ? 'activated' : ''}
|
||||||
round
|
round
|
||||||
@ -1291,7 +1291,7 @@ const Composer: FC<OwnProps & StateProps> = ({
|
|||||||
<i className="icon-bot-command" />
|
<i className="icon-bot-command" />
|
||||||
</ResponsiveHoverButton>
|
</ResponsiveHoverButton>
|
||||||
)}
|
)}
|
||||||
{activeVoiceRecording && currentRecordTime && (
|
{activeVoiceRecording && Boolean(currentRecordTime) && (
|
||||||
<span className="recording-state">
|
<span className="recording-state">
|
||||||
{formatVoiceRecordDuration(currentRecordTime - startRecordTimeRef.current!)}
|
{formatVoiceRecordDuration(currentRecordTime - startRecordTimeRef.current!)}
|
||||||
</span>
|
</span>
|
||||||
@ -1309,7 +1309,7 @@ const Composer: FC<OwnProps & StateProps> = ({
|
|||||||
peerType={attachMenuPeerType}
|
peerType={attachMenuPeerType}
|
||||||
theme={theme}
|
theme={theme}
|
||||||
/>
|
/>
|
||||||
{botKeyboardMessageId && (
|
{Boolean(botKeyboardMessageId) && (
|
||||||
<BotKeyboardMenu
|
<BotKeyboardMenu
|
||||||
messageId={botKeyboardMessageId}
|
messageId={botKeyboardMessageId}
|
||||||
isOpen={isBotKeyboardOpen}
|
isOpen={isBotKeyboardOpen}
|
||||||
|
|||||||
@ -202,7 +202,7 @@ const InlineBotTooltip: FC<OwnProps> = ({
|
|||||||
sensitiveArea={160}
|
sensitiveArea={160}
|
||||||
>
|
>
|
||||||
{switchPm && renderSwitchPm()}
|
{switchPm && renderSwitchPm()}
|
||||||
{renderedInlineBotResults?.length && renderContent()}
|
{Boolean(renderedInlineBotResults?.length) && renderContent()}
|
||||||
</InfiniteScroll>
|
</InfiniteScroll>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@ -54,7 +54,7 @@ const PollResults: FC<OwnProps & StateProps> = ({
|
|||||||
<div className="PollResults" dir={lang.isRtl ? 'rtl' : undefined}>
|
<div className="PollResults" dir={lang.isRtl ? 'rtl' : undefined}>
|
||||||
<h3 className="poll-question" dir="auto">{renderText(summary.question, ['emoji', 'br'])}</h3>
|
<h3 className="poll-question" dir="auto">{renderText(summary.question, ['emoji', 'br'])}</h3>
|
||||||
<div className="poll-results-list custom-scroll">
|
<div className="poll-results-list custom-scroll">
|
||||||
{lastSyncTime && summary.answers.map((answer) => (
|
{Boolean(lastSyncTime) && summary.answers.map((answer) => (
|
||||||
<PollAnswerResults
|
<PollAnswerResults
|
||||||
key={`${message.id}-${answer.option}`}
|
key={`${message.id}-${answer.option}`}
|
||||||
chat={chat}
|
chat={chat}
|
||||||
|
|||||||
@ -146,7 +146,7 @@ const ManageInviteInfo: FC<OwnProps & StateProps> = ({
|
|||||||
onClick={handleCopyClicked}
|
onClick={handleCopyClicked}
|
||||||
/>
|
/>
|
||||||
<Button className="copy-link" onClick={handleCopyClicked}>{lang('CopyLink')}</Button>
|
<Button className="copy-link" onClick={handleCopyClicked}>{lang('CopyLink')}</Button>
|
||||||
{expireDate && (
|
{Boolean(expireDate) && (
|
||||||
<p className="text-muted">
|
<p className="text-muted">
|
||||||
{isExpired
|
{isExpired
|
||||||
? lang('ExpiredLink')
|
? lang('ExpiredLink')
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user